在detectron2的官网上有代码示例,但是因为有时候登录detectron2特别不稳定,在一定时间间隔内根本登录不上去,所以为了以后使用方便,在这里记录一下demo的具体使用方法。
cd demo/
python demo.py --config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \
--input input1.jpg input2.jpg \
[--other-options]
--opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl
To save outputs to a directory (for images) or a file (for webcam or video), use --output
.
需要注意的是.yaml中的数据集等参数需要与demo中的注册信息一样,否则检测出来的结果没有类别的标签,而且标注框的颜色随机。