源码:https://github.com/RangiLyu/nanodet
1. 运行inference,
python demo/demo.py image --config config//nanodet_irbt_list_dataset.yml --model checkpoint/nanodet-plus-m-1.5x_416/nanodet_model_best.pth --path data/test_data/x.jpg
出现如下错误提示:
oaded library "/home/anaconda3/envs/xxx/lib/python3.8/site-packages/cv2/qt/plugins/platforms/libqxcb.so"
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/anaconda3/envs/xxx/lib/python3.8/site-packages/cv2/qt/plugins/" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: xcb.
Aborted (core dumped)
原因可能是opencv-python的版本过高,降低其版本
2. cannot connect to X server
in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:2157.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
: cannot connect to X server
这个是因为demo.py里面开启了cv2.show(),这在ubuntu里面是不支持的,
修改下面的代码段
def visualize(self, dets, meta, class_names, score_thres, wait=0):
time1 = time.time()
result_img = self.model.head.show_result(
meta["raw_img"][0], dets, class_names, score_thres=score_thres, show=False
)
print("viz time: {:.3f}s".format(time.time() - time1))
return result_img
show=False
3.找不到推理后的数据
rser.add_argument("--config", help="model config file path")
parser.add_argument("--model", help="model file path")
parser.add_argument("--path", default="./demo", help="path to images or video")
parser.add_argument("--camid", type=int, default=0, help="webcam demo camera id")
parser.add_argument(
"--save_result",
action="store_true",
help="whether to save the inference result of image/video",
不要忘记save_result这个参数