GithubHelp home page GithubHelp logo

mmdetection-mini's Introduction

mmdetection-mini

mmdetection的mini版本,主要包括一阶段目标检测器,结构和 mmdetection完全一致,系统通过从头构建整个框架来熟悉所有细节

0 蓝图

本仓库属于长期项目,计划分成n个阶段,每个阶段做啥事情我已经有打算了,目前还处于第一阶段:解读mmdet已经复现的算法。这个阶段主要是对mmdet已经复现的代码进行深度分析,每个算法都会有配套的详细论文和代码实现解读(后续会增加视频解读和汇总版解读文档)。故如果大家早当前阶段想利用本框架进行重新训练,最好还是直接用mmdet官方代码库,在后续阶段会重构训练逻辑代码,新增对比实验等等操作,请各位朋友不要着急!

1 为何而生

很多人可能有疑问:mmdetection那么好用,你为啥要自己又写一遍呢?没事干? 其实不然,基于我目前的理解,出于以下几点原因:

  • 学习目的 mmdetection无疑是非常优异的目标检测框架,但是其整个框架代码其实非常多。我希望通过从0构建整个 结构,来彻底熟悉整个框架,而不是仅仅熟悉算法部分。只有自己写一遍才能发现一些容易忽略的细节
  • 方便注释 这一点,我相信很多人都碰到过。主要原因是mmdetection发展太快了,更新特别频繁,比如今天我拉了最新分支 加入了我的一些理解注释,过了两天,一更新就发现完全变了,此时再pull就出现很多冲突。天天解决这些冲突其实蛮累的。 所以我自己写一个mmdetection,然后加入注释,并且实时同步mmdetection到最新版,不仅可能清楚每次更新的 所有细节,还可以不影响注释
  • 新特性方便增加 如果自己想实现一些mmdetection里面没有的新特性,就非常方便了。比如我要在debug模式下进行可视化分析, 如果直接加到mmdetection上面,会改动一些代码,一旦pull又有冲突。由于同步mmdetection过程是手动的,新增特征 也不会出现冲突

2 介绍

完全基于mmdetection框架结构,简称mmdet最简学习版,基于最简实现,第一原则就是简洁,不会加入一些乱七八糟的功能,一步一步构建一阶段目标检测器。 主要目的为在从0构建整个框架的基础上,掌握整个目标检测实现细节。 并且方便新增自己想要实现的部分。

由于只有一张显卡,故不支持分布式训练。

总结:本项目目的是学习,希望通过从0构建每一行代码,来熟悉每个部分,而且自己写的框架,后续我新增一些新特性也非常容易

更新可能是快时慢。在掌握每个细节后才会增加新代码,欢迎有兴趣的朋友共同学习,也欢迎提出意见。

3 提交日志

文档链接

4 已实现模型

  • retinanet
  • yolov3
  • darknet-yolov3
  • darknet-yolov4
  • darknet-tiny_yolov3
  • darknet-tiny_yolov4
  • yolov5(s/m/l/x全部支持)
  • fcos
  • atss
  • ghm
  • gfl
  • pisa
  • paa
  • faster rcnn
  • cascade rcnn
  • libra rcnn
  • dynamic rcnn
  • ssd
  • vfnet
  • guided anchoring
  • sabl
  • reppoints
  • reppointsv2
  • cornernet
  • centripetalnet

5 模型仓库

文档链接

6 安装说明

可选安装流程: 文档链接

推荐安装流程: 考虑到很多人反映cuda无法编译成功,故本仓库将直接采用mmcv里面已经编译好的代码,新安装流程是:

  1. 提前安装mmcv-full对应的最新版本,参考https://github.com/open-mmlab/mmdetection/blob/master/docs/get_started.md
  2. 不再需要python setup.py develop

也就是说mmdet/cv_core/ops/csrc里面的代码是废弃的。我们目前采用的环境是 pytorch1.3+Python 3.6+CUDA10.1+MMCV1.1.5

7 统一数据集

由于coco训练集图片太多了,跑到论文效果需要非常多时间,而本框架目的主要目的是快速验证 **和算法(代码和mmdetection一致,应该没有错误),故对主要以voc为主:

  • coco
  • voc2012和voc2007
  • wider face

8 使用说明

8.1 训练、测试和demo使用说明

开启训练过程和mmdetection完全一致,例如:

python train.py ../configs/retinanet/retinanet_r50_fpn_coco.py

开启测试过程和mmdetection完全一致,例如:

# 评估   
python test.py ../configs/retinanet/retinanet_r50_fpn_coco.py ../tools/work_dirs/retinanet_r50_fpn_coco/latest.pth --eval bbox
# 显示
python test.py ../configs/retinanet/retinanet_r50_fpn_coco.py ../tools/work_dirs/retinanet_r50_fpn_coco/latest.pth --show

开启demo过程和mmdetection完全一致,例如:

python image_demo.py demo.jpg ../configs/retinanet/retinanet_r50_fpn_coco.py ../tools/work_dirs/retinanet_r50_fpn_coco/latest.pth

8.2 darknet权重转化为mmdetection

转化脚本在tools/darknet里面

使用方法就是参考模型仓库文档里面的链接,将对应的权重下载下来,然后设置path就可以转化成功

例如tiny_yolov3权重:

  1. 首先到https://github.com/AlexeyAB/darknet 对应的tiny_yolov3链接处下载对应权重

  2. 打开tools/darknet/tiny_yolov3.py代码,修改tiny_yolov3_weights_path为你的下载的权重路径

  3. 运行tiny_yolov3.py即可生成pth权重

  4. 然后就可以直接训练或者测试了

8.3 yolov5权重转化为mmdetection

转化脚本在tools/darknet里面。以yolov5s为例

  1. https://github.com/ultralytics/yolov5/releases/tag/v3.0 处下载yolo5s.pt或者直接运行convert_yolov5_weights_step1.py脚本,会自动下载
  2. 运行convert_yolov5_weights_step1.py脚本,但是不好意思,你不能直接在我写的路径下运行,你需要将本脚本copy到yolov5工程目录下运行,并且必须pytorch版本大于等于1.6,原因是其保存的权重包括了picker对象,如果不放在相同路径下无法重新加载
  3. 利用上一步所得权重,然后运行tools/darknet/convert_yolov5_weights_step2.py(在本框架中运行),得到最终转化模型
  4. 然后修改configs/yolo/rr_yolov5_416_coco.py对应的路径就可以进行前向测试或者mAP计算了

支持yolov5所有模型

9 mmdetection-mini独有特性

  • loss分析工具 tools/loss_analyze.py
  • anchor分析工具 tools/anchor_analyze.py
  • 模型感受野自动计算工具 tools/receptive_analyze.py
  • 前向推理时间分析工具 tools/inference_analyze.py
  • 特征图可视化工具tools/featuremap_analyze
  • darknet权重和mmdetection模型相互转化工具 tools/darknet
  • 数据分析工具(hw ratio/hw scale/anchor kmean)tools/dataset_analyze
  • 正样本可视化,需要开启debug模式
  • 支持darknet系列模型权重在mmdetection中训练,目前支持4个主流模型yolov3/v4和tiny-yolov3/v4
  • coco数据可视化工具,包括显示所有label和仅仅显示gt bbox格式,显示效果极佳(即使是voc数据,也推荐先转化为coco)
  • 支持任意数据格式转coco类CocoCreator
  • yolov5转化工具tools/darknet/convert_yolov5_weights_step2.py

10 mmdetection-mini工具汇总

  • voc2coco工具 tools/convert/voc2coco
  • 数据浏览工具 tools/browse_dataset

笔记(持续更新)

第一篇:mmdetection最小复刻版(一):整体概览
或者 知乎文章
第二篇:mmdetection最小复刻版(二):RetinaNet和YoloV3分析
或者 知乎文章
第三篇:mmdetection最小复刻版(三):神兵利器
或者 知乎文章
第四篇:mmdetection最小复刻版(四):独家yolo转化内幕
或者 知乎文章
第五篇:mmdetection最小复刻版(五):yolov5转化内幕
或者 知乎文章
第六篇:mmdetection最小复刻版(六):FCOS深入可视化分析
或者 知乎文章
第七篇:mmdetection最小复刻版(七):anchor-base和anchor-free差异分析
或者 知乎文章
第八篇:mmdetection最小复刻版(八):梯度均衡机制GHM深入分析
或者 知乎文章
第九篇:mmdetection最小复刻版(九):广义FocalLoss深入分析
或者 知乎文章
第十篇:mmdetection最小复刻版(十):mAP和PISA深入分析
第十一篇:mmdetection最小复刻版(十一):概率Anchor分配机制PAA深入分析
第十二篇:mmdetection最小复刻版(十二):Faster RCNN深入分析
第十三篇:mmdetection最小复刻版(十三):超强cascade rcnn算法分析
第十四篇:mmdetection最小复刻版(十四):检测器不平衡处理Libra rcnn
第十五篇:mmdetection最小复刻版(十五):two-stage动态版本dynamic rcnn
或者 知乎文章
第十六篇:mmdetection最小复刻版(十六):iou感知VarifocalNet深入分析
或者 知乎文章
第十七篇:mmdetection最小复刻版(十七):语义导向anchor生成
第十八篇:mmdetection最小复刻版(十八):Side-Aware边界框定位
第十九篇:mmdetection最小复刻版(十九):点集表示法RepPoints
第二十篇:mmdetection最小复刻版(二十):加入验证任务的RepPointsV2
第二十一篇:mmdetection最小复刻版(二十一):关键点检测思路CornerNet分析
第二十二篇:mmdetection最小复刻版(二十二):引入向心力解决CornerNet虚检问题

3W字长文带你轻松入门视觉transformer

other

  1. 目标检测通用算法流程
  2. yolov1深入解读
  3. ssd深入解读
  4. yolov2深入解读
  5. yolov3深入解读
  6. retinanet深入解读
  7. rpn深度解读
  8. faster rcnn深入解读
  9. fpn深入解读
  10. mask rcnn深入解读
  11. cascade rcnn深入解读
  12. fcos深入解读

mmdetection-mini's People

Contributors

hhaandroid avatar pi-pi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mmdetection-mini's Issues

阅读文章需要密码

感谢作者提供的优秀工作!

在看下面的一些算法分析的时候,RepPointv2需要密码才能查看,作者可以提供一下吗?
还有就是之前的一些文章,里面的图片挂掉了,有的是文章本身404了,希望作者可以有空解决一下!

祝好!

训练出现问题,求解答

Traceback (most recent call last):
File "D:/MachineLearning/unet/mmdetection-mini-master/tools/train.py", line 11, in
import mmdet.cv_core
File "D:\MachineLearning\unet\mmdetection-mini-master\tools..\mmdet\cv_core_init_.py", line 15, in
from .ops import *
File "D:\MachineLearning\unet\mmdetection-mini-master\tools..\mmdet\cv_core\ops_init_.py", line 3, in
from .cc_attention import CrissCrossAttention
File "D:\MachineLearning\unet\mmdetection-mini-master\tools..\mmdet\cv_core\ops\cc_attention.py", line 9, in
ext_module = ext_loader.load_ext(
File "D:\MachineLearning\unet\mmdetection-mini-master\tools..\mmdet\cv_core\utils\ext_loader.py", line 10, in load_ext
assert hasattr(ext, fun), f'{fun} miss in module {name}'
AssertionError: ca_forward miss in module _ext

Process finished with exit code 1

这里为什么要+1呢?

assigned_gt_inds[pos_inds] = argmax_overlaps[pos_inds] + 1 # 正样本anchor,保存对应的gt bbox索引,表示和其匹配上

这里为什么要+1呢? 我理解argmax_overlaps里存储了max_overlaps所对应的gt_box的idx, 直接赋值不就好了吗, +1是出于什么考虑呢? 而且在同文件的161~162行进行分配label的时候又去-1已获得gt_box idx, 感觉有点多此一举啊, 但感觉肯定不是没有原因的,所以想问下

            if pos_inds.numel() > 0:
                assigned_labels[pos_inds] = gt_labels[
                    assigned_gt_inds[pos_inds] - 1]  # 正样本anchor处的label值

PAA报错

大佬,请问我想发PAA移植到RPN上去,结果有报错,请问方法可取吗

在 paa_reassign()方法的 level_gt_mask = level_mask & gt_mask 报错,说是特征维度不一致。

RuntimeError: The size of tensor a (746) must match the size of tensor b (1220) at non-singleton dimension 0

使用torchsummary打印网络结构

conda3+mmdetection2.3.0+python3.7+pytorch1.5.0+torchvision0.6.0+mmcv1.1.6+torchsummary1.5.1
当我使用torchsummary工具试图打印fcos网络结构:
from mmdet.apis import init_detector
from torchsummary import summary
checkpoint_file=...
config_file=...
model=init_detector(config_file,checkpoint_file)
summary(model,(3,224,224))
报错:TypeError:forward() missing 1 required positional argument:'img_metas'
我确定已经在fcos的配置文件的train_pipline中加入了完整的meta_keys(包含img字段),并把debug模式开启。请问对于这种错误有什么解决方案吗?

inference_analyze.py problem

当我使用跑“
python tools/infertime_analyze.py configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py

报错:“
AttributeError: 'NoneType' object has no attribute 'rpn'

我应该怎么解决这个问题呀

旋转目标检测

是否有兴趣实现基于yolov5的旋转目标检测?可以在HRSC2016这种广泛采用的公开小型数据集上验证效果。

求助

作者您好,请问您方便给个vx吗?想请教一些关于这个repo使用的问题。谢谢~

losses=self(**data)

你好,这一句我不是很明白训练过程中是如何计算损失呢,我看了代码到mmdet/models/detectors/base.py train_step()函数里面有这一句,能不能麻烦你讲解一下。

训练效果

使用mini的yolov5训练自己的数据集时出现了比yolov3低了20多个点的情况,都没有使用预训练权重,下面是训练截图的map对比,百思不得其解。希望大佬们能提供一些思路。
我猜测是SGD设为0.001的问题,改为源码的0.01也没有什么改善。
image

怎么可视化正负样本的采样结果呢

非常感谢你的这份工作!我在你的简介里看到了可以可视化正样本的采样结果,不过需要开启debug模式,但是想知道采样结果可视化的这部分代码在哪个位置呢,能够直接调用吗?

cv_core/parallel/data_parallel.py中的53行和77行是不是少写了[0]

作者您好,在阅读你的MMDataParallel源码时发现,53行和77行与mmcv中不符。
你的代码库是return self.module.train_step(*inputs, **kwargs)
mmcv代码库是return self.module.train_step(*inputs[0], **kwargs[0])

scatter返回的tuple嘛,应该是需要[0]取一下元素的

运行环境

请问您这个工程能在windows下运行吗?

修改类别后遇到RuntimeError: shape '[1, -1, 11]' is invalid for input of size 58140

Traceback (most recent call last):
File "tools/train.py", line 133, in
main()
File "tools/train.py", line 129, in main
meta=meta)
File "/data/jun/mmdetection-mini/tools/../mmdet/apis/train.py", line 104, in train_detector
runner.run(data_loaders, cfg.workflow, cfg.total_epochs)
File "/data/jun/mmdetection-mini/tools/../mmdet/cv_core/runner/epoch_based_runner.py", line 124, in run
epoch_runner(data_loaders[i], **kwargs)
File "/data/jun/mmdetection-mini/tools/../mmdet/cv_core/runner/epoch_based_runner.py", line 48, in train
self.run_iter(data_batch, train_mode=True)
File "/data/jun/mmdetection-mini/tools/../mmdet/cv_core/runner/epoch_based_runner.py", line 28, in run_iter
**kwargs)
File "/data/jun/mmdetection-mini/tools/../mmdet/cv_core/parallel/data_parallel.py", line 69, in train_step
return self.module.train_step(*inputs[0], **kwargs[0]) # 然后调用model自己的train_step方法
File "/data/jun/mmdetection-mini/tools/../mmdet/models/detectors/base.py", line 204, in train_step
losses = self(**data)
File "/home/jun/.conda/envs/jun/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/data/jun/mmdetection-mini/tools/../mmdet/models/detectors/base.py", line 138, in forward
return self.forward_train(img, img_metas, **kwargs)
File "/data/jun/mmdetection-mini/tools/../mmdet/models/detectors/single_stage.py", line 95, in forward_train
gt_labels, gt_bboxes_ignore, **kwargs)
File "/data/jun/mmdetection-mini/tools/../mmdet/models/dense_heads/base_dense_head.py", line 54, in forward_train
losses = self.loss(*loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore)
File "/data/jun/mmdetection-mini/tools/../mmdet/models/dense_heads/base_yolo_head.py", line 346, in loss
self.loss_single, pred_maps, target_maps_list, neg_maps_list)
File "/data/jun/mmdetection-mini/tools/../mmdet/det_core/utils/misc.py", line 54, in multi_apply
return tuple(map(list, zip(*map_results)))
File "/data/jun/mmdetection-mini/tools/../mmdet/models/dense_heads/base_yolo_head.py", line 372, in loss_single
1).reshape(num_imgs, -1, self.num_attrib)
RuntimeError: shape '[1, -1, 11]' is invalid for input of size 58140
(jun) jun@lthpc:/data/jun/mmdetection-mini$ RuntimeError: shape '[1, -1, 11]' is invalid for input of size 58140

感受野计算出错

您好,我尝试将您实现的感受野计算工具迁移至mmdetv2中去,但一直计算出错
尝试retinanet感受野计算,报以下错
Traceback (most recent call last):
File "tools/receptive_analyze.py", line 45, in
analyze_receptive(cfg, input_shape, index)
File "tools/receptive_analyze.py", line 36, in analyze_receptive
calc_receptive_filed(model, input_shape, index)
File "/home/zhaoxin/workspace/mmdetection/tools/../mmdet/core/utils/receptivefield.py", line 103, in calc_receptive_filed
cal_model.compute(input_shape, [index])
File "/home/zhaoxin/workspace/mmdetection/tools/../mmdet/core/utils/receptivefield.py", line 54, in compute
replace_names_dict(self._model)
File "/home/zhaoxin/workspace/mmdetection/tools/../mmdet/core/utils/misc.py", line 86, in replace_names_dict
_get_names(model)
File "/home/zhaoxin/workspace/mmdetection/tools/../mmdet/core/utils/misc.py", line 73, in _get_names
_get_names(m, parent_name=name)
File "/home/zhaoxin/workspace/mmdetection/tools/../mmdet/core/utils/misc.py", line 78, in _get_names
module._modules[key] = Linear()
NameError: name 'Linear' is not defined

尝试faster rcnn时,报以下错
Traceback (most recent call last):
File "tools/receptive_analyze.py", line 45, in
analyze_receptive(cfg, input_shape, index)
File "tools/receptive_analyze.py", line 34, in analyze_receptive
model = create_model(cfg)
File "tools/receptive_analyze.py", line 29, in create_model
model = build_detector(cfg.model, train_cfg=None, test_cfg=None)
File "/home/zhaoxin/workspace/mmdetection/tools/../mmdet/models/builder.py", line 67, in build_detector
return build(cfg, DETECTORS, dict(train_cfg=train_cfg, test_cfg=test_cfg))
File "/home/zhaoxin/workspace/mmdetection/tools/../mmdet/models/builder.py", line 32, in build
return build_from_cfg(cfg, registry, default_args)
File "/home/zhaoxin/workspace/mmcv/mmcv/utils/registry.py", line 171, in build_from_cfg
return obj_cls(**args)
File "/home/zhaoxin/workspace/mmdetection/tools/../mmdet/models/detectors/faster_rcnn.py", line 24, in init
pretrained=pretrained)
File "/home/zhaoxin/workspace/mmdetection/tools/../mmdet/models/detectors/two_stage.py", line 34, in init
rpn_head_.update(train_cfg=rpn_train_cfg, test_cfg=test_cfg.rpn)
AttributeError: 'NoneType' object has no attribute 'rpn'

Welcome update to OpenMMLab 2.0

Welcome update to OpenMMLab 2.0

I am Vansin, the technical operator of OpenMMLab. In September of last year, we announced the release of OpenMMLab 2.0 at the World Artificial Intelligence Conference in Shanghai. We invite you to upgrade your algorithm library to OpenMMLab 2.0 using MMEngine, which can be used for both research and commercial purposes. If you have any questions, please feel free to join us on the OpenMMLab Discord at https://discord.gg/amFNsyUBvm or add me on WeChat (van-sin) and I will invite you to the OpenMMLab WeChat group.

Here are the OpenMMLab 2.0 repos branches:

OpenMMLab 1.0 branch OpenMMLab 2.0 branch
MMEngine 0.x
MMCV 1.x 2.x
MMDetection 0.x 、1.x、2.x 3.x
MMAction2 0.x 1.x
MMClassification 0.x 1.x
MMSegmentation 0.x 1.x
MMDetection3D 0.x 1.x
MMEditing 0.x 1.x
MMPose 0.x 1.x
MMDeploy 0.x 1.x
MMTracking 0.x 1.x
MMOCR 0.x 1.x
MMRazor 0.x 1.x
MMSelfSup 0.x 1.x
MMRotate 1.x 1.x
MMYOLO 0.x

Attention: please create a new virtual environment for OpenMMLab 2.0.

请问在使用可视化工具时出现输入不连续的问题怎么办?RuntimeError: input must be contiguous (deform_conv_forward at ./mmcv/ops/csrc/pytorch/deform_conv.cpp:66)

RuntimeError: input must be contiguous (deform_conv_forward at ./mmcv/ops/csrc/pytorch/deform_conv.cpp:66)
frame #0: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x47 (0x7f0f42ff1627 in /home/linsy/anaconda3/envs/FCOS/lib/python3.8/site-packages/torch/lib/libc10.so)
frame #1: deform_conv_forward(at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, int, int, int, int, int, int, int, int, int, int, int) + 0x5fa (0x7f0ee575d8ea in /home/linsy/anaconda3/envs/FCOS/lib/python3.8/site-packages/mmcv/_ext.cpython-38-x86_64-linux-gnu.so)
frame #2: + 0x96300 (0x7f0ee569f300 in /home/linsy/anaconda3/envs/FCOS/lib/python3.8/site-packages/mmcv/_ext.cpython-38-x86_64-linux-gnu.so)
frame #3: + 0x9644e (0x7f0ee569f44e in /home/linsy/anaconda3/envs/FCOS/lib/python3.8/site-packages/mmcv/_ext.cpython-38-x86_64-linux-gnu.so)
frame #4: + 0x928fc (0x7f0ee569b8fc in /home/linsy/anaconda3/envs/FCOS/lib/python3.8/site-packages/mmcv/_ext.cpython-38-x86_64-linux-gnu.so)

frame #11: THPFunction_apply(_object*, _object*) + 0xb2f (0x7f0f742dfd1f in /home/linsy/anaconda3/envs/FCOS/lib/python3.8/site-packages/torch/lib/libtorch_python.so)

请教解码函数

image

yolov5解码函数这里,为什么说mmdetection的anchor已经偏移了0.5? 咋看出来的?

我用detecton2发现的时候,

# 由于mmdetection的anchor已经偏移了0.5,故*2的操作要放在外面
        x_center_pred = (pred_bboxes[..., 0] - 0.5) * 2 * stride + x_center
        y_center_pred = (pred_bboxes[..., 1] - 0.5) * 2 * stride + y_center
        # yolov5中正常情况应该是
        # x_center_pred = (pred_bboxes[..., 0] * 2. - 0.5 + grid[:, 0]) * stride  # xy
        # y_center_pred = (pred_bboxes[..., 1] * 2. - 0.5 + grid[:, 1]) * stride  # xy

用了下面的写法感觉中心点有偏移,是为啥

求更

啥时候更新啊大佬,跟着你这个学mmdetection比原版的清晰多了

有關於fcos訓練可視化

2020-11-23 16:43:28,481 - mmdet - INFO - workflow: [('train', 1)], max: 12 epochs
Traceback (most recent call last):
File "train.py", line 133, in
main()
File "train.py", line 129, in main
meta=meta)
File "/home/danny/Lab/mmdetection-mini/tools/../mmdet/apis/train.py", line 104, in train_detector
runner.run(data_loaders, cfg.workflow, cfg.total_epochs)
File "/home/danny/Lab/mmdetection-mini/tools/../mmdet/cv_core/runner/epoch_based_runner.py", line 124, in run
epoch_runner(data_loaders[i], **kwargs)
File "/home/danny/Lab/mmdetection-mini/tools/../mmdet/cv_core/runner/epoch_based_runner.py", line 48, in train
self.run_iter(data_batch, train_mode=True)
File "/home/danny/Lab/mmdetection-mini/tools/../mmdet/cv_core/runner/epoch_based_runner.py", line 28, in run_iter
**kwargs)
File "/home/danny/Lab/mmdetection-mini/tools/../mmdet/cv_core/parallel/data_parallel.py", line 69, in train_step
return self.module.train_step(*inputs[0], **kwargs[0]) # 然后调用model自己的train_step方法
File "/home/danny/Lab/mmdetection-mini/tools/../mmdet/models/detectors/base.py", line 204, in train_step
losses = self(**data)
File "/home/danny/anaconda3/envs/mmdetetion-mini/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/home/danny/Lab/mmdetection-mini/tools/../mmdet/models/detectors/base.py", line 138, in forward
return self.forward_train(img, img_metas, **kwargs)
File "/home/danny/Lab/mmdetection-mini/tools/../mmdet/models/detectors/single_stage.py", line 95, in forward_train
gt_labels, gt_bboxes_ignore, **kwargs)
File "/home/danny/Lab/mmdetection-mini/tools/../mmdet/models/dense_heads/base_dense_head.py", line 54, in forward_train
losses = self.loss(*loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore)
File "/home/danny/Lab/mmdetection-mini/tools/../mmdet/models/dense_heads/fcos_head.py", line 207, in loss
img = img_meta['img'].data.numpy()
KeyError: 'img'

使用voc轉成coco來訓練,config多修改成以下
train_cfg = dict( # 在fcos里面是不需要的
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.5,
neg_iou_thr=0.4,
min_pos_iou=0,
ignore_iof_thr=-1),
allowed_border=-1,
pos_weight=-1,
debug=True)

如果debug=False是可以訓練

can you train yolov5?

i can not train yolov5 with your code ,report error ' ValueError: Target size (torch.Size([16, 1200, 1])) must be the same as input size (torch.Size([16, 17000, 1]))',it seems that have prombles on network ,i find two prombles,the first is the neck of yolov5 is none ,the neck code need to write,the second is anchor size of yolov5 is that of yolov3 ,which need to be modified. finally ,thank you for you great work ,Look forward to your reply!

多卡训练

您好,从原生mmdetection转到了您的版本,觉得您的代码写的十分简练,适合学习。如果您能在后续的工作中在train.py中支持多卡训练就更完美了,也可能是我没有找到正确的方法。也希望您能创建一个群,大家可以共同研究代码,谢谢!

a_forward miss in module _ext 按照网上的办法重装了很多次,没用

ca_forward miss in module _ext
File "/remote-home/liguopeng/object_detection/object_detection/mmdetection/adv/cv_core/utils/ext_loader.py", line 8, in load_ext
assert hasattr(ext, fun), f'{fun} miss in module {name}'
File "/remote-home/liguopeng/object_detection/object_detection/mmdetection/adv/cv_core/ops/cc_attention.py", line 9, in
ext_module = ext_loader.load_ext(
File "/remote-

focal_loss_cuda.obj : error LNK2001: 无法解析的外部符号 "public: long __cdecl at::Tensor::item<long>(void)const " (??$item@J@Tensor@at@@QEBAJXZ) build\lib.win-amd64-3.8\mmdet\cv_core\_ext.cp38-win_amd64.pyd : fatal error LNK1120: 1 个无法解析的外部命令

OS: Win10
CUDA: 11.0
pytorch: 1.7.1+cu110
python: 3.8

编译mmdetection-mini时出现了以下错误:

LIB:build\temp.win-amd64-3.8\Release\./mmdet/cv_core/ops/csrc/pytorch\_ext.cp38-win_amd64.lib
  正在创建库 build\temp.win-amd64-3.8\Release\./mmdet/cv_core/ops/csrc/pytorch\_ext.cp38-win_amd64.lib 和对象 build\temp.win-amd64-3.8\Release\./mmdet/cv_core/ops/csrc/pytorch\_ext.cp38-win_amd64.exp
focal_loss_cuda.obj : error LNK2001: 无法解析的外部符号 "public: long __cdecl at::Tensor::item<long>(void)const " (??$item@J@Tensor@at@@QEBAJXZ)
build\lib.win-amd64-3.8\mmdet\cv_core\_ext.cp38-win_amd64.pyd : fatal error LNK1120: 1 个无法解析的外部命令
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29333\\bin\\HostX86\\x64\\link.exe' failed with exit status 1120

windows下的mmcv-full已经在mmcv的讨论open-mmlab/mmcv#709 (comment) 中实现了编译安装。mmdetection是可以正常编译的。

About YoloV4

Thank your for share this modify mmdet version.
Source YOLOV4 include many trick but dont find it in your project, such as Mosaic/AdversarialTraining etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.