配置好detectron2,却不会使用。
网上找了一张街道图01.jpg放入文件夹images。
创建空文件夹results存放输出结果。
在detectron2路径下键入 目标检测
python demo/demo.py --config-file configs/COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml --input images/01.jpg --output results --opts MODEL.WEIGHTS models/model_final_b275ba.pkl
报错:
File "e:\ruanjian\13_2bao\fvcore-main\fvcore-main\fvcore\common\checkpoint.py", line 153, in load
assert os.path.isfile(path), "Checkpoint {} not found!".format(path)
AssertionError: Checkpoint models/model_final_b275ba.pkl not found!
改为:python demo/demo.py --config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input images/01.jpg --output results --opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl
解释:–opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl 会直接从网上下载,我们可以预先下载到本地,然后指定路径即可。参考零基础视角----学习detectron2如何训练自己数据集
model_final_f10217.pkl为实例分割
model_final_b275ba.pkl为目标检测
model_final_cafdb1.pkl为全景分割
webcam 就是开摄像头 实时监测
python demo/demo.py --config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --webcam
--opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl
除了model_final_f10217.pkl,其他可以参考Detectron2 快速开始,使用 WebCam 测试
去把 model zoo的模型 下载到本地