1 file + 11 − 8 Inline Compare changes Side-by-side Inline Show whitespace changes Files 1 get_json_file_YOLO.py +11 −8 Original line number Diff line number Diff line # /!\ 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']) Loading @@ -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 Loading
get_json_file_YOLO.py +11 −8 Original line number Diff line number Diff line # /!\ 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']) Loading @@ -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 Loading