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
Source code for CIKM 2021 paper for Relation-aware Heterogeneous Graph for User Profiling

RHGN Source code for CIKM 2021 paper for Relation-aware Heterogeneous Graph for User Profiling Dependencies torch==1.6.0 torchvision==0.7.0 dgl==0.7.1

Big Data and Multi-modal Computing Group, CRIPAC 6 Nov 29, 2022
Bi-level feature alignment for versatile image translation and manipulation (Under submission of TPAMI)

Bi-level feature alignment for versatile image translation and manipulation (Under submission of TPAMI) Preparation Clone the Synchronized-BatchNorm-P

Fangneng Zhan 12 Aug 10, 2022
Reference implementation for Structured Prediction with Deep Value Networks

Deep Value Network (DVN) This code is a python reference implementation of DVNs introduced in Deep Value Networks Learn to Evaluate and Iteratively Re

Michael Gygli 55 Feb 02, 2022
This repo holds code for TransUNet: Transformers Make Strong Encoders for Medical Image Segmentation

TransUNet This repo holds code for TransUNet: Transformers Make Strong Encoders for Medical Image Segmentation Usage

1.4k Jan 04, 2023
Simulation-based performance analysis of server-less Blockchain-enabled Federated Learning

Blockchain-enabled Server-less Federated Learning Repository containing the files used to reproduce the results of the publication "Blockchain-enabled

Francesc Wilhelmi 9 Sep 27, 2022
Official implementation of "SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers"

SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers Figure 1: Performance of SegFormer-B0 to SegFormer-B5. Project page

NVIDIA Research Projects 1.4k Dec 31, 2022
Solving reinforcement learning tasks which require language and vision

Multimodal Reinforcement Learning JAX implementations of the following multimodal reinforcement learning approaches. Dual-coding Episodic Memory from

Henry Prior 31 Feb 26, 2022
This is the official github repository of the Met dataset

The Met dataset This is the official github repository of the Met dataset. The official webpage of the dataset can be found here. What is it? This cod

Nikolaos-Antonios Ypsilantis 35 Dec 17, 2022
PyTorch implementation of "LayoutTransformer: Layout Generation and Completion with Self-attention"

PyTorch implementation of "LayoutTransformer: Layout Generation and Completion with Self-attention" to appear in ICCV 2021

Kamal Gupta 75 Dec 23, 2022
李云龙二次元风格化!打滚卖萌,使用了animeGANv2进行了视频的风格迁移

李云龙二次元风格化!一键star、fork,你也可以生成这样的团长! 打滚卖萌求star求fork! 0.效果展示 视频效果前往B站观看效果最佳:李云龙二次元风格化: github开源repo:李云龙二次元风格化 百度AIstudio开源地址,一键fork即可运行: 李云龙二次元风格化!一键fork

oukohou 44 Dec 04, 2022
Finding Donors for CharityML

Finding-Donors-for-CharityML - Investigated factors that affect the likelihood of charity donations being made based on real census data.

Moamen Abdelkawy 1 Dec 30, 2021
A best practice for tensorflow project template architecture.

A best practice for tensorflow project template architecture.

Mahmoud Gamal Salem 3.6k Dec 22, 2022
StyleSpace Analysis: Disentangled Controls for StyleGAN Image Generation

StyleSpace Analysis: Disentangled Controls for StyleGAN Image Generation Demo video: CVPR 2021 Oral: Single Channel Manipulation: Localized or attribu

Zongze Wu 267 Dec 30, 2022
Code for the AI lab course 2021/2022 of the University of Verona

AI-Lab Code for the AI lab course 2021/2022 of the University of Verona Set-Up the environment for the curse Download Anaconda for your System. Instal

Davide Corsi 5 Oct 19, 2022
Trax — Deep Learning with Clear Code and Speed

Trax — Deep Learning with Clear Code and Speed Trax is an end-to-end library for deep learning that focuses on clear code and speed. It is actively us

Google 7.3k Dec 26, 2022
Multi-modal Content Creation Model Training Infrastructure including the FACT model (AI Choreographer) implementation.

AI Choreographer: Music Conditioned 3D Dance Generation with AIST++ [ICCV-2021]. Overview This package contains the model implementation and training

Google Research 365 Dec 30, 2022
Software Platform for solving and manipulating multiparametric programs in Python

PPOPT Python Parametric OPtimization Toolbox (PPOPT) is a software platform for solving and manipulating multiparametric programs in Python. This pack

10 Sep 13, 2022
A pure PyTorch batched computation implementation of "CIF: Continuous Integrate-and-Fire for End-to-End Speech Recognition"

A pure PyTorch batched computation implementation of "CIF: Continuous Integrate-and-Fire for End-to-End Speech Recognition"

張致強 14 Dec 02, 2022
Convert game ISO and archives to CD CHD for emulation on Linux.

tochd Convert game ISO and archives to CD CHD for emulation. Author: Tuncay D. Source: https://github.com/thingsiplay/tochd Releases: https://github.c

Tuncay 20 Jan 02, 2023
FCN (Fully Convolutional Network) is deep fully convolutional neural network architecture for semantic pixel-wise segmentation

FCN_via_Keras FCN FCN (Fully Convolutional Network) is deep fully convolutional neural network architecture for semantic pixel-wise segmentation. This

Kento Watanabe 48 Aug 30, 2022