fasterRCNN检测时取消/不输出置信度conf

fasterRCNN 检测时取消/不输出置信度conf

在predict.py中,ctrl+鼠标左键点击draw_objs进入draw_box_utils.py中的draw_text函数:
在这里插入图片描述
在这里插入图片描述
将54行:

isplay_str = f"{category_index[str(cls)]}: {int(100 * score)}%"

改为:

display_str = f"{category_index[str(cls)]}"  # # 不绘制置信度信息conf

然后回去运行predict.py即可。

运行predict.py方法

修改的地方主要有“

model = create_model(num_classes=2)  # 改成自己的类别数目+1,要加上背景)

忘记改这里会报错:

RuntimeError: Error(s) in loading state_dict for FasterRCNN:
	size mismatch for roi_heads.box_predictor.cls_score.weight: copying a param with shape torch.Size([2, 1024]) from checkpoint, the shape in current model is torch.Size([21, 1024]).
	size mismatch for roi_heads.box_predictor.cls_score.bias: copying a param with shape torch.Size([2]) from checkpoint, the shape in current model is torch.Size([21]).
	size mismatch for roi_heads.box_predictor.bbox_pred.weight: copying a param with shape torch.Size([8, 1024]) from checkpoint, the shape in current model is torch.Size([84, 1024]).
	size mismatch for roi_heads.box_predictor.bbox_pred.bias: copying a param with shape torch.Size([8]) from checkpoint, the shape in current model is torch.Size([84]).
python-BaseException
weights_path = "./save_weights/resNetFpn-model-199.pth"   # 换成自己的权重路径
label_json_path = './pascal_voc_classes.json'  # 换成自己的类别的json文件
original_img = Image.open("/media/BilibalaWZ/deep-learning-for-image-processing-master/pytorch_object_detection/faster_rcnn/data_set/test_v5VSobbyyds/B_540_22.jpg")   # 换成自己的图片路径
plot_img.save("./runs/predict/exp2/B_540_22.jpg")  # 更换保存路径

ps:本文使用的fasterrcnn的代码为b站霹雳吧啦WZ的github仓库fasterrcnn代码包。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值