Skip to content
Snippets Groups Projects
Commit 191ad7b7 authored by Stephane Chavin's avatar Stephane Chavin
Browse files

correction

parent 304bda96
No related branches found
No related tags found
No related merge requests found
# /!\ 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 os
import json import json
import labelme import labelme
import base64 import base64
import pandas as pd import pandas as pd
mode = 'train' #or val parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='TODO')
img_dir = str('../annot/YOLO/images/'+mode+'/') 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 filename = args.path_to_json
out_file = 'test_convert_labels_train_2/' #direction out_file = args.direction
img_path = '/nfs/NAS7/manip_stephane/annot/YOLO/images/train/' img_path = args.path_to_img
liste_file = os.listdir(filename) liste_file = os.listdir(filename)
liste_file = pd.DataFrame(liste_file, columns =['fn']) liste_file = pd.DataFrame(liste_file, columns =['fn'])
...@@ -24,7 +27,7 @@ liste_file = liste_file.reset_index() ...@@ -24,7 +27,7 @@ liste_file = liste_file.reset_index()
for i, row in liste_file.iterrows(): for i, row in liste_file.iterrows():
if len(row.fn) > 30: 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') image_data = base64.b64encode(data).decode('utf-8')
else: else:
continue continue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment