Giter Club home page Giter Club logo

nanodet-opncv-dnn-cpp-python's Introduction

nanodet-opncv-dnn-cpp-python

用opencv部署nanodet目标检测,包含C++和python两种版本程序的实现, 使用opencv里的dnn模块加载网络模型,图像预处理和后处理模块是使用C++和python编程实现。 整个程序运行,不依赖任何深度学习框架, 在windows系统和ubuntu系统,在cpu和gpu机器上都能运行。

python版本的主程序是main_nanodet.py, c++版本的主程序是main.cpp

程序里提供输入图片尺寸320和416这两种选择,类别置信度阈值confThreshold,nms重叠率阈值nmsThreshold可自行调整

nanodet的后处理模块的解读,可以参阅我写的csdn博客文章 https://blog.csdn.net/nihate/article/details/113850913

nanodet-opncv-dnn-cpp-python's People

Contributors

hpc203 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

Watchers

 avatar  avatar  avatar  avatar

nanodet-opncv-dnn-cpp-python's Issues

when i use cv2.dnn.readNet() to read the onnx model, i have a question

when i use cv2.dnn.readNet() to read the onnx model, i have a question
(expected: 'shapes.depth() == CV_32S') where 'shapes.depth()' is 5(CV_32FC1)
must be equal to 'CV_32S' is 4(CV_32SC1) in void_cdecl cv::dnn::dnn4_v20200609::ONNXImporter::populateNet(class cv::dnn::dnn4_v20200609::Net), file D:\opencv_test\newbuild\opencv-master\modules\dnn\src\onnx\innx_importer.cpp, line 1442

error about cpp code

[ INFO:0] global C:\jenkins\workspace\OpenCV\OpenVINO\2021.2\build\windows\opencv\modules\dnn\src\onnx\onnx_importer.cpp (395) cv::dnn::dnn4_v20201117::ONNXImporter::populateNet DNN/ONNX: loading ONNX v6 model produced by 'pytorch':1.7. Number of nodes = 335, inputs = 1, outputs = 6

About NanoDet model config file

Hi,
Can you release your training model config file for reference?
Because I use netron check my model is only one output.
But your excellent model have six output.
Have you done any other processing on the model?
Following text is my training config file.

# nanodet-EfficientNet-Lite1_416
save_dir: workspace/RepVGG-A0-416
model:
  arch:
    name: OneStageDetector
    backbone:
      name: RepVGG
      arch: A0
      out_stages: [2,3,4]
      activation: ReLU
      last_channel: 512
      deploy: False
    fpn:
      name: PAN
      in_channels: [96, 192, 512]
      out_channels: 128
      start_level: 0
      num_outs: 3
    head:
      name: NanoDetHead
      num_classes: 1
      conv_type: Conv
      input_channel: 128
      feat_channels: 128
      stacked_convs: 2
      activation: ReLU
      share_cls_reg: True
      octave_base_scale: 8
      scales_per_octave: 1
      strides: [8, 16, 32]
      reg_max: 10
      norm_cfg:
        type: BN
      loss:
        loss_qfl:
          name: QualityFocalLoss
          use_sigmoid: True
          beta: 2.0
          loss_weight: 1.0
        loss_dfl:
          name: DistributionFocalLoss
          loss_weight: 0.25
        loss_bbox:
          name: GIoULoss
          loss_weight: 2.0
data:
  train:
    name: CocoDataset
    img_path: /nfs/Workspace/dataset/mscoco/images/train2017
    ann_path: /nfs/Workspace/dataset/mscoco/annotations/annotations/instances_train2017_person.json
    input_size: [416,416] #[w,h]
    keep_ratio: True
    pipeline:
      perspective: 0.0
      scale: [0.5, 1.5]
      stretch: [[1, 1], [1, 1]]
      rotation: 0
      shear: 0
      translate: 0.2
      flip: 0.5
      brightness: 0.2
      contrast: [0.6, 1.4]
      saturation: [0.5, 1.2]
      normalize: [[103.53, 116.28, 123.675], [57.375, 57.12, 58.395]]
  val:
    name: CocoDataset
    img_path: /nfs/Workspace/dataset/mscoco/images/val2017
    ann_path: /nfs/Workspace/dataset/mscoco/annotations/annotations/instances_val2017_person.json
    input_size: [416,416] #[w,h]
    keep_ratio: True
    pipeline:
      normalize: [[103.53, 116.28, 123.675], [57.375, 57.12, 58.395]]
device:
  gpu_ids: [0]
  workers_per_gpu: 1
  batchsize_per_gpu: 100
schedule:
#  resume:
#  load_model: YOUR_MODEL_PATH
  optimizer:
    name: SGD
    lr: 0.07
    momentum: 0.9
    weight_decay: 0.0001
  warmup:
    name: linear
    steps: 500
    ratio: 0.01
  total_epochs: 170
  lr_schedule:
    name: MultiStepLR
    milestones: [130,150,160,165]
    gamma: 0.1
  val_intervals: 5
evaluator:
  name: CocoDetectionEvaluator
  save_key: mAP

log:
  interval: 10

class_names: ['person']

And this is my model architecture output
mine

Here is the model architecture output you provided
nanodet_ros

Please help! Thanks a lot!

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.