After training the model, an error occurs when running the demo.py inference file in YOLOX, and the running code with the error is as follows:
Run Code
python tools/demo.py image -f exps/example/yolox_voc/yolox_voc_s.py -c YOLO_outputs/yolox_voc_s_1/best_ckpt.pth --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result --device [cpu/gpu]
Note:
-f exps/example/yolox_voc/yolox_voc_s.py
This command must match, not the yolox used for testing before training_s.py, which is configured by yourself. If you don’t correct it, you will always report the following errors.
Of course, if the above instructions are OK, this error still occurs, that is, the category corresponding error in the demo.
Take my own example, I use VOC format datasets, but the default in the demo file is COCO_CLASSES, so this will definitely report an error, so we have to change it in the demo.py file.
First, find the file yolox/data/datasets/_init_.py and add the following code to the file.
from .voc_classes import VOC_CLASSES
Then enter tools/demo.py file
About 15 lines, Modify
from yolox.data.datasets import COCO_CLASSES
to
from yolox.data.datasets import VOC_CLASSES
Modify about 100 lines of cls_names in Predictor:
to
Set the function of about 300 lines
Change to
No error will be reported during operation, successful! NICE!