yjh0410 1 năm trước cách đây
mục cha
commit
71a8eb117a

+ 8 - 8
README.md

@@ -31,14 +31,14 @@
 - COCO
 
 | Model       | Batch | Scale | FPS<sup>FP32<br>RTX 4060 |AP<sup>val<br>0.5:0.95 | AP<sup>val<br>0.5 | FLOPs<br><sup>(G) | Params<br><sup>(M) | Weight | Logs |
-|-------------|-------|-------|--------------------------|------------------------|-------------------|-------------------|--------------------|--------|------|
-| YOLOv1-R18  | 1xb16 |  640  |                          |         27.6           |       46.8        |   37.8            |   21.3             | [ckpt](https://github.com/yjh0410/YOLO-Tutorial-v2/releases/download/yolo_tutorial_ckpt/yolov1_r18_coco.pth) | [log](https://github.com/yjh0410/YOLO-Tutorial-v2/releases/download/yolo_tutorial_ckpt/YOLOv1-R18-COCO.txt) |
-| YOLOv2-R18  | 1xb16 |  640  |                          |         28.4           |       47.4        |   38.0            |   21.5             | [ckpt](https://github.com/yjh0410/YOLO-Tutorial-v2/releases/download/yolo_tutorial_ckpt/yolov2_r18_coco.pth) | [log](https://github.com/yjh0410/YOLO-Tutorial-v2/releases/download/yolo_tutorial_ckpt/YOLOv2-R18-COCO.txt) |
-| YOLOv3-S    | 1xb16 |  640  |                          |         31.3           |        49.2       |   25.2            |   7.3              | [ckpt](https://github.com/yjh0410/YOLO-Tutorial-v3/releases/download/yolo_tutorial_ckpt/yolov3_s_coco.pth) | [log](https://github.com/yjh0410/YOLO-Tutorial-v3/releases/download/yolo_tutorial_ckpt/YOLOv3-S-COCO.txt) |
-| YOLOv5-S    | 1xb16 |  640  |                          |       38.8             |     56.9          |   27.3            |   9.0              | [ckpt](https://github.com/yjh0410/YOLO-Tutorial-v5/releases/download/yolo_tutorial_ckpt/yolov5_s_coco.pth) | [log](https://github.com/yjh0410/YOLO-Tutorial-v5/releases/download/yolo_tutorial_ckpt/YOLOv5-S-COCO.txt) |
-| YOLOv5-AF-S | 1xb16 |  640  |                          |       39.6             |       58.7        |   26.9            |   8.9              | [ckpt](https://github.com/yjh0410/YOLO-Tutorial-v5/releases/download/yolo_tutorial_ckpt/yolov5_af_s_coco.pth) | [log](https://github.com/yjh0410/YOLO-Tutorial-v5/releases/download/yolo_tutorial_ckpt/YOLOv5-AF-S-COCO.txt) |
-| YOLOv8-S    | 1xb16 |  640  |                          |                        |                   |   28.4            |   11.3            |  |  |
-| GELAN-S     | 1xb16 |  640  |                          |                        |                   |   26.9            |   8.9             |  |  |
+|-------------|-------|-------|--------------------------|-----------------------|-------------------|-------------------|--------------------|--------|------|
+| YOLOv1-R18  | 1xb16 |  640  |           124            |         27.6          |       46.8        |   37.8            |   21.3             | [ckpt](https://github.com/yjh0410/YOLO-Tutorial-v2/releases/download/yolo_tutorial_ckpt/yolov1_r18_coco.pth) | [log](https://github.com/yjh0410/YOLO-Tutorial-v2/releases/download/yolo_tutorial_ckpt/YOLOv1-R18-COCO.txt) |
+| YOLOv2-R18  | 1xb16 |  640  |           128            |         28.4          |       47.4        |   38.0            |   21.5             | [ckpt](https://github.com/yjh0410/YOLO-Tutorial-v2/releases/download/yolo_tutorial_ckpt/yolov2_r18_coco.pth) | [log](https://github.com/yjh0410/YOLO-Tutorial-v2/releases/download/yolo_tutorial_ckpt/YOLOv2-R18-COCO.txt) |
+| YOLOv3-S    | 1xb16 |  640  |           107            |         31.3          |       49.2        |   25.2            |   7.3              | [ckpt](https://github.com/yjh0410/YOLO-Tutorial-v3/releases/download/yolo_tutorial_ckpt/yolov3_s_coco.pth) | [log](https://github.com/yjh0410/YOLO-Tutorial-v3/releases/download/yolo_tutorial_ckpt/YOLOv3-S-COCO.txt) |
+| YOLOv5-S    | 1xb16 |  640  |            80            |         38.8          |       56.9        |   27.3            |   9.0              | [ckpt](https://github.com/yjh0410/YOLO-Tutorial-v5/releases/download/yolo_tutorial_ckpt/yolov5_s_coco.pth) | [log](https://github.com/yjh0410/YOLO-Tutorial-v5/releases/download/yolo_tutorial_ckpt/YOLOv5-S-COCO.txt) |
+| YOLOv5-AF-S | 1xb16 |  640  |            83            |         39.6          |       58.7        |   26.9            |   8.9              | [ckpt](https://github.com/yjh0410/YOLO-Tutorial-v5/releases/download/yolo_tutorial_ckpt/yolov5_af_s_coco.pth) | [log](https://github.com/yjh0410/YOLO-Tutorial-v5/releases/download/yolo_tutorial_ckpt/YOLOv5-AF-S-COCO.txt) |
+| YOLOv8-S    | 1xb16 |  640  |                          |                       |                   |   28.4            |   11.3            |  |  |
+| GELAN-S     | 1xb16 |  640  |                          |                       |                   |   26.9            |   8.9             |  |  |
 
 ### RT-DETR系列
 下表汇报了本项目的RT-DETR系列在COCO数据集上的性能指标,

+ 52 - 33
yolo/README.md

@@ -86,10 +86,10 @@ bash train.sh yolov1_r18 coco path/to/coco 128 4 1699 path/to/yolov1_r18_coco.pt
 ## 训练自定义数据
 除了本教程所介绍的VOC和COCO两大主流数据集,本项目也支持训练读者自定义的数据。不过,需要按照本项目的要求来从头开始准备数据,包括标注和格式转换(COCO格式)。如果读者手中的数据已经都准备好了,倘若不符合本项目的格式,还请另寻他法,切不可强行使用本项目,否则出了问题,我们也无法提供解决策略,只能后果自负。为了能够顺利使用本项目,请读者遵循以下的步骤来开始准备数据
 
-- 第1步,准备图片,诸如jpg格式、png格式等都可以,构建为自定义数据集,不妨起名为`CustomedDataset`,然后使用开源的`labelimg`制作标签文件。有关于`labelimg`的使用方法,请自行了解。完成标注后,应得到如下所示的文件目录格式:
+- 第1步,准备图片,诸如jpg格式、png格式等都可以,构建为自定义数据集,不妨起名为`CustomDataset`,然后使用开源的`labelimg`制作标签文件。有关于`labelimg`的使用方法,请自行了解。完成标注后,应得到如下所示的文件目录格式:
 
 ```
-CustomedDataset
+CustomDataset
 |_ train
 |  |_ images     
 |     |_ 0.jpg
@@ -112,11 +112,11 @@ CustomedDataset
 ```
 
 - 第2步: 修改与数据有关的配置参数
-读者需要修改定义在`dataset/customed.py`文件中的`customed_class_indexs` 和 `customed_class_labels`两个参数,前者是类别索引,后者是类别名称。例如,我们使用了如下的定义以供读者参考:
+读者需要修改定义在`dataset/custom.py`文件中的`custom_class_indexs` 和 `custom_class_labels`两个参数,前者是类别索引,后者是类别名称。例如,我们使用了如下的定义以供读者参考:
 ```Shell
-# dataset/customed.py
-customed_class_indexs = [0, 1, 2, 3, 4, 5, 6, 7, 8]
-customed_class_labels = ('bird', 'butterfly', 'cat', 'cow', 'dog', 'lion', 'person', 'pig', 'tiger', )
+# dataset/custom.py
+custom_class_indexs = [0, 1, 2, 3, 4, 5, 6, 7, 8]
+custom_class_labels = ('bird', 'butterfly', 'cat', 'cow', 'dog', 'lion', 'person', 'pig', 'tiger', )
 ```
 
 - 第3步: 将数据转换为COCO的json格式
@@ -126,14 +126,14 @@ customed_class_labels = ('bird', 'butterfly', 'cat', 'cow', 'dog', 'lion', 'pers
 cd <YOLO-TUTORIAL-V2/yolo/>
 cd tools
 # convert train split
-python convert_ours_to_coco.py --root path/to/customed_dataset/ --split train
+python convert_ours_to_coco.py --root path/to/custom_dataset/ --split train
 # convert val split
-python convert_ours_to_coco.py --root path/to/customed_dataset/ --split val
+python convert_ours_to_coco.py --root path/to/custom_dataset/ --split val
 ```
 
 随后,我们便可得到一个名为`train.json` 的文件和一个名为 `val.json` 文件,如下所示.
 ```
-CustomedDataset
+CustomDataset
 |_ train
 |  |_ images     
 |     |_ 0.jpg
@@ -164,9 +164,9 @@ CustomedDataset
 cd <YOLO-TUTORIAL-V2/yolo/>
 cd dataset
 # convert train split
-python customed.py --root path/to/customed_dataset/ --split train
+python custom.py --root path/to/custom_dataset/ --split train
 # convert val split
-python customed.py --root path/to/customed_dataset/ --split val
+python custom.py --root path/to/custom_dataset/ --split val
 ```
 
 - 第5步:使用自定义数据训练模型
@@ -174,8 +174,27 @@ python customed.py --root path/to/customed_dataset/ --split val
 
 ```Shell
 cd <YOLO-TUTORIAL-V2/yolo/>
-bash train.sh yolov1_r18 customed path/to/customed_dataset/ 128 4 1699 None
-```
+# For single GPU
+python train.py --cuda \
+                --dataset custom \
+                --root path/to/custom_dataset/ \
+                --model yolov1_r18 \
+                --batch_size 16 \
+                --fp16
+
+# For multi GPUs (taking 8 gpus with 1623 port as the example)
+python -m torch.distributed.run --nproc_per_node 8 --master_port 1623 train.py --cuda \
+                --distributed \
+                --dataset custom \
+                --root path/to/custom_dataset/ \
+                --model yolov1_r18 \
+                --batch_size 16 \
+                --sybn \
+                --fp16
+```
+
+You could add `--pretrained path/to/yolov1_r18_coco.pth` into the above command to load the coco pretrained weight as
+the initial weight, which might help with faster training convergence and improve performance on custom tasks. However, if there is a significant difference between your custom data and COCO data, this trick may not be effective. For example, if your custom data is medical images, in my opinion, the large number of natural images contained in the COCO dataset may not have any promoting effect on your task.
 
 - 第6步:使用自定义数据测试模型
 
@@ -183,7 +202,7 @@ bash train.sh yolov1_r18 customed path/to/customed_dataset/ 128 4 1699 None
 
 ```Shell
 cd <YOLO-TUTORIAL-V2/yolo/>
-python test.py -d customed --root path/to/customed_dataset/ -d customed -m yolov1_r18 --weight path/to/checkpoint --show
+python test.py -d custom --root path/to/custom_dataset/ -d custom -m yolov1_r18 --weight path/to/checkpoint --show
 ```
 
 - 第7步:使用自定义数据验证模型
@@ -192,7 +211,7 @@ python test.py -d customed --root path/to/customed_dataset/ -d customed -m yolov
 
 ```Shell
 cd <YOLO-TUTORIAL-V2/yolo/>
-python eval.py -d customed --root path/to/customed_dataset/ -d customed -m yolov1_r18 --weight path/to/checkpoint
+python eval.py -d custom --root path/to/custom_dataset/ -d custom -m yolov1_r18 --weight path/to/checkpoint
 ```
 
 ## Demo
@@ -336,7 +355,7 @@ Besides the popular datasets, we can also train the model on ourself dataset. To
 - Step-1: Prepare the images (JPG/JPEG/PNG ...) and use `labelimg` to make XML format annotation files.
 
 ```
-CustomedDataset
+CustomDataset
 |_ train
 |  |_ images     
 |     |_ 0.jpg
@@ -359,28 +378,28 @@ CustomedDataset
 ```
 
 - Step-2: Make the configuration for our dataset.
-You need to edit the `customed_class_indexs` and `customed_class_labels` defined in `dataset/customed.py` to adapt to your customed dataset.
+You need to edit the `custom_class_indexs` and `custom_class_labels` defined in `dataset/custom.py` to adapt to your custom dataset.
 
 For example:
 ```Shell
-# dataset/customed.py
-customed_class_indexs = [0, 1, 2, 3, 4, 5, 6, 7, 8]
-customed_class_labels = ('bird', 'butterfly', 'cat', 'cow', 'dog', 'lion', 'person', 'pig', 'tiger', )
+# dataset/custom.py
+custom_class_indexs = [0, 1, 2, 3, 4, 5, 6, 7, 8]
+custom_class_labels = ('bird', 'butterfly', 'cat', 'cow', 'dog', 'lion', 'person', 'pig', 'tiger', )
 ```
 
-- Step-3: Convert customed to COCO format.
+- Step-3: Convert custom to COCO format.
 
 ```Shell
 cd <YOLO-TUTORIAL-V2/yolo/>
 cd tools
 # convert train split
-python convert_ours_to_coco.py --root path/to/customed_dataset/ --split train
+python convert_ours_to_coco.py --root path/to/custom_dataset/ --split train
 # convert val split
-python convert_ours_to_coco.py --root path/to/customed_dataset/ --split val
+python convert_ours_to_coco.py --root path/to/custom_dataset/ --split val
 ```
 Then, we can get a `train.json` file and a `val.json` file, as shown below.
 ```
-CustomedDataset
+CustomDataset
 |_ train
 |  |_ images     
 |     |_ 0.jpg
@@ -410,43 +429,43 @@ CustomedDataset
 cd <YOLO-TUTORIAL-V2/yolo/>
 cd dataset
 # convert train split
-python customed.py --root path/to/customed_dataset/ --split train
+python custom.py --root path/to/custom_dataset/ --split train
 # convert val split
-python customed.py --root path/to/customed_dataset/ --split val
+python custom.py --root path/to/custom_dataset/ --split val
 ```
 
-- Step-5 **Train** on the customed dataset
+- Step-5 **Train** on the custom dataset
 
 For example:
 
 ```Shell
 # With coco pretrained weight
 cd <YOLO-TUTORIAL-V2/yolo/>
-python train.py --root path/to/customed_dataset/ -d customed -m yolov1_r18 -bs 16 -p path/to/yolov1_r18_coco.pth
+python train.py --root path/to/custom_dataset/ -d custom -m yolov1_r18 -bs 16 -p path/to/yolov1_r18_coco.pth
 ```
 
 ```Shell
 # Without coco pretrained weight
 cd <YOLO-TUTORIAL-V2/yolo/>
-python train.py --root path/to/customed_dataset/ -d customed -m yolov1_r18 -bs 16
+python train.py --root path/to/custom_dataset/ -d custom -m yolov1_r18 -bs 16
 ```
 
-- Step-6 **Test** on the customed dataset
+- Step-6 **Test** on the custom dataset
 
 For example:
 
 ```Shell
 cd <YOLO-TUTORIAL-V2/yolo/>
-python test.py --root path/to/customed_dataset/ -d customed -m yolov1_r18 --weight path/to/checkpoint --show
+python test.py --root path/to/custom_dataset/ -d custom -m yolov1_r18 --weight path/to/checkpoint --show
 ```
 
-- Step-7 **Eval** on the customed dataset
+- Step-7 **Eval** on the custom dataset
 
 For example:
 
 ```Shell
 cd <YOLO-TUTORIAL-V2/yolo/>
-python eval.py --root path/to/customed_dataset/ -d customed -m yolov1_r18 --weight path/to/checkpoint
+python eval.py --root path/to/custom_dataset/ -d custom -m yolov1_r18 --weight path/to/checkpoint
 ```
 
 ## Demo

+ 2 - 4
yolo/benchmark.py

@@ -27,14 +27,12 @@ def parse_args():
                         help='use cuda.')
 
     # Model setting
-    parser.add_argument('-m', '--model', default='yolo_n', type=str,
+    parser.add_argument('-m', '--model', default='yolov1_r18', type=str,
                         help='build yolo')
     parser.add_argument('--weight', default=None,
                         type=str, help='Trained state_dict file path to open')
     parser.add_argument('--fuse_conv_bn', action='store_true', default=False,
                         help='fuse Conv & BN')
-    parser.add_argument('--fuse_rep_conv', action='store_true', default=False,
-                        help='fuse Conv & BN')
 
     # Data setting
     parser.add_argument('--root', default='D:/python_work/dataset/COCO/',
@@ -108,7 +106,7 @@ if __name__ == '__main__':
     model = build_model(args, cfg, is_val=False)
 
     # Load trained weight
-    model = load_weight(model, args.weight, args.fuse_conv_bn, args.fuse_rep_conv)
+    model = load_weight(model, args.weight, args.fuse_conv_bn)
     model.to(device).eval()
         
     # Run

+ 4 - 4
yolo/dataset/build.py

@@ -4,7 +4,7 @@ try:
     # dataset class
     from .voc        import VOCDataset
     from .coco       import COCODataset
-    from .customed   import CustomedDataset
+    from .custom     import CustomDataset
     # transform class
     from .data_augment.yolo_augment import YOLOAugmentation, YOLOBaseTransform
     from .data_augment.ssd_augment  import SSDAugmentation, SSDBaseTransform
@@ -13,7 +13,7 @@ except:
     # dataset class
     from voc        import VOCDataset
     from coco       import COCODataset
-    from customed   import CustomedDataset
+    from yolo.dataset.custom   import CustomDataset
     # transform class
     from data_augment.yolo_augment import YOLOAugmentation, YOLOBaseTransform
     from data_augment.ssd_augment  import SSDAugmentation, SSDBaseTransform
@@ -41,9 +41,9 @@ def build_dataset(args, cfg, transform=None, is_train=False):
                               is_train  = is_train,
                               )
     ## Custom dataset
-    elif args.dataset == 'customed':
+    elif args.dataset == 'custom':
         image_set = 'train' if is_train else 'val'
-        dataset = CustomedDataset(cfg       = cfg,
+        dataset = CustomDataset(cfg       = cfg,
                                   data_dir  = args.root,
                                   image_set = image_set,
                                   transform = transform,

+ 8 - 8
yolo/dataset/customed.py → yolo/dataset/custom.py

@@ -12,11 +12,11 @@ except:
     from  data_augment.strong_augment import MosaicAugment, MixupAugment
 
 
-customed_class_indexs = [0, 1, 2, 3, 4, 5, 6, 7, 8]
-customed_class_labels = ('bird', 'butterfly', 'cat', 'cow', 'dog', 'lion', 'person', 'pig', 'tiger', )
+custom_class_indexs = [0, 1, 2, 3, 4, 5, 6, 7, 8]
+custom_class_labels = ('bird', 'butterfly', 'cat', 'cow', 'dog', 'lion', 'person', 'pig', 'tiger', )
 
 
-class CustomedDataset(Dataset):
+class CustomDataset(Dataset):
     def __init__(self, 
                  cfg,
                  data_dir     :str = None, 
@@ -27,7 +27,7 @@ class CustomedDataset(Dataset):
         # ----------- Basic parameters -----------
         self.image_set = image_set
         self.is_train  = is_train
-        self.num_classes = len(customed_class_labels)
+        self.num_classes = len(custom_class_labels)
         # ----------- Path parameters -----------
         self.data_dir = data_dir
         self.json_file = '{}.json'.format(image_set)
@@ -36,8 +36,8 @@ class CustomedDataset(Dataset):
         self.ids = self.coco.getImgIds()
         self.class_ids = sorted(self.coco.getCatIds())
         self.dataset_size = len(self.ids)
-        self.class_labels = customed_class_labels
-        self.class_indexs = customed_class_indexs
+        self.class_labels = custom_class_labels
+        self.class_indexs = custom_class_indexs
         # ----------- Transform parameters -----------
         self.transform = transform
         if is_train:
@@ -255,7 +255,7 @@ if __name__ == "__main__":
         cfg = SSDBaseConfig()
 
     transform = build_transform(cfg, args.is_train)
-    dataset = CustomedDataset(cfg, args.root, 'val', transform, args.is_train)
+    dataset = CustomDataset(cfg, args.root, 'val', transform, args.is_train)
     
     np.random.seed(0)
     class_colors = [(np.random.randint(255),
@@ -305,7 +305,7 @@ if __name__ == "__main__":
             cls_id = int(label)
             color = class_colors[cls_id]
             # class name
-            label = customed_class_labels[cls_id]
+            label = custom_class_labels[cls_id]
             image = cv2.rectangle(image, (int(x1), int(y1)), (int(x2), int(y2)), color, 2)
             # put the test on the bbox
             cv2.putText(image, label, (int(x1), int(y1 - 5)), 0, 0.5, color, 1, lineType=cv2.LINE_AA)

+ 5 - 5
yolo/demo.py

@@ -20,7 +20,7 @@ from config import build_config\
 
 from dataset.voc  import voc_class_labels
 from dataset.coco import coco_class_labels
-from dataset.customed import customed_class_labels
+from yolo.dataset.custom import custom_class_labels
 
 
 def parse_args():
@@ -53,7 +53,7 @@ def parse_args():
 
     # Data setting
     parser.add_argument('-d', '--dataset', default='coco',
-                        help='coco, voc, customed.')
+                        help='coco, voc, custom.')
 
     return parser.parse_args()
                     
@@ -259,9 +259,9 @@ def run():
     elif args.dataset == "coco":
         cfg.num_classes = 80
         cfg.class_labels = coco_class_labels
-    elif args.dataset == "customed":
-        cfg.num_classes = len(customed_class_labels)
-        cfg.class_labels = customed_class_labels
+    elif args.dataset == "custom":
+        cfg.num_classes = len(custom_class_labels)
+        cfg.class_labels = custom_class_labels
     else:
         raise NotImplementedError("Unknown dataset: {}".format(args.dataset))
     

+ 8 - 11
yolo/eval.py

@@ -1,9 +1,10 @@
 import argparse
 import torch
 
-from evaluator.voc_evaluator import VOCAPIEvaluator
-from evaluator.coco_evaluator import COCOAPIEvaluator
-from evaluator.customed_evaluator import CustomedEvaluator
+# evaluators
+from evaluator.voc_evaluator    import VOCAPIEvaluator
+from evaluator.coco_evaluator   import COCOAPIEvaluator
+from evaluator.custom_evaluator import CustomEvaluator
 
 # load transform
 from dataset.build import build_dataset, build_transform
@@ -28,14 +29,10 @@ def parse_args():
                         help='build yolo')
     parser.add_argument('--weight', default=None,
                         type=str, help='Trained state_dict file path to open')
-    parser.add_argument('-p', '--pretrained', default=None, type=str,
-                        help='load pretrained weight')
     parser.add_argument('-r', '--resume', default=None, type=str,
                         help='keep training')
     parser.add_argument('--fuse_conv_bn', action='store_true', default=False,
                         help='fuse Conv & BN')
-    parser.add_argument('--fuse_rep_conv', action='store_true', default=False,
-                        help='fuse Conv & BN')
 
     # Data setting
     parser.add_argument('--root', default='/Users/liuhaoran/Desktop/python_work/object-detection/dataset/',
@@ -72,8 +69,8 @@ def coco_test(cfg, model, data_dir, device, transform):
     # COCO evaluation
     evaluator.evaluate(model)
 
-def customed_test(cfg, model, data_dir, device, transform):
-    evaluator = CustomedEvaluator(
+def custom_test(cfg, model, data_dir, device, transform):
+    evaluator = CustomEvaluator(
         cfg=cfg,
         data_dir=data_dir,
         device=device,
@@ -115,5 +112,5 @@ if __name__ == '__main__':
             voc_test(cfg, model, args.root, device, transform)
         elif args.dataset == 'coco':
             coco_test(cfg, model, args.root, device, transform)
-        elif args.dataset == 'customed':
-            customed_test(cfg, model, args.root, device, transform)
+        elif args.dataset == 'custom':
+            custom_test(cfg, model, args.root, device, transform)

+ 2 - 2
yolo/evaluator/build.py

@@ -2,7 +2,7 @@ import os
 
 from evaluator.coco_evaluator import COCOAPIEvaluator
 from evaluator.voc_evaluator import VOCAPIEvaluator
-from evaluator.customed_evaluator import CustomedEvaluator
+from evaluator.custom_evaluator import CustomEvaluator
 
 
 
@@ -24,7 +24,7 @@ def build_evluator(args, cfg, transform, device):
                                      )
     ## Custom dataset Evaluator
     elif args.dataset == 'ourdataset':
-        evaluator = CustomedEvaluator(cfg       = cfg,
+        evaluator = CustomEvaluator(cfg       = cfg,
                                       data_dir  = args.root,
                                       device    = device,
                                       transform = transform

+ 3 - 3
yolo/evaluator/customed_evaluator.py → yolo/evaluator/custom_evaluator.py

@@ -1,7 +1,7 @@
 import json
 import tempfile
 import torch
-from dataset.customed import CustomedDataset
+from yolo.dataset.custom import CustomDataset
 from utils.box_ops import rescale_bboxes
 
 try:
@@ -10,7 +10,7 @@ except:
     print("It seems that the COCOAPI is not installed.")
 
 
-class CustomedEvaluator():
+class CustomEvaluator():
     def __init__(self, cfg, data_dir, device, image_set='val', transform=None):
         # ----------------- Basic parameters -----------------
         self.image_set = image_set
@@ -21,7 +21,7 @@ class CustomedEvaluator():
         self.ap50_95 = 0.
         self.ap50 = 0.
         # ----------------- Dataset -----------------
-        self.dataset = CustomedDataset(cfg, data_dir=data_dir, image_set=image_set, transform=None, is_train=False)
+        self.dataset = CustomDataset(cfg, data_dir=data_dir, image_set=image_set, transform=None, is_train=False)
 
     @torch.no_grad()
     def evaluate(self, model):

+ 1 - 3
yolo/test.py

@@ -41,8 +41,6 @@ def parse_args():
                         type=str, help='Trained state_dict file path to open')
     parser.add_argument('--fuse_conv_bn', action='store_true', default=False,
                         help='fuse Conv & BN')
-    parser.add_argument('--fuse_rep_conv', action='store_true', default=False,
-                        help='fuse Conv & BN')
 
     # Data setting
     parser.add_argument('--root', default='D:/python_work/dataset/COCO/',
@@ -134,7 +132,7 @@ if __name__ == '__main__':
     model = build_model(args, cfg, is_val=False)
 
     # load trained weight
-    model = load_weight(model, args.weight, args.fuse_conv_bn, args.fuse_rep_conv)
+    model = load_weight(model, args.weight, args.fuse_conv_bn)
     model.to(device).eval()
 
     # compute FLOPs and Params

+ 4 - 4
yolo/tools/convert_ours_to_coco.py

@@ -5,9 +5,9 @@ import glob
 
 import sys
 sys.path.append("..")
-from dataset.customed import customed_class_labels
-num_classes = len(customed_class_labels)
-categories  = customed_class_labels
+from yolo.dataset.custom import custom_class_labels
+num_classes = len(custom_class_labels)
+categories  = custom_class_labels
 START_BOUNDING_BOX_ID = 1
 PRE_DEFINE_CATEGORIES = {categories[i]: i + 1 for i in range(num_classes)} 
 
@@ -129,7 +129,7 @@ if __name__ == "__main__":
     parser = argparse.ArgumentParser(
         description="Convert VOC-style annotation labele by LabelImg to COCO format."
     )
-    parser.add_argument("--root", default="path/to/customed_dataset", type=str,
+    parser.add_argument("--root", default="path/to/custom_dataset", type=str,
                         help="Directory path to dataset.", )
     parser.add_argument("--split", default='train', 
                         help="split of dataset.", type=str)

+ 1 - 1
yolo/utils/misc.py

@@ -343,7 +343,7 @@ def compute_flops(model, img_size, device):
     print('Params : {:.2f} M'.format(params / 1e6))
 
 ## load trained weight
-def load_weight(model, path_to_ckpt, fuse_cbn=False, fuse_rep_conv=False):
+def load_weight(model, path_to_ckpt, fuse_cbn=False):
     # Check ckpt file
     if path_to_ckpt is None:
         print('no weight file ...')