Update labelme2yolo.py

This commit is contained in:
rooneysh 2021-08-19 15:47:40 +08:00 committed by GitHub
parent e66cf07f78
commit 68b4fc6407
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -141,12 +141,12 @@ class Labelme2YOLO(object):
yolo_center_x= round(float(obj_center_x / img_w), 6)
yolo_center_y = round(float(obj_center_y / img_h), 6)
yolo__w = round(float(obj_w / img_w), 6)
yolo_w = round(float(obj_w / img_w), 6)
yolo_h = round(float(obj_h / img_h), 6)
label_id = self._label_id_map[shape['label']]
return label_id, yolo_center_x, yolo_center_y, yolo__w, yolo_h
return label_id, yolo_center_x, yolo_center_y, yolo_w, yolo_h
def _get_other_shape_yolo_object(self, shape, img_h, img_w):
def __get_object_desc(obj_port_list):
@ -161,12 +161,12 @@ class Labelme2YOLO(object):
yolo_center_x= round(float((obj_x_min + obj_w / 2.0) / img_w), 6)
yolo_center_y = round(float((obj_y_min + obj_h / 2.0) / img_h), 6)
yolo__w = round(float(obj_w / img_w), 6)
yolo_w = round(float(obj_w / img_w), 6)
yolo_h = round(float(obj_h / img_h), 6)
label_id = self._label_id_map[shape['label']]
return label_id, yolo_center_x, yolo_center_y, yolo__w, yolo_h
return label_id, yolo_center_x, yolo_center_y, yolo_w, yolo_h
def _save_yolo_label(self, json_name, label_dir_path, target_dir, yolo_obj_list):
txt_path = os.path.join(label_dir_path,