Yolo v7图像目标检测无标注问题排查求助
YOLOv7检测结果无标注问题排查
我在Docker中部署YOLOv7,程序运行无报错,但生成的检测图像和原图完全一致,没有任何目标标注。以下是完整复现步骤、控制台输出及环境信息,求排查问题。
复现命令
git clone https://github.com/WongKinYiu/yolov7 cd yolov7 nvidia-docker run --name yolov7 -it --rm -v "$CWD":/yolov7 --shm-size=64g nvcr.io/nvidia/pytorch:21.08-py3 # 容器内操作 cd /yolov7 python -m pip install virtualenv python -m virtualenv venv3 . venv3/bin/activate pip install -r requirements.txt apt update apt install -y zip htop screen libgl1-mesa-glx pip install seaborn thop python detect.py --weights yolov7.pt --conf 0.25 --img-size 640 --source inference/images/horses.jpg
检测命令控制台输出
# python detect.py --weights yolov7.pt --conf 0.25 --img-size 640 --source inference/images/horses.jpg Namespace(agnostic_nms=False, augment=False, classes=None, conf_thres=0.25, device='', exist_ok=False, img_size=640, iou_thres=0.45, name='exp', no_trace=False, nosave=False, project='runs/detect', save_conf=False, save_txt=False, source='inference/images/horses.jpg', update=False, view_img=False, weights=['yolov7.pt']) YOLOR 🚀 v0.1-115-g072f76c torch 1.13.0+cu117 CUDA:0 (NVIDIA GeForce GTX 1650, 3903.875MB) Fusing layers... RepConv.fuse_repvgg_block RepConv.fuse_repvgg_block RepConv.fuse_repvgg_block Model Summary: 306 layers, 36905341 parameters, 6652669 gradients Convert model to Traced-model... traced_script_module saved! model is traced! /yolov7/venv3/lib/python3.8/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3190.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] Done. (150.9ms) Inference, (0.3ms) NMS The image with the result is saved in: runs/detect/exp6/horses.jpg Done. (0.616s)
按预期,生成的图像runs/detect/exp6/horses.jpg应显示检测结果,但它与原图inference/images/horses.jpg完全一致,无任何差异。
环境信息
NVIDIA驱动
$ nvidia-smi Tue Dec 6 09:47:03 2022 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 525.60.11 Driver Version: 525.60.11 CUDA Version: 12.0 | |-------------------------------+----------------------+----------------------+| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC || Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. || | | MIG M. ||===============================+======================+======================|| 0 NVIDIA GeForce ... On | 00000000:01:00.0 Off | N/A || 45% 27C P8 N/A / 75W | 13MiB / 4096MiB | 0% Default || | | N/A |+-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: || GPU GI CI PID Type Process name GPU Memory || ID ID Usage ||=============================================================================|| 0 N/A N/A 1152 G /usr/lib/xorg/Xorg 9MiB || 0 N/A N/A 1256 G /usr/bin/gnome-shell 2MiB |+-----------------------------------------------------------------------------+
Ubuntu版本
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.4 LTS Release: 20.04 Codename: focal
排查建议
- 验证权重文件:确认
yolov7.pt是否完整下载,可删除后重新下载官方权重文件替换,再运行检测。 - 降低置信度:当前设置的
--conf 0.25可能过滤掉了所有检测结果,尝试改为--conf 0.1或更低阈值测试。 - 跳过虚拟环境:容器基础环境已预装PyTorch,可尝试不创建虚拟环境,直接安装依赖后运行检测,避免版本冲突。
- 检查测试图像:替换为其他清晰的目标测试图,确认原图像是否存在模糊、目标过小等问题导致检测失败。
- 指定推理设备:手动添加
--device 0强制使用GPU,或--device cpu切换到CPU推理,排查设备兼容性问题。
内容的提问来源于stack exchange,提问作者丶 Limeー来夢 丶
相关产品推荐
相关产品推荐

