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
Rax is a Learning-to-Rank library written in JAX

🦖 Rax: Composable Learning to Rank using JAX Rax is a Learning-to-Rank library written in JAX. Rax provides off-the-shelf implementations of ranking

Google 247 Dec 27, 2022
GestureSSD CBAM - A gesture recognition web system based on SSD and CBAM, using pytorch, flask and node.js

GestureSSD_CBAM A gesture recognition web system based on SSD and CBAM, using pytorch, flask and node.js SSD implementation is based on https://github

xue_senhua1999 2 Jan 06, 2022
DeepRec is a recommendation engine based on TensorFlow.

DeepRec Introduction DeepRec is a recommendation engine based on TensorFlow 1.15, Intel-TensorFlow and NVIDIA-TensorFlow. Background Sparse model is a

Alibaba 676 Jan 03, 2023
Code for Paper Predicting Osteoarthritis Progression via Unsupervised Adversarial Representation Learning

Predicting Osteoarthritis Progression via Unsupervised Adversarial Representation Learning (c) Tianyu Han and Daniel Truhn, RWTH Aachen University, 20

Tianyu Han 7 Nov 22, 2022
Expressive Body Capture: 3D Hands, Face, and Body from a Single Image

Expressive Body Capture: 3D Hands, Face, and Body from a Single Image [Project Page] [Paper] [Supp. Mat.] Table of Contents License Description Fittin

Vassilis Choutas 1.3k Jan 07, 2023
Functional deep learning

Pipeline abstractions for deep learning. Full documentation here: https://lf1-io.github.io/padl/ PADL: is a pipeline builder for PyTorch. may be used

LF1 101 Nov 09, 2022
Use unsupervised and supervised learning to predict stocks

AIAlpha: Multilayer neural network architecture for stock return prediction This project is meant to be an advanced implementation of stacked neural n

Vivek Palaniappan 1.5k Jan 06, 2023
Team Enigma at ArgMining 2021 Shared Task: Leveraging Pretrained Language Models for Key Point Matching

Team Enigma at ArgMining 2021 Shared Task: Leveraging Pretrained Language Models for Key Point Matching This is our attempt of the shared task on Quan

Manav Nitin Kapadnis 12 Jul 08, 2022
OpenMMLab Computer Vision Foundation

English | 简体中文 Introduction MMCV is a foundational library for computer vision research and supports many research projects as below: MMCV: OpenMMLab

OpenMMLab 4.6k Jan 09, 2023
Rapid experimentation and scaling of deep learning models on molecular and crystal graphs.

LitMatter A template for rapid experimentation and scaling deep learning models on molecular and crystal graphs. How to use Clone this repository and

Nathan Frey 32 Dec 06, 2022
Keras implementations of Generative Adversarial Networks.

This repository has gone stale as I unfortunately do not have the time to maintain it anymore. If you would like to continue the development of it as

Erik Linder-Norén 8.9k Jan 04, 2023
Pytorch implementation of the paper "Optimization as a Model for Few-Shot Learning"

Optimization as a Model for Few-Shot Learning This repo provides a Pytorch implementation for the Optimization as a Model for Few-Shot Learning paper.

Albert Berenguel Centeno 238 Jan 04, 2023
A library to inspect itermediate layers of PyTorch models.

A library to inspect itermediate layers of PyTorch models. Why? It's often the case that we want to inspect intermediate layers of a model without mod

archinet.ai 380 Dec 28, 2022
Code for "On the Effects of Batch and Weight Normalization in Generative Adversarial Networks"

Note: this repo has been discontinued, please check code for newer version of the paper here Weight Normalized GAN Code for the paper "On the Effects

Sitao Xiang 182 Sep 06, 2021
Official PyTorch implementation of "Camera Distance-aware Top-down Approach for 3D Multi-person Pose Estimation from a Single RGB Image", ICCV 2019

PoseNet of "Camera Distance-aware Top-down Approach for 3D Multi-person Pose Estimation from a Single RGB Image" Introduction This repo is official Py

Gyeongsik Moon 677 Dec 25, 2022
Transformer - Transformer in PyTorch

Transformer 完成进度 Embeddings and PositionalEncoding with example. MultiHeadAttent

Tianyang Li 1 Jan 06, 2022
Code accompanying "Adaptive Methods for Aggregated Domain Generalization"

Adaptive Methods for Aggregated Domain Generalization (AdaClust) Official Pytorch Implementation of Adaptive Methods for Aggregated Domain Generalizat

Xavier Thomas 15 Sep 20, 2022
Bayesian Inference Tools in Python

BayesPy Bayesian Inference Tools in Python Our goal is, given the discrete outcomes of events, estimate the distribution of categories. Using gradient

Max Sklar 99 Dec 14, 2022
Pytorch implementation of the DeepDream computer vision algorithm

deep-dream-in-pytorch Pytorch (https://github.com/pytorch/pytorch) implementation of the deep dream (https://en.wikipedia.org/wiki/DeepDream) computer

102 Dec 05, 2022
Info and sample codes for "NTU RGB+D Action Recognition Dataset"

"NTU RGB+D" Action Recognition Dataset "NTU RGB+D 120" Action Recognition Dataset "NTU RGB+D" is a large-scale dataset for human action recognition. I

Amir Shahroudy 578 Dec 30, 2022