MMrotate框架使用小技巧

保存最佳权重

进入到./configs/schedules里,将evaluation = dict(interval=1, metric='mAP')更改为evaluation = dict(interval=1, metric='mAP', save_best='auto')

查看模型复杂度

利用tools/analysis_tools/get_flops.py
本工具用于统计模型的参数量,可以通过 --shape 参数指定输入图片的尺寸
例如:

python tools/analysis_tools/get_flops.py configs/redet/redet_re50_refpn_3x_hrsc_le90.py --shape 800 512

讲述出为:

==============================
Input shape: (3, 800, 512)
Flops: 48.24 GFLOPs
Params: 35.25 M
==============================

计算单图推理时间

利用tools/analysis_tools/benchmark.py
此工具是用来测试模型在当前环境下的推理速度的,模型会跑一遍配置文件中指定的测试集,计算单图推理时间(FPS)。
例如:

python -m torch.distributed.launch --nproc_per_node=1 --master_port=29500 tools/analysis_tools/benchmark.py configs/redet/redet_re50_refpn_3x_hrsc_le90.py work_dirs/redet_re50_refpn_3x_hrsc_le90/epoch_1.pth --launcher pytorch

则输出为:

Done image [50 / 2000], fps: 7.1 img / s, times per image: 140.9 ms / img
Done image [100/ 2000], fps: 7.1 img / s, times per image: 141.1 ms / img
Done image [150/ 2000], fps: 7.1 img / s, times per image: 141.1 ms / img
Done image [200/ 2000], fps: 7.1 img / s, times per image: 140.8 ms / img
Done image [250/ 2000], fps: 7.2 img / s, times per image: 139.7 ms / img
Done image [300/ 2000], fps: 7.2 img / s, times per image: 139.0 ms / img
Done image [350/ 2000], fps: 7.2 img / s, times per image: 138.7 ms / img
Done image [400/ 2000], fps: 7.2 img / s, times per image: 138.4 ms / img
Done image [450/ 2000], fps: 7.2 img / s, times per image: 138.0 ms / img

将测试结果可视化

利用./tools/test.py加上参数--show-dir
例如:

python ./tools/test.py configs/redet/redet_
re50_refpn_1x_dota_le90.py work_dirs/redet_re50_refpn_1x_dota_le90/latest.pth --show-dir work_dirs/vis

更改可视化图片中显示的内容

在文件mmrotate/core/visualization/image.py
有代码:

draw_labels(
                ax,
                labels[num_bboxes:],
                positions,
                class_names=class_names,
                color=text_colors,
                font_size=font_size,
                scales=scales,
                horizontal_alignment=horizontal_alignment)

可以修改显示的内容。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值