CenterX 目标检测新网络(已开源)

作者:CPFLAME
项目代码:https://github.com/CPFLAME/centerX
项目介绍:https://zhuanlan.zhihu.com/p/323814368

在这里插入图片描述

CenterX

This repo is implemented based on detectron2 and CenterNet

What’s new

  • Support imgaug data augmentation
  • Support swa
  • Support Knowledge Distill, teacher-student, designed by myself
  • Support other LR_SCHEDULER
  • Support Optimizer RangerLars, not convergence in COCO
  • We provide some examples and scripts to convert centerX to Caffe, ONNX and TensorRT format in projects/speedup

What’s comming

  • [️✔] Support simple inference
  • [✔] Support to caffe, onnx, tensorRT
  • Support keypoints

Requirements

  • Python >= 3.7
  • PyTorch >= 1.5
  • torchvision that matches the PyTorch installation.
  • OpenCV
  • pycocotools
pip install cython; pip install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
  • GCC >= 4.9
gcc --version
  • detectron2
pip install -U 'git+https://github.com/CPFLAME/detectron2.git'
pip install git+https://github.com/pabloppp/pytorch-tools -U

Data prepare

the same as detectron2

Training

modify your yamls in run.sh

sh run.sh

Testing and Evaluation

modify your yamls in run.sh,
add eval-only and MODEL.WEIGHTS in your setting

sh run.sh

Performance

coco

This repo use less training time to get a competitive performance compared to other versions

Backbone ResNet-50

CodemAPepoch
centerX33.270
centerX34.3140
centernet-better34.9140

Backbone ResNet-18

centerX_KD means ResNet-50(33.2) as teacher, ResNet-18(27.9) as student, Knowledge Distill for 70 epoch in coco.

CodemAPepoch
centerX30.2140
centerX27.970
centerX_KD31.070
centernet-better29.8140
centernet28.1140

crowd human

  • optim: SGD
  • lr: 0.02
  • scheduler: WarmupMultiStepLR ,drop 0.1 in (50, 62) for 80 epoch; (90 ,120) for 140 epoch
  • train size: 512 max size
  • test size: 512 max size
  • batch size: 64
  • woGT: KD only use teacher loss
BackbonemAPmAP50mAP75epochteacherstudent_pretrain
resdcn1831.256.630.880--
resdcn18_swa31.156.630.480--
resdcn18_syncBN31.356.630.780--
resdcn18_imgaug29.654.728.980--
resdcn18_KD34.560.234.380resdcn50resdcn18
resdcn18_KD_woGT33.058.332.780resdcn50resdcn18
resdcn18_KD_woGT_scratch32.858.132.6140resdcn50imagenet
resdcn5035.161.235.380--

KD exp

crowd human KD

Generalization performance for Knowledge Distill

Backbonecrowd mAPcoco_person mAPepochteacherstudent_pretraintrain_set
resdcn5035.135.780--crowd
resdcn18(baseline)31.231.280--crowd
resdcn18_KD34.534.980resdcn50resdcn18crowd
resdcn18_KD_woGT_scratch32.834.2140resdcn50imagenetcrowd
resdcn18_KD_woGT_scratch34.136.3140resdcn50imagenetcrowd+coco

multi teacher KD

BackbonemAP crowdmAP coco_carepochteacherstudent_pretraintrain_set
1.resdcn5035.1-80--crowd
2.resdcn1831.7-70--crowd
3.resdcn50-31.670--coco_car
4.resdcn18-27.870--coco_car
resdcn18_KD_woGT_scratch31.629.41401,3imagenetcrowd+coco_car
BackbonemAP crowd_humanmAP widerfaceepochteacherstudent_pretraintrain_set
1.resdcn5035.1-80--crowd
2.resdcn1831.7-70--crowd
3.resdcn50-32.970--widerface
4.resdcn18-29.670--widerface
5.resdcn18_ignore_nolabel29.124.2140--crowd+wider
6.resdcn18_pseudo_label28.927.7140--crowd+wider
7.resdcn18_KD_woGT_scratch31.332.11401,3imagenetcrowd+wider

License

centerX is released under the Apache 2.0 license.

Acknowledgement

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用 YOLO(You Only Look Once)目标检测算法进行对象检测是一种常见的方法。下面是一些简单的步骤,来使用 C++ 实现 YOLO 目标检测。 1. 首先,你需要下载 YOLO 的权重文件和配置文件,这些文件可以从官方网站上下载得到。 2. 安装 OpenCV 库,该库是一个用于计算机视觉开源计算机视觉库,并且可以通过 C++ 进行使用。 3. 加载 YOLO 权重文件和配置文件,并初始化 YOLO 模型。 4. 读取图像,使用 YOLO 模型进行对象检测。YOLO 模型会返回每个检测到的对象的类别、位置以及置信度等信息。 5. 可以将检测结果保存到文件中,或者在图像上绘制框来可视化检测结果。 以下是一个简单的示例代码,展示如何使用 C++ 实现 YOLO 目标检测。 ```c++ #include <opencv2/opencv.hpp> #include <iostream> using namespace cv; using namespace std; int main() { // 加载 YOLO 权重文件和配置文件 String weights = "yolov3.weights"; String cfg = "yolov3.cfg"; dnn::Net net = dnn::readNetFromDarknet(cfg, weights); // 初始化 YOLO 模型 net.setPreferableBackend(dnn::DNN_BACKEND_OPENCV); net.setPreferableTarget(dnn::DNN_TARGET_CPU); // 读取图像 Mat image = imread("test.jpg"); // 使用 YOLO 模型进行对象检测 Mat inputBlob = dnn::blobFromImage(image, 1 / 255.0, Size(416, 416), Scalar(0, 0, 0), true, false); net.setInput(inputBlob); vector<Mat> outs; net.forward(outs, net.getUnconnectedOutLayersNames()); float confThreshold = 0.5; vector<int> classIds; vector<float> confidences; vector<Rect> boxes; for (size_t i = 0; i < outs.size(); ++i) { // 解析 YOLO 模型的输出 float* data = (float*)outs[i].data; for (int j = 0; j < outs[i].rows; ++j, data += outs[i].cols) { Mat scores = outs[i].row(j).colRange(5, outs[i].cols); Point classIdPoint; double confidence; minMaxLoc(scores, 0, &confidence, 0, &classIdPoint); if (confidence > confThreshold) { int centerX = (int)(data[0] * image.cols); int centerY = (int)(data[1] * image.rows); int width = (int)(data[2] * image.cols); int height = (int)(data[3] * image.rows); int left = centerX - width / 2; int top = centerY - height / 2; classIds.push_back(classIdPoint.x); confidences.push_back((float)confidence); boxes.push_back(Rect(left, top, width, height)); } } } // 可视化检测结果 vector<String> classNames = {"person", "car", "truck", "bus", "motorbike"}; for (size_t i = 0; i < boxes.size(); ++i) { Rect box = boxes[i]; rectangle(image, box, Scalar(0, 0, 255), 2); int classId = classIds[i]; String label = format("%.2f %s", confidences[i], classNames[classId].c_str()); int baseline; Size labelSize = getTextSize(label, FONT_HERSHEY_SIMPLEX, 0.5, 1, &baseline); rectangle(image, Point(box.x, box.y - labelSize.height - baseline), Point(box.x + labelSize.width, box.y), Scalar(255, 255, 255), FILLED); putText(image, label, Point(box.x, box.y - baseline), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 0, 0)); } // 显示图像 imshow("YOLO Object Detection", image); waitKey(0); return 0; } ``` 在上面的代码中,我们使用 OpenCV 库进行了 YOLO 目标检测,并且绘制了检测结果。你可以自己尝试一下,看看能否成功运行代码。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值