diff --git a/get_json_file_YOLO.py b/get_json_file_YOLO.py index aa85ee545f0ff1aa5e459064804fa0668934f893..a5d2c4792761138e47afeaffc981921c80ea338a 100644 --- a/get_json_file_YOLO.py +++ b/get_json_file_YOLO.py @@ -1,17 +1,20 @@ -# /!\ TO DO before : globox convert input_YOLO/labels/val/ output_../classifier/test_convert_labels/ --format yolo --save_fmt labelme --img_folder YOLO/images/val/ #path to images - +import argparse import os import json import labelme import base64 import pandas as pd -mode = 'train' #or val -img_dir = str('../annot/YOLO/images/'+mode+'/') +parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='TODO') +parser.add_argument('-p','--path_to_json', type=str, help = 'Path of the folder that contain the .json',required=True) +parser.add_argument('-i','--path_to_img', type=str, help = 'Path of the folder that contain the .jpg',required=True) +parser.add_argument('-d','--direction', type=str, help = 'Directory to wich modified .json files will be stored',required=True) +args = parser.parse_args() + -filename = 'test_convert_labels_train/' #path to .json -out_file = 'test_convert_labels_train_2/' #direction -img_path = '/nfs/NAS7/manip_stephane/annot/YOLO/images/train/' +filename = args.path_to_json +out_file = args.direction +img_path = args.path_to_img liste_file = os.listdir(filename) liste_file = pd.DataFrame(liste_file, columns =['fn']) @@ -24,7 +27,7 @@ liste_file = liste_file.reset_index() for i, row in liste_file.iterrows(): if len(row.fn) > 30: - data = labelme.LabelFile.load_image_file(img_dir+row.fn[:-4]+'jpg') + data = labelme.LabelFile.load_image_file(str(img_path+row.fn[:-4]+'jpg')) image_data = base64.b64encode(data).decode('utf-8') else: continue