Giter VIP home page Giter VIP logo

picodet_pytorch's Introduction

PP-PicoDet: A Better Real-Time Object Detector on Mobile Devices

Introduction

@article{picodet,
  title={{PP-PicoDet}: A Better Real-Time Object Detector on Mobile Devices},
  author={Guanghua Yu, Qinyao Chang, Wenyu Lv, Chang Xu, Cheng Cui, Wei Ji, Qingqing Dang, Kaipeng Deng, Guanzhong Wang, Yuning Du, Baohua Lai, Qiwen Liu, Xiaoguang Hu, Dianhai Yu, Yanjun Ma},
  journal={arXiv preprint arXiv:2111.00902},
  year={2021}
}

Backbone Pretrained Weights

Results and Models

Bakcbone size box AP(ppdet) Config Download
picodet-s 320 26.9(27.1) config model | log
picodet-s 416 30.6(30.6) config model | log
picodet-m 416 34.2(34.3) config model | log
picodet-l 640 40.4(40.9) config model | log

Usage

Install MMdetection

Our implementation is based on mmdetection. Install mmdetection according to INSTALL

Note: Make sure your mmcv-full version is consistency with mmdet version(we use mmcv==1.4.0)

Train

  1. Download pretrained backbone using the link above

  2. training

bash tools/dist_train.sh ./configs/picodet/picodet_s_320_coco.py 4

Test

bash tools/dist_test.sh $CONFIG_PATH $TRAINED_MODEL_PATH $GPU_NUMS --eval bbox

eg. use picodet-s 320 pretrianed model
bash tools/dist_test.sh ./configs/picodet/picodet_s_320_coco.py $MODEL_DIR/picodet_s_320.26.9.pth 8 --eval bbox

Evaluating bbox...
Loading and preparing results...
DONE (t=1.76s)
creating index...
index created!
Running per image evaluation...
Evaluate annotation type *bbox*
DONE (t=43.50s).
Accumulating evaluation results...
DONE (t=14.63s).

 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.269
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=1000 ] = 0.408
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=1000 ] = 0.279
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=1000 ] = 0.076
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=1000 ] = 0.269
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=1000 ] = 0.462
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.421
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=300 ] = 0.421
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=1000 ] = 0.421
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=1000 ] = 0.138
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=1000 ] = 0.470
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=1000 ] = 0.684

Deploy

TODO:

  • mnn deploy

picodet_pytorch's People

Contributors

aemikachow avatar aronlin avatar bigwangyudong avatar bo396543018 avatar chenbo2-tal avatar chrisfsj2051 avatar daavoo avatar erotemic avatar hellock avatar hhaandroid avatar innerlee avatar johnson-wang avatar jshilong avatar melikovk avatar mxbonn avatar myownskyw7 avatar oceanpang avatar rangilyu avatar runningleon avatar ryanxli avatar shinya7y avatar thangvubk avatar tianyuandu avatar v-qjqs avatar wswday avatar xvjiarui avatar yeliudev avatar yhcao6 avatar yuzhj avatar zwwwayne 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

Watchers

 avatar

picodet_pytorch's Issues

How to use in Windows

Hello, author.
May I ask how to train and test in windows environment? Thank you!

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/A9dCpjHPfE or add me on WeChat (ID: 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 0.x 1.x
MMYOLO 0.x

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

导出 onnx 模型报错

你好,
我下载的示例模型,采用默认配置参数,导出onnx模型

python tools/deployment/pytorch2onnx.py configs/picodet/picodet_s_416_coco.py configs/picodet/picodet_s_416_coco.pth   --output-file /data/workspace/mmdet_picodet_s_416_coco.onnx

导出 onnx模型时报错:

File "/home/zxx/code/picodet_repro/mmdet/models/dense_heads/base_dense_head.py", line 427, in onnx_export
    assert cls_score.size()[-2:] == bbox_pred.size()[-2:]

然后发现好像是picodet_head.py 里195 行的维度没有对齐。将代码修改如下

if torch.onnx.is_in_onnx_export():
            # cls_score = (
            #     torch.sigmoid(cls_score)
            #     .reshape(1, self.num_classes, -1)
            #     .permute(0, 2, 1)
            # )
            # bbox_pred = bbox_pred.reshape(1, (self.reg_max + 1) * 4, -1).permute(
            #     0, 2, 1
            # )

            bbox_pred = bbox_pred.permute(0, 2, 3, 1).reshape(1, -1, 4 * (self.reg_max + 1))
            pred_corners = self.integral(bbox_pred)
            bbox_pred = pred_corners.reshape(1,cls_feat.shape[-2],cls_feat.shape[-1], 4).permute(0,3,1,2)

return cls_score, bbox_pred

但依然会报错:

load checkpoint from local path: configs/picodet/picodet_s_416_coco.pth
The model and loaded state dict do not match exactly

unexpected key in source state_dict: bbox_head.p3_feat.scale_reg, bbox_head.p4_feat.scale_reg, bbox_head.p5_feat.scale_reg, bbox_head.p6_feat.scale_reg, bbox_head.p7_feat.scale_reg

missing keys in source state_dict: bbox_head.gfl_reg.0.weight, bbox_head.gfl_reg.0.bias, bbox_head.gfl_reg.1.weight, bbox_head.gfl_reg.1.bias, bbox_head.gfl_reg.2.weight, bbox_head.gfl_reg.2.bias, bbox_head.gfl_reg.3.weight, bbox_head.gfl_reg.3.bias
/home/zxx/code/picodet_repro/mmdet/models/dense_heads/base_dense_head.py:407: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  cfg.get('nms_pre', -1), device=device, dtype=torch.long)

...

Traceback (most recent call last):
  File "tools/deployment/pytorch2onnx.py", line 345, in <module>
    skip_postprocess=args.skip_postprocess)
  File "tools/deployment/pytorch2onnx.py", line 100, in pytorch2onnx
    dynamic_axes=dynamic_axes)
  File "/home/zxx/miniconda3/envs/mmdet/lib/python3.7/site-packages/torch/onnx/__init__.py", line 276, in export
    custom_opsets, enable_onnx_checker, use_external_data_format)
  File "/home/zxx/miniconda3/envs/mmdet/lib/python3.7/site-packages/torch/onnx/utils.py", line 94, in export
    use_external_data_format=use_external_data_format)
  File "/home/zxx/miniconda3/envs/mmdet/lib/python3.7/site-packages/torch/onnx/utils.py", line 701, in _export
    dynamic_axes=dynamic_axes)
  File "/home/zxx/miniconda3/envs/mmdet/lib/python3.7/site-packages/torch/onnx/utils.py", line 503, in _model_to_graph
    _export_onnx_opset_version)
RuntimeError: number of dims don't match in permute

请问大佬有没有遇到这个问题,如何解决。

The model and loaded state dict do not match exactly

Hello,

I am trying the code demo/image_demo.py . while loading the pretrained weights I encountered the following error

load checkpoint from local path: demo/picodet_s_320.26.9.pth
The model and loaded state dict do not match exactly

unexpected key in source state_dict: ema_backbone_conv1_conv_weight, ema_backbone_conv1_bn_weight, ema_backbone_conv1_bn_bias, ema_backbone_conv1_bn_running_mean, ema_backbone_conv1_bn_running_var, ema_backbone_conv1_bn_num_batches_tracked, ema_backbone_2_1_conv_dw_1_conv_weight, ema_backbone_2_1_conv_dw_1_bn_weight, ema_backbone_2_1_conv_dw_1_bn_bias, ema_backbone_2_1_conv_dw_1_bn_running_mean, ema_backbone_2_1_conv_dw_1_bn_running_var, ema_backbone_2_1_conv_dw_1_bn_num_batches_tracked, ema_backbone_2_1_conv_linear_1_conv_weight, ema_backbone_2_1_conv_linear_1_bn_weight, ema_backbone_2_1_conv_linear_1_bn_bias, ema_backbone_2_1_conv_linear_1_bn_running_mean, ema_backbone_2_1_conv_linear_1_bn_running_var, ema_backbone_2_1_conv_linear_1_bn_num_batches_tracked, ema_backbone_2_1_conv_pw_2_conv_weight, ema_backbone_2_1_conv_pw_2_bn_weight, ema_backbone_2_1_conv_pw_2_bn_bias, ema_backbone_2_1_conv_pw_2_bn_running_mean, ema_backbone_2_1_conv_pw_2_bn_running_var, ema_backbone_2_1_conv_pw_2_bn_num_batches_tracked, ema_backbone_2_1_conv_dw_2_conv_weight, ema_backbone_2_1_conv_dw_2_bn_weight, ema_backbone_2_1_conv_dw_2_bn_bias,
.....................................................

I tried the following config and checkpoint file

config_file = 'configs/picodet/picodet_s_320_coco.py'
checkpoint_file = 'picodet_s_320.26.9.pth'

Any suggestions how to fix this ? Thanks.

NanoDet精度能对齐吗?

@Bo396543018
你好,我最近在mmdet2上面尝试对齐一下nanodet的精度,但是似乎数据增强那边有些出入,看你写的不知道有没有对齐精度呢?

可以增加一些操作说明。。。

Thanks for your error report and we appreciate it a lot.

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. I have read the FAQ documentation but cannot get the expected help.
  3. The bug has not been fixed in the latest version.

Describe the bug
A clear and concise description of what the bug is.

Reproduction

  1. What command or script did you run?
A placeholder for the command.
  1. Did you make any modifications on the code or config? Did you understand what you have modified?
  2. What dataset did you use?

Environment

  1. Please run python mmdet/utils/collect_env.py to collect necessary environment information and paste it here.
  2. You may add addition that may be helpful for locating the problem, such as
    • How you installed PyTorch [e.g., pip, conda, source]
    • Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)

Error traceback
If applicable, paste the error trackback here.

A placeholder for trackback.

Bug fix
If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

registry 没有 PicoDet

Traceback (most recent call last):
File "tools/train.py", line 185, in
main()
File "tools/train.py", line 158, in main
test_cfg=cfg.get('test_cfg'))
File "/home/zijing.wang/.local/lib/python3.6/site-packages/mmdet/models/builder.py", line 59, in build_detector
cfg, default_args=dict(train_cfg=train_cfg, test_cfg=test_cfg))
File "/home/zijing.wang/.local/lib/python3.6/site-packages/mmcv/utils/registry.py", line 213, in build
return self.build_func(*args, **kwargs, registry=self)
File "/home/zijing.wang/.local/lib/python3.6/site-packages/mmcv/cnn/builder.py", line 27, in build_model_from_cfg
return build_from_cfg(cfg, registry, default_args)
File "/home/zijing.wang/.local/lib/python3.6/site-packages/mmcv/utils/registry.py", line 46, in build_from_cfg
f'{obj_type} is not in the {registry.name} registry')
KeyError: 'PicoDet is not in the models registry'

picode网络的训练细节

Describe the feature
我也在复现picodet的网络,但是loss在训练集快速降到很小,但是验证集上的loss却比较大,map很低,由于是从paddlepaddle中抽取的部分代码,可能在训练上存在问题,也可能代码还有细节没注意到,希望博主能分享下训练的具体过程。
顺便提一下,预训练模型能在百度云上也放一个不?感谢
Motivation
A clear and concise description of the motivation of the feature.
Ex1. It is inconvenient when [....].
Ex2. There is a recent paper [....], which is very helpful for [....].

Related resources
If there is an official code release or third-party implementations, please also provide the information here, which would be very helpful.

Additional context
Add any other context or screenshots about the feature request here.
If you would like to implement the feature and create a PR, please leave a comment here and that would be much appreciated.

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.