Mmdetection trains its own data set to report errors ⚠️ :
# AssertionError: The `num_ classes` (3) in Shared2FCBBoxHead of MMDataParallel does not matches the length of `CLASSES` 80) in CocoDataset
This means that the category (3) you specified does not match the category (80) of cocodataset.
You may have modified the following files, but you still report an error:
mmdetection-master\mmdet\core\evaluation\class_ names.py
def coco_classes(): return [ # 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', # 'truck', 'boat', 'traffic_light', 'fire_hydrant', 'stop_sign', # 'parking_meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', # 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', # 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', # 'sports_ball', 'kite', 'baseball_bat', 'baseball_glove', 'skateboard', # 'surfboard', 'tennis_racket', 'bottle', 'wine_glass', 'cup', 'fork', # 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', # 'broccoli', 'carrot', 'hot_dog', 'pizza', 'donut', 'cake', 'chair', # 'couch', 'potted_plant', 'bed', 'dining_table', 'toilet', 'tv', # 'laptop', 'mouse', 'remote', 'keyboard', 'cell_phone', 'microwave', # 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', # 'scissors', 'teddy_bear', 'hair_drier', 'toothbrush' 'lm','ls' ]mmdetection-master\mmdet\datasets\coco.py
class CocoDataset(CustomDataset): # CLASSES = ( # 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', # 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', # 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', # 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', # 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', # 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', # 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', # 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', # 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', # 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', # 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', # 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', # 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', # 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush' # ) CLASSES = ('lm', 'ls')
No more nonsense, go straight to the method. There are several methods:
one ️⃣ If you have two classes, you can replace the first two classes in the above two places with your classes. The method is relatively simple, but there may be hidden dangers.
two ️⃣ The second method is to modify the class_ After names.py and voc.py, the code must be recompiled (run Python setup.py install) and then trained.
I tried, but I still made the same mistake. Maybe my method is wrong.
reference resources:
New mmdetection v2.3.0 training test notes – it610.com
Mmdetectionv2. X version trains its own VOC dataset_ Peach jam Momo blog – CSDN blog
three ️⃣ The third method, which I use, is actually the same as recompilation. The reason for recompilation is that you report an error because the source file in the environment has not been modified. There are only some Python files in the mmdetection master directory. When the program is actually running, it is still the source file in the environment, because we directly modify the source file in the environment.
Suppose my CONDA environment is called CONDA_ env_ Name, so go to the following directory and modify two files respectively:
\anaconda3\envs\conda_ env_ name\lib\python3.7\site-packages\mmdet\core\evaluation\class_ names.py
\anaconda3\envs\conda_ env_ name\lib\python3.7\site-packages\mmdet\datasets\coco.py
Modify the categories in these two files in the CONDA environment.
⭐ In the end, I did my best to solve this bug and write this blog to help you avoid detours.
Read More:
- Running Django (2.2) project in Python 3.7.9 reports an error
- After NPM run dev is running, the browser does not respond and reports an error in. / ~ / Babel loader / lib! / ~ / Vue loader / lib/ selector.js?type=script&in
- After JQ gets the tag element itself, it gets its own HTML text format (find only finds one level of child elements)
- Jedis reports errors using tool classes
- Arduino reports an error when writing a custom library file to solve the problem of not name of type, not declared in this scope
- The echots in Vue reports an error. After obtaining the DOM element, the chart can be displayed. The console still reports an error
- The version number of robot JS running by electron does not match
- Build your own resnet18 network and load torch vision’s own weight
- Hadoop reports an error. Cannot access scala.serializable and python MapReduce reports an error
- Lamdba in the studio part reports an error. Observe lamdba reports an error but can run
- The echo introduced in react reports an error: xaxis “0” not found
- In chome browser, console reports an error but does not display it
- QT + MySQL generates an EXE file and reports an error “driver not loaded”. Solution steps
- Using onnx to deploy models in mmdetection
- Running realsense ROS reports an error, USB cam overflow, hardware error
- An error is reported in the compiler require of laravel: installation failed, reversing/ composer.json to its original content.
- [OpenGL · error] visual studio 2019 reports an error. It is an external symbol gladloadglloader that cannot be parsed. This symbol is referenced in the function main
- Why do we not need to write implementation classes in mybatis to get the objects we need
- The file server reports an error of 413, and the file uploaded by nginx reports an error of 413 request entity too large
- HTML method IE8 reports an error, IE8 jQuery Ajax obtains static resources reports an error, typeerror denies access