Exemple #1
0
    def __getitem__(self, idx):

        assert self.train == True, 'getitem fuction only for training.'

        image = self.images[idx]

        # debug
        debug = 0
        if debug:
            print(image.dtype)
            print(np.array(image, dtype=np.float32).dtype)
            print(image.shape)
            tools.show_image(
                np.array(image, dtype=np.int
                         ))  # interfaces is not supported for multi-processing
            #exit(0)

        score = np.array((float(self.scores[idx])),
                         dtype=np.float32).reshape([1])  #IMPORTANT
        sample = {'image': image, 'score': score}

        if self.transform:
            sample = self.transform(sample)

        return sample
Exemple #2
0
def show_result(processed_img: robot_finder.ProcessedImg):
    show_image(
        img=draw_points(
            processed_img.img,
            processed_img.blue_pts + processed_img.red_pts
        ),
        win_name=PROC_WIN,
    )
Exemple #3
0
def post_screenshot(argv, response):
    result   = {}
    target   = argv[1] if len(argv) > 1 else None
    fileName = save_fileInfo(response, target)
    if not fileName:
        saveFile = target if target else os.path.basename(source)
        result['stderr'] = 'save %s error' % (saveFile)
    else:
        tools.show_image(fileName)
    return result
Exemple #4
0
    def __init__(self, train_dir, test_path, batch_size=128, resize=None):
        self.test_images, self.test_labels = Reader.analysis_singlefile(
            test_path)
        self.train_images, self.train_labels = Reader.analysis_dir(train_dir)

        self.train_images, self.train_labels = shuffle_arrs(
            self.train_images, self.train_labels)
        self.test_images, self.test_labels = shuffle_arrs(
            self.test_images, self.test_labels)
        print('loading training image shape is ', np.shape(self.train_images),
              ' training label shape is ', np.shape(self.train_labels))
        print('loading testing image shape is ', np.shape(self.test_images),
              ' testing label shape is ', np.shape(self.test_labels))
        show_image(self.test_images[0], [100, 100])
        self.train_generator = Generator(self.train_images,
                                         self.train_labels,
                                         batch_size,
                                         epoch_num=-1,
                                         resize=resize).next_batch()
        self.test_generator = Generator(self.test_images,
                                        self.test_labels,
                                        batch_size,
                                        epoch_num=1,
                                        resize=resize).next_batch()
Exemple #5
0
def display():
    processed_imgs.wait_next()
    show_result(processed_imgs.last)
    show_image(selfies.last, SNAP_WIN)