Example #1
0
def main(_):
    images_dir = FLAGS.images_dir
    annotation_path = FLAGS.annotation_path
    record_path = FLAGS.output_path
    resize_size = FLAGS.resize_side_size
    _, annotation_dict = data_provider.provide(annotation_path, images_dir)
    generate_tfrecord(annotation_dict, record_path, resize_size)
Example #2
0
def main(_):
    images_fg_dir = FLAGS.images_fg_dir
    images_bg_dir = FLAGS.images_bg_dir
    annotation_path = FLAGS.annotation_path
    record_path = FLAGS.output_path
    resize_size = FLAGS.resize_side_size

    image_paths = data_provider.provide(annotation_path, images_fg_dir,
                                        images_bg_dir)

    generate_tfrecord(image_paths, record_path, resize_size)
Example #3
0
def main(_):
    images_dir = FLAGS.images_dir
    train_annotation_path = FLAGS.train_annotation_path
    train_record_path = FLAGS.train_output_path
    val_annotation_path = FLAGS.val_annotation_path
    val_record_path = FLAGS.val_output_path
    resize_size = FLAGS.resize_side_size

    # Write json
    data_provider.write_annotation_json(images_dir, train_annotation_path,
                                        val_annotation_path)

    time.sleep(5)

    _, train_annotation_dict = data_provider.provide(train_annotation_path,
                                                     None)
    _, val_annotation_dict = data_provider.provide(val_annotation_path, None)

    generate_tfrecord(train_annotation_dict, train_record_path, resize_size)
    generate_tfrecord(val_annotation_dict, val_record_path, resize_size)
FLAGS = flags.FLAGS


if __name__ == '__main__':
    # Specify which gpu to be used
    os.environ["CUDA_VISIBLE_DEVICES"] = '1'
    
    frozen_inference_graph_path = FLAGS.frozen_inference_graph_path
    images_dir = FLAGS.images_dir
    annotation_path = FLAGS.annotation_path
    output_path = FLAGS.output_path
    
    model = predictor.Predictor(frozen_inference_graph_path)
    
    _, annotation_dict = data_provider.provide(annotation_path, images_dir)

    val_results = []
    correct_count = 0
    predicted_count = 0
    num_samples = len(annotation_dict)
    for image_path, label in annotation_dict.items():
        predicted_count += 1
        if predicted_count % 100 == 0:
            print('Predict {}/{}.'.format(predicted_count, num_samples))
        
        image_name = image_path.split('/')[-1]
        image = cv2.imread(image_path)
        if image is None:
            print('image %s does not exist.' % image_name)
            continue