liux0614 / yolo_nano

Unofficial implementation of yolo nano
MIT License
254 stars 72 forks source link

更改COCO类别数后报错AssertionError #32

Closed PIPIWAN closed 4 years ago

PIPIWAN commented 4 years ago

我想用自己的数据集训练,于是修改了coco.names,opts.py两个文件中的类别数,修改后出现以下错误。

z@z:~/桌面/yolo_nano-master$ python3 main.py --dataset_path datasets/images --annotation_path datasets/annotation/ --dataset coco --lr 0.0001 --conf_thres 0.8 --nms_thres 0.5
------------------------ OPTIONS -----------------------------
          annotation_path: datasets/annotation/          
               batch_size: 16                            
              begin_epoch: 0                             
      checkpoint_interval: 10                            
          checkpoint_path: ./checkpoints                 
           classname_path: datasets/coco.names           
               conf_thres: 0.8                           
                  dataset: coco                          
             dataset_path: ./datasets/images             
                   device: cuda                          
                 final_lr: 0.1                           
   gradient_accumulations: 1                             
               hflip_prob: 0.5                           
               image_size: 416                           
                       lr: 0.0001                        
              manual_seed: 42                            
                    model: yolo_nano                     
                 momentum: 0.9                           
                nms_thres: 0.5                           
                  no_cuda: False                         
                 no_hflip: False                         
           no_multi_scale: False                         
            no_pad2square: False                         
                 no_train: False                         
                   no_val: False                         
                   no_vis: False                         
                no_vis_gt: False                         
             no_vis_preds: False                         
              num_classes: 2                             
               num_epochs: 20                            
              num_threads: 8                             
                optimizer: Adam                          
            print_options: True                          
             project_root: .                             
              resume_path:                               
                     test: False                         
             val_interval: 5                             
           vis_all_images: False                         
             weight_decay: 0.001                         
------------------------  END   ------------------------------

Traceback (most recent call last):
  File "main.py", line 33, in <module>
    visualizer = Visualizer(opt)
  File "/home/z/桌面/yolo_nano-master/utils/visualizer.py", line 22, in __init__
    assert len(self.class_names) == opt.num_classes
AssertionError