CenterNet:Objects as Points目标检测模型在Pytorch当中的实现

Overview

CenterNet:Objects as Points目标检测模型在Pytorch当中的实现


目录

  1. 性能情况 Performance
  2. 所需环境 Environment
  3. 注意事项 Attention
  4. 文件下载 Download
  5. 预测步骤 How2predict
  6. 训练步骤 How2train
  7. 参考资料 Reference

性能情况

训练数据集 权值文件名称 测试数据集 输入图片大小 mAP 0.5:0.95 mAP 0.5
VOC07+12 centernet_resnet50_voc.pth VOC-Test07 512x512 - 77.1
COCO-Train2017 centernet_hourglass_coco.pth COCO-Val2017 512x512 38.4 56.8

所需环境

torch==1.2.0

注意事项

代码中的centernet_resnet50_voc.pth是使用voc数据集训练的。
代码中的centernet_hourglass_coco.pth是使用coco数据集训练的。
注意不要使用中文标签,文件夹中不要有空格!
在训练前需要务必在model_data下新建一个txt文档,文档中输入需要分的类,在train.py中将classes_path指向该文件

文件下载

训练所需的centernet_resnet50_voc.pth、centernet_hourglass_coco.pth可在百度网盘中下载。
链接: https://pan.baidu.com/s/1QBBgRb_TH8kJdSCQGgcXmQ 提取码: phnc

centernet_resnet50_voc.pth是voc数据集的权重。
centernet_hourglass_coco.pth是coco数据集的权重。

预测步骤

a、使用预训练权重

  1. 下载完库后解压,在百度网盘下载centernet_resnet50_voc.pth或者centernet_hourglass_coco.pth,放入model_data,运行predict.py,输入
img/street.jpg
  1. 利用video.py可进行摄像头检测。

b、使用自己训练的权重

  1. 按照训练步骤训练。
  2. 在yolo.py文件里面,在如下部分修改model_path和classes_path使其对应训练好的文件;model_path对应logs文件夹下面的权值文件,classes_path是model_path对应分的类
_defaults = {
    "model_path"        : 'model_data/centernet_resnet50_voc.pth',
    "classes_path"      : 'model_data/voc_classes.txt',
    # "model_path"        : 'model_data/centernet_hourglass_coco.h5',
    # "classes_path"      : 'model_data/coco_classes.txt',
    "backbone"          : "resnet50",
    "image_size"        : [512,512,3],
    "confidence"        : 0.3,
    # backbone为resnet50时建议设置为True
    # backbone为hourglass时建议设置为False
    # 也可以根据检测效果自行选择
    "nms"               : True,
    "nms_threhold"      : 0.3,
    "cuda"              : True
}
  1. 运行predict.py,输入
img/street.jpg
  1. 利用video.py可进行摄像头检测。

训练步骤

  1. 本文使用VOC格式进行训练。
  2. 训练前将标签文件放在VOCdevkit文件夹下的VOC2007文件夹下的Annotation中。
  3. 训练前将图片文件放在VOCdevkit文件夹下的VOC2007文件夹下的JPEGImages中。
  4. 在训练前利用voc2centernet.py文件生成对应的txt。
  5. 再运行根目录下的voc_annotation.py,运行前需要将classes改成你自己的classes。注意不要使用中文标签,文件夹中不要有空格!
classes = ["aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"]
  1. 此时会生成对应的2007_train.txt,每一行对应其图片位置及其真实框的位置
  2. 在训练前需要务必在model_data下新建一个txt文档,文档中输入需要分的类,在train.py中将classes_path指向该文件,示例如下:
classes_path = 'model_data/new_classes.txt'    

model_data/new_classes.txt文件内容为:

cat
dog
...
  1. 运行train.py即可开始训练。

mAP目标检测精度计算更新

更新了get_gt_txt.py、get_dr_txt.py和get_map.py文件。
get_map文件克隆自https://github.com/Cartucho/mAP
具体mAP计算过程可参考:https://www.bilibili.com/video/BV1zE411u7Vw

Reference

https://github.com/xuannianz/keras-CenterNet
https://github.com/see--/keras-centernet
https://github.com/xingyizhou/CenterNet

Comments
  • map指标

    map指标

    B导,我在使用get_map.py的时候,您的初始设置confidence为0.02,我正常得到map结果,但是我像其他网络一样把confidence修改成为0.001以后就得不到map结果了,这是为什么呢? 还有就是想问一下,在计算voc的map时,confidence都应该设置为很低,所以是不是0.02和0.001的效果相似?谢谢b导

    opened by ChristmasLee 2
  • 训练没有归一化,预测却有归一化,是不是有问题?

    训练没有归一化,预测却有归一化,是不是有问题?

    训练时候加载数据是dataloader.py 222行,是没有对图片做mean和std归一化的,但预测时predict.py -> centernet.py -> util/util.py -> preprocess_input里却对图片做了mean、std归一化,这应该有问题吧?

    opened by seven-linglx 2
  • 显示no mudule named 'past'

    显示no mudule named 'past'

    Traceback (most recent call last): File "train.py", line 15, in from utils.callbacks import LossHistory File "/root/centernet/centernet-pytorch-main/utils/callbacks.py", line 9, in from torch.utils.tensorboard import SummaryWriter File "/root/.local/lib/python3.7/site-packages/torch/utils/tensorboard/init.py", line 6, in from .writer import FileWriter, SummaryWriter # noqa F401 File "/root/.local/lib/python3.7/site-packages/torch/utils/tensorboard/writer.py", line 18, in from ._convert_np import make_np File "/root/.local/lib/python3.7/site-packages/torch/utils/tensorboard/_convert_np.py", line 12, in from caffe2.python import workspace File "/root/.local/lib/python3.7/site-packages/caffe2/python/workspace.py", line 15, in from past.builtins import basestring

    opened by buloseshi 1
  • 请问我改mobilenetv3的时候运行到第7批次就自动停止了是怎么回事呢

    请问我改mobilenetv3的时候运行到第7批次就自动停止了是怎么回事呢

    Finish Validation 0%| | 0/119 [00:00<?, ?it/s]Get map. 0%| | 0/119 [00:00<?, ?it/s] Traceback (most recent call last): File "/home/linux/data2/sun/centernet-pytorch-main/train.py", line 491, in epoch_step, epoch_step_val, gen, gen_val, UnFreeze_Epoch, Cuda, fp16, scaler, backbone, save_period, save_dir, local_rank) File "/home/linux/data2/sun/centernet-pytorch-main/utils/utils_fit.py", line 161, in fit_one_epoch eval_callback.on_epoch_end(epoch + 1, model_train) File "/home/linux/data2/sun/centernet-pytorch-main/utils/callbacks.py", line 211, in on_epoch_end self.get_map_txt(image_id, image, self.class_names, self.map_out_path) File "/home/linux/data2/sun/centernet-pytorch-main/utils/callbacks.py", line 145, in get_map_txt outputs = decode_bbox(outputs[0], outputs[1], outputs[2], self.confidence, self.cuda) IndexError: list index out of range

    opened by sunsn1997 2
  • 第一次尝试的新手提问

    第一次尝试的新手提问

    image

    按照readme文档中的步骤 1 已解压VOC数据集至项目根目录,pth文件至model_data目录 2 已修改voc_annotation.py 中的annotation_mode为2 3 运行train.py

    环境 pytorch1.2 + cuda10.0 +python3.6 ,Ubuntu 刚开始是使用的高版本torch和python,然后也尝试了python3.6+ torch1.2的环境,出现一样的问题

    opened by Xie-Muxi 1
Releases(v3.0)
  • v3.0(Apr 22, 2022)

    重要更新

    • 支持step、cos学习率下降法。
    • 支持adam、sgd优化器选择。
    • 支持学习率根据batch_size自适应调整。
    • 支持不同预测模式的选择,单张图片预测、文件夹预测、视频预测、图片裁剪、heatmap、各个种类目标数量计算。
    • 更新summary.py文件,用于观看网络结构。
    • 增加了多GPU训练。
    Source code(tar.gz)
    Source code(zip)
  • v2.0(Mar 4, 2022)

    重要更新

    • 更新train.py文件,增加了大量的注释,增加多个可调整参数。
    • 更新predict.py文件,增加了大量的注释,增加fps、视频预测、批量预测等功能。
    • 更新centernet.py文件,增加了大量的注释,增加先验框选择、置信度、非极大抑制等参数。
    • 合并get_dr_txt.py、get_gt_txt.py和get_map.py文件,通过一个文件来实现数据集的评估。
    • 更新voc_annotation.py文件,增加多个可调整参数。
    • 更新summary.py文件,用于观看网络结构。
    Source code(tar.gz)
    Source code(zip)
Owner
Bubbliiiing
Bubbliiiing
Hybrid CenterNet - Hybrid-supervised object detection / Weakly semi-supervised object detection

Hybrid-Supervised Object Detection System Object detection system trained by hybrid-supervision/weakly semi-supervision (HSOD/WSSOD): This project is

null 5 Dec 10, 2022
Where2Act: From Pixels to Actions for Articulated 3D Objects

Where2Act: From Pixels to Actions for Articulated 3D Objects The Proposed Where2Act Task. Given as input an articulated 3D object, we learn to propose

Kaichun Mo 69 Nov 28, 2022
Automatically erase objects in the video, such as logo, text, etc.

Video-Auto-Wipe Read English Introduction:Here   本人不定期的基于生成技术制作一些好玩有趣的算法模型,这次带来的作品是“视频擦除”方向的应用模型,它实现的功能是自动感知到视频中我们不想看见的部分(譬如广告、水印、字幕、图标等等)然后进行擦除。由于图标擦

seeprettyface.com 141 Dec 26, 2022
Code for ACM MM 2020 paper "NOH-NMS: Improving Pedestrian Detection by Nearby Objects Hallucination"

NOH-NMS: Improving Pedestrian Detection by Nearby Objects Hallucination The offical implementation for the "NOH-NMS: Improving Pedestrian Detection by

Tencent YouTu Research 64 Nov 11, 2022
Unadversarial Examples: Designing Objects for Robust Vision

Unadversarial Examples: Designing Objects for Robust Vision This repository contains the code necessary to replicate the major results of our paper: U

Microsoft 93 Nov 28, 2022
A vision library for performing sliced inference on large images/small objects

SAHI: Slicing Aided Hyper Inference A vision library for performing sliced inference on large images/small objects Overview Object detection and insta

Open Business Software Solutions 2.3k Jan 4, 2023
DeFMO: Deblurring and Shape Recovery of Fast Moving Objects (CVPR 2021)

Evaluation, Training, Demo, and Inference of DeFMO DeFMO: Deblurring and Shape Recovery of Fast Moving Objects (CVPR 2021) Denys Rozumnyi, Martin R. O

Denys Rozumnyi 139 Dec 26, 2022
Segcache: a memory-efficient and scalable in-memory key-value cache for small objects

Segcache: a memory-efficient and scalable in-memory key-value cache for small objects This repo contains the code of Segcache described in the followi

TheSys Group @ CMU CS 78 Jan 7, 2023
Official PyTorch implementation of CAPTRA: CAtegory-level Pose Tracking for Rigid and Articulated Objects from Point Clouds

CAPTRA: CAtegory-level Pose Tracking for Rigid and Articulated Objects from Point Clouds Introduction This is the official PyTorch implementation of o

Yijia Weng 96 Dec 7, 2022
ManipulaTHOR, a framework that facilitates visual manipulation of objects using a robotic arm

ManipulaTHOR: A Framework for Visual Object Manipulation Kiana Ehsani, Winson Han, Alvaro Herrasti, Eli VanderBilt, Luca Weihs, Eric Kolve, Aniruddha

AI2 65 Dec 30, 2022
A DeepStack custom model for detecting common objects in dark/night images and videos.

DeepStack_ExDark This repository provides a custom DeepStack model that has been trained and can be used for creating a new object detection API for d

MOSES OLAFENWA 98 Dec 24, 2022
"SOLQ: Segmenting Objects by Learning Queries", SOLQ is an end-to-end instance segmentation framework with Transformer.

SOLQ: Segmenting Objects by Learning Queries This repository is an official implementation of the paper SOLQ: Segmenting Objects by Learning Queries.

MEGVII Research 179 Jan 2, 2023
Code for Discriminative Sounding Objects Localization (NeurIPS 2020)

Discriminative Sounding Objects Localization Code for our NeurIPS 2020 paper Discriminative Sounding Objects Localization via Self-supervised Audiovis

null 51 Dec 11, 2022
The code for the CVPR 2021 paper Neural Deformation Graphs, a novel approach for globally-consistent deformation tracking and 3D reconstruction of non-rigid objects.

Neural Deformation Graphs Project Page | Paper | Video Neural Deformation Graphs for Globally-consistent Non-rigid Reconstruction Aljaž Božič, Pablo P

Aljaz Bozic 134 Dec 16, 2022
RGB-D Local Implicit Function for Depth Completion of Transparent Objects

RGB-D Local Implicit Function for Depth Completion of Transparent Objects [Project Page] [Paper] Overview This repository maintains the official imple

NVIDIA Research Projects 43 Dec 12, 2022
Tooling for the Common Objects In 3D dataset.

CO3D: Common Objects In 3D This repository contains a set of tools for working with the Common Objects in 3D (CO3D) dataset. Download the dataset The

Facebook Research 724 Jan 6, 2023
Pytorch Implementation of Interaction Networks for Learning about Objects, Relations and Physics

Interaction-Network-Pytorch Pytorch Implementraion of Interaction Networks for Learning about Objects, Relations and Physics. Interaction Network is a

null 117 Nov 5, 2022
performing moving objects segmentation using image processing techniques with opencv and numpy

Moving Objects Segmentation On this project I tried to perform moving objects segmentation using background subtraction technique. the introduced meth

Mohamed Magdy 15 Dec 12, 2022
This repository contains a re-implementation of the code for the CVPR 2021 paper "Omnimatte: Associating Objects and Their Effects in Video."

Omnimatte in PyTorch This repository contains a re-implementation of the code for the CVPR 2021 paper "Omnimatte: Associating Objects and Their Effect

Erika Lu 728 Dec 28, 2022