推理
问题
1. ModuleNotFoundError: No module named 'groundingdino'
解决: 运行 python setup.py install 编译groundingdino库。或者直接引入环境变量:
linux:
export PYTHONPATH=$PYTHONPATH:/data/groundingdino
windows:
$env:PYTHONPATH = "$env:PYTHONPATH;/data/groundingdino"
2.SSHerror:忘了具体的报错名,总之是使用bert-base-uncased时,huggingface连接超时之类的错误,解决:手动下载:google-bert/bert-base-uncased at main (huggingface.co),并修改代码中相关路径,指向本地存放路径
3. NameError: name '_C' is not defined
解决:CUDA 配置错误,参考官方说明去解决IDEA-Research/GroundingDINO: [ECCV 2024] Official implementation of the paper "Grounding DINO: Marrying DINO with Grounded Pre-Training for Open-Set Object Detection" (github.com)
或者用cpu-only模式,不启用CUDA
结果
命令:
python demo/inference_on_a_image.py -c groundingdino/config/GroundingDINO_SwinT_OGC.py -p weights/groundingdino_swint_ogc.pth -i data/boat.jpg -o "output" -t "boat" --cpu-only
检测结果:
原图像: