Skip to content

Commit dbec210

Browse files
committed
Optim code
1 parent 3781b15 commit dbec210

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

yolov5_2_coco.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,10 @@ def gen_dataset(self, img_paths, target_img_path, target_json, mode):
157157
with open(target_json, 'w', encoding='utf-8') as f:
158158
json.dump(json_data, f, ensure_ascii=False)
159159

160-
def read_annotation(self, txtfile, img_id,
161-
height, width):
160+
def read_annotation(self, txt_file, img_id, height, width):
162161
annotation = []
163-
allinfo = read_txt(txtfile)
164-
for label_info in allinfo:
162+
all_info = read_txt(txt_file)
163+
for label_info in all_info:
165164
# 遍历一张图中不同标注对象
166165
label_info = label_info.split(" ")
167166
if len(label_info) < 5:
@@ -208,7 +207,7 @@ def _get_annotation(vertex_info, height, width):
208207
if __name__ == "__main__":
209208
parser = argparse.ArgumentParser('Datasets converter from YOLOV5 to COCO')
210209
parser.add_argument('--dir_path', type=str,
211-
default='datasets/tmp/YOLOV5',
210+
default='datasets/YOLOV5',
212211
help='Dataset root path')
213212
args = parser.parse_args()
214213

0 commit comments

Comments
 (0)