コード例 #1
0
ファイル: pascal_voc.py プロジェクト: rodsom22/lwf_polyps
 def load_image(self, image_index):
     """ Load an image at the image_index.
     """
     path = os.path.join(
         self.data_dir, 'JPEGImages',
         self.image_names[image_index] + self.image_extension)
     return read_image_bgr(path)
コード例 #2
0
ファイル: coco.py プロジェクト: rodsom22/lwf_polyps
 def load_image(self, image_index):
     """ Load an image at the image_index.
     """
     image_info = self.coco.loadImgs(self.image_ids[image_index])[0]
     path       = os.path.join(self.data_dir, 'images', self.set_name, image_info['file_name'])
     return read_image_bgr(path)
コード例 #3
0
                    exist_ok=True)
                shutil.copy(
                    os.path.join(anns_path, i[:-4] + '.xml'),
                    f'/home/palm/PycharmProjects/seven2/xmls/readjusted/{set_name}/'
                    + i[:-4] + '.xml')
                continue
            if '<name>obj</name>' not in x:
                os.makedirs(
                    f'/home/palm/PycharmProjects/seven2/xmls/readjusted/{set_name}/',
                    exist_ok=True)
                shutil.copy(
                    os.path.join(anns_path, i[:-4] + '.xml'),
                    f'/home/palm/PycharmProjects/seven2/xmls/readjusted/{set_name}/'
                    + i[:-4] + '.xml')
                continue
            image = read_image_bgr(os.path.join(folder, i))
            start_time = time.time()
            # copy to draw ong
            draw = image.copy()
            draw = cv2.cvtColor(draw, cv2.COLOR_BGR2RGB)

            # preprocess image for network
            image = preprocess_image(image)
            image, scale = resize_image(image, min_side=720, max_side=1280)

            # process image
            boxes, scores, labels = prediction_model.predict_on_batch(
                np.expand_dims(image, axis=0))

            # correct for image scale
            boxes /= scale
コード例 #4
0
 def load_image(self, image_index):
     """ Load an image at the image_index.
     """
     return read_image_bgr(self.images[image_index])
コード例 #5
0
ファイル: inference2.py プロジェクト: DableUTeeF/mine
import time
from boxutils import add_bbox


if __name__ == '__main__':
    labels_to_names = [x.split(',')[0] for x in open('/home/palm/PycharmProjects/seven2/anns/c.csv').read().split('\n')[:-1]]
    model_path = '/home/palm/PycharmProjects/seven2/snapshots/infer_model_5.h5'
    model = models.load_model(model_path)

    dst = '/home/palm/PycharmProjects/seven/predict/1'
    path = '/home/palm/PycharmProjects/seven/data1/1'
    pad = 0
    for image_name in os.listdir(path):
        p = os.path.join(path, image_name)

        image = read_image_bgr(p)

        # copy to draw on
        draw = image.copy()

        # preprocess image for network
        image = preprocess_image(image)
        image, scale = resize_image(image, min_side=720, max_side=1280)

        # process image
        start = time.time()
        boxes, scores, labels = model.predict_on_batch(np.expand_dims(image, axis=0))
        print("processing time: ", time.time() - start)

        # correct for image scale
        boxes /= scale
コード例 #6
0
sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))
keras.backend.set_session(sess)

if __name__ == '__main__':
    prediction_model = models.load_model('snapshots/infer_model_test.h5')
    root = '/media/palm/BiggerData/mine/new/i/'
    # srcs = [
    #     'PU_23550891_00_20200905_214516_BKQ02-003',
    #     'PU_23550891_00_20200905_230000_BKQ02',
    # ]
    srcs = os.listdir(root)
    for p in srcs:
        src = os.path.join(root, p)
        os.makedirs(f'/media/palm/BiggerData/mine/out/i/{p}', exist_ok=True)
        for f in os.listdir(src):
            frame = read_image_bgr(os.path.join(src, f))

            im = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
            frame = np.dstack((im, im, im))
            frame, scale = resize_image(frame, min_side=720, max_side=1280)
            image = preprocess_image(frame)
            boxes, scores, labels = prediction_model.predict_on_batch(
                np.expand_dims(image, axis=0))
            for box, score, label in zip(boxes[0], scores[0], labels[0]):
                # scores are sorted so we can break
                if score < 0.5:
                    break
                b = box.astype(int)

                frame = add_bbox(frame, b, label, [
                    'crane',
コード例 #7
0
 def load_image(self, image_index):
     return read_image_bgr(self.image_path(image_index))
コード例 #8
0
ファイル: siamese_eval.py プロジェクト: DableUTeeF/seven2
    names_to_labels = {}
    for x in open('/home/palm/PycharmProjects/seven2/anns/classes.csv').read(
    ).split('\n')[:-1]:
        names_to_labels[x.split(',')[0]] = int(x.split(',')[1])
    query_path = '/home/palm/PycharmProjects/seven/images/cropped7/train'
    cache_path = '/home/palm/PycharmProjects/seven/caches'
    cache_dict = {}
    all_detections = []
    all_annotations = []
    known_classes = os.listdir(query_path)

    for instance in valid_ints:
        all_annotation = all_annotation_from_instance(instance,
                                                      names_to_labels)

        image = read_image_bgr(instance["filename"])

        t = time.time()

        # copy to draw ong
        draw = image.copy()

        # preprocess image for network
        image = preprocess_image(image)
        image, scale = resize_image(image, min_side=720, max_side=1280)

        # process image
        boxes, scores, labels = prediction_model.predict_on_batch(
            np.expand_dims(image, axis=0))

        # correct for image scale