From 18481780cfa065f0758fe1f75b687a4d853fe7f2 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Sun, 1 May 2022 12:59:03 +0800 Subject: [PATCH] Rename to AnnotationsConverter --- tools/{convert_yolo_to_coco.py => convert_txt_to_json.py} | 6 +++--- yolort/utils/__init__.py | 6 ++++-- yolort/utils/{yolo2coco.py => annotations_converter.py} | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) rename tools/{convert_yolo_to_coco.py => convert_txt_to_json.py} (73%) rename yolort/utils/{yolo2coco.py => annotations_converter.py} (98%) diff --git a/tools/convert_yolo_to_coco.py b/tools/convert_txt_to_json.py similarity index 73% rename from tools/convert_yolo_to_coco.py rename to tools/convert_txt_to_json.py index fc7f5437..8902e137 100644 --- a/tools/convert_yolo_to_coco.py +++ b/tools/convert_txt_to_json.py @@ -2,11 +2,11 @@ import argparse -from yolort.utils.yolo2coco import YOLO2COCO +from yolort.utils import AnnotationsConverter def get_parser(): - parser = argparse.ArgumentParser("Datasets converter from yolo to coco", add_help=True) + parser = argparse.ArgumentParser("Annotations converter from yolo to coco", add_help=True) parser.add_argument("--data_source", default="./coco128", help="Dataset root path") parser.add_argument("--class_names", default="./coco.name", help="Path of the label names") @@ -21,7 +21,7 @@ def cli_main(): args = parser.parse_args() print(f"Command Line Args: {args}") - converter = YOLO2COCO(args.data_source, args.class_names, split=args.split, year=args.year) + converter = AnnotationsConverter(args.data_source, args.class_names, split=args.split, year=args.year) converter.generate() diff --git a/yolort/utils/__init__.py b/yolort/utils/__init__.py index 39e018da..e2ed5da3 100644 --- a/yolort/utils/__init__.py +++ b/yolort/utils/__init__.py @@ -9,6 +9,7 @@ except ImportError: from torch.utils.model_zoo import load_url as load_state_dict_from_url +from .annotations_converter import AnnotationsConverter from .dependency import check_version from .hooks import FeatureExtractor from .image_utils import cv2_imshow, get_image_from_url, read_image_to_tensor @@ -16,6 +17,9 @@ __all__ = [ + "AnnotationsConverter", + "FeatureExtractor", + "Visualizer", "check_version", "contains_any_tensor", "cv2_imshow", @@ -23,8 +27,6 @@ "get_callable_dict", "load_state_dict_from_url", "read_image_to_tensor", - "FeatureExtractor", - "Visualizer", ] diff --git a/yolort/utils/yolo2coco.py b/yolort/utils/annotations_converter.py similarity index 98% rename from yolort/utils/yolo2coco.py rename to yolort/utils/annotations_converter.py index ecb7b0b3..991e163f 100644 --- a/yolort/utils/yolo2coco.py +++ b/yolort/utils/annotations_converter.py @@ -8,9 +8,9 @@ from PIL import Image -class YOLO2COCO: +class AnnotationsConverter: """ - Convert YOLO labels to MSCOCO JSON labels. + Make a MSCOCO JSON format annotations from YOLO format. Args: root (string): Root directory of the Sintel Dataset