Esempio n. 1
0
import argparse
import random

from autowebcompat import network, utils

parser = argparse.ArgumentParser()
parser.add_argument('network', type=str, choices=network.SUPPORTED_NETWORKS, help='Select the network to use for training')
parser.add_argument('optimizer', type=str, choices=network.SUPPORTED_OPTIMIZERS, help='Select the optimizer to use for training')
args = parser.parse_args()

labels = utils.read_labels()

utils.prepare_images()
all_image_names = [i for i in utils.get_images() if i in labels]
all_images = sum([[i + '_firefox.png', i + '_chrome.png'] for i in all_image_names], [])
image = utils.load_image(all_images[0])
input_shape = image.shape
BATCH_SIZE = 32
EPOCHS = 50


def load_pair(fname):
    f = utils.load_image(fname + '_firefox.png')
    print(f.shape)
    c = utils.load_image(fname + '_chrome.png')
    print(c.shape)
    return [f, c]


images_train = random.sample(all_image_names, int(len(all_image_names) * 0.9))
images_test = [i for i in all_image_names if i not in set(images_train)]
Esempio n. 2
0
parser.add_argument('file_name',
                    action='store',
                    help='Filename to open and save your labels')
parser.add_argument('--verify',
                    dest='verify',
                    default=False,
                    action='store_true',
                    help='To verify and edit previous labels')
args = parser.parse_args()

labels = utils.read_labels(labels_directory + args.file_name + '.csv')
bounding_boxes = utils.read_bounding_boxes(labels_directory + args.file_name +
                                           '_bounding_box.json')

if args.verify:
    images_to_show = [i for i in utils.get_images() if i in labels]
else:
    all_labels = utils.read_labels()
    images_to_show = [i for i in utils.get_images() if i not in labels]
    images_in_all_labels = [i for i in images_to_show if i in all_labels]
    images_not_in_all_labels = [
        i for i in images_to_show if i not in all_labels
    ]
    random.shuffle(images_not_in_all_labels)
    random.shuffle(images_in_all_labels)
    images_to_show = images_not_in_all_labels + images_in_all_labels

image_index = 0
drawing = False
shifting = False
changing_shape = False
Esempio n. 3
0
import random

from autowebcompat import network
from autowebcompat import utils

labels = utils.read_labels()

utils.prepare_images()
all_images = utils.get_images()
image = utils.load_image(all_images[0])
input_shape = image.shape
BATCH_SIZE = 32
EPOCHS = 50


def load_pair(fname):
    f = utils.load_image(fname + '_firefox.png')
    print(f.shape)
    c = utils.load_image(fname + '_chrome.png')
    print(c.shape)
    return [f, c]


images_train = random.sample(all_images, int(len(all_images) * 0.9))
images_test = [i for i in all_images if i not in set(images_train)]


def couples_generator(images):
    for i in images:
        yield load_pair(i), labels[i]
Esempio n. 4
0
import random

from autowebcompat import network, utils

labels = utils.read_labels()

utils.prepare_images()
all_image_names = utils.get_images()
all_images = sum([[i + '_firefox.png', i + '_chrome.png']
                  for i in all_image_names], [])
image = utils.load_image(all_images[0])
input_shape = image.shape
BATCH_SIZE = 32
EPOCHS = 50


def load_pair(fname):
    f = utils.load_image(fname + '_firefox.png')
    print(f.shape)
    c = utils.load_image(fname + '_chrome.png')
    print(c.shape)
    return [f, c]


images_train = random.sample(all_image_names, int(len(all_image_names) * 0.9))
images_test = [i for i in all_image_names if i not in set(images_train)]


def couples_generator(images):
    for i in images:
        yield load_pair(i), labels[i]