mmdetection初步运行

1.安装conda虚拟环境时,按照官方说明一次就正常安装好了;
2.需要提前下载模型权重,运行时会自动下载resnet等模型的预训练权重,可以提前下载好后放进对应的隐藏文件夹内;
3.运行推理代码:

python demo/image_demo.py 'demo/demo.jpg' 'configs/detectors/detectors_cascade_rcnn_r50_1x_coco.py' 'checkpoints/detectors_cascade_rcnn_r50_1x_coco-32a10ba0.pth'

会报警告:

/home/lgy/PycharmProjects/mmdetection/mmdet/datasets/utils.py:68: UserWarning: "ImageToTensor" pipeline is replaced by "DefaultFormatBundle" for batch inference. It is recommended to manually replace it in the test data pipeline in your config file.
  'data pipeline in your config file.', UserWarning)

官方对该警告的建议是不用搭理,个人按警告替换后,报了一些奇奇怪怪的错误。

或者直接新建个py文件运行:

from mmdet.apis import init_detector, inference_detector
import mmcv

# Specify the path to model config and checkpoint file
config_file = 'configs/detectors/detectors_cascade_rcnn_r50_1x_coco.py'
checkpoint_file = 'checkpoints/detectors_cascade_rcnn_r50_1x_coco-32a10ba0.pth'

# build the model from a config file and a checkpoint file
model = init_detector(config_file, checkpoint_file, device='cuda:0')

# test a single image and show the results
img = 'demo/demo.jpg'
# img = mmcv.imread(img) # which will only load it once
result = inference_detector(model, img)
# visualize the results in a new window
# 可视化推理检测的结果
model.show_result(img, result)
# or save the visualization results to image files
# 将推理的结果保存
model.show_result(img, result, out_file='result.jpg')

# test a video and show the results
# 测试视频片段的推理结果
# video = mmcv.VideoReader('video.mp4')
# for frame in video:
#     result = inference_detector(model, frame)
#     model.show_result(frame, result, wait_time=1)

版权声明:本文为CSDN博主「下大禹了」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_43541325/article/details/115615142

下大禹了

我还没有学会写个人说明!

暂无评论

发表评论

相关推荐

Meta-DETR | 图像级“元”学习提升目标检测精度

计算机视觉研究院专栏作者:Edison_GOne-shot目标检测旨在通过几个标注的样本来检测新的目标。之前的工作已经证明了元学习是一个很有前途的解决方案,它们中的大多数基本上是通过解决在区域上的元学习检测来进行分类

AP AR mAP ROC AUC(目标检测)

禁止转载!在做目标检测任务的时候,通常会制定规则来评估性能,就如下图所示,后面会慢慢道来其中的原理。 混淆矩阵中 TP、TN、FP、FN
在目标检测中,通常以IoU阈值作为

瑕疵检测(深度学习)

与通用目标检测的区别
相较与整张图片瑕疵区域的占比一般非常小,Faster R-CNN等检测模型对小物体检测不够好
深度学习从低层到高层不断去提炼高层语义信息,层数的增大细节的信息丢失得越多,对于缺