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
Pytorch implementation of the paper DocEnTr: An End-to-End Document Image Enhancement Transformer.

DocEnTR Description Pytorch implementation of the paper DocEnTr: An End-to-End Document Image Enhancement Transformer. This model is implemented on to

Mohamed Ali Souibgui 74 Jan 07, 2023
Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow

eXtreme Gradient Boosting Community | Documentation | Resources | Contributors | Release Notes XGBoost is an optimized distributed gradient boosting l

Distributed (Deep) Machine Learning Community 23.6k Dec 31, 2022
Lightweight mmm - Lightweight (Bayesian) Media Mix Model

Lightweight (Bayesian) Media Mix Model This is not an official Google product. L

Google 342 Jan 03, 2023
Implementation of Neural Style Transfer in Pytorch

PytorchNeuralStyleTransfer Code to run Neural Style Transfer from our paper Image Style Transfer Using Convolutional Neural Networks. Also includes co

Leon Gatys 396 Dec 01, 2022
This is a Pytorch implementation of paper: DropEdge: Towards Deep Graph Convolutional Networks on Node Classification

DropEdge: Towards Deep Graph Convolutional Networks on Node Classification This is a Pytorch implementation of paper: DropEdge: Towards Deep Graph Con

401 Dec 16, 2022
PAMI stands for PAttern MIning. It constitutes several pattern mining algorithms to discover interesting patterns in transactional/temporal/spatiotemporal databases

Introduction PAMI stands for PAttern MIning. It constitutes several pattern mining algorithms to discover interesting patterns in transactional/tempor

RAGE UDAY KIRAN 43 Jan 08, 2023
Official Pytorch Implementation of Unsupervised Image Denoising with Frequency Domain Knowledge

Unsupervised Image Denoising with Frequency Domain Knowledge (BMVC 2021 Oral) : Official Project Page This repository provides the official PyTorch im

Donggon Jang 12 Sep 26, 2022
CMUA-Watermark: A Cross-Model Universal Adversarial Watermark for Combating Deepfakes (AAAI2022)

CMUA-Watermark The official code for CMUA-Watermark: A Cross-Model Universal Adversarial Watermark for Combating Deepfakes (AAAI2022) arxiv. It is bas

50 Nov 26, 2022
Rafael Project- Classifying rockets to different types using data science algorithms.

Rocket-Classify Rafael Project- Classifying rockets to different types using data science algorithms. In this project we received data base with data

Hadassah Engel 5 Sep 18, 2021
Vit-ImageClassification - Pytorch ViT for Image classification on the CIFAR10 dataset

Vit-ImageClassification Introduction This project uses ViT to perform image clas

Kaicheng Yang 4 Jun 01, 2022
Code used to generate the results appearing in "Train longer, generalize better: closing the generalization gap in large batch training of neural networks"

Train longer, generalize better - Big batch training This is a code repository used to generate the results appearing in "Train longer, generalize bet

Elad Hoffer 145 Sep 16, 2022
Texture mapping with variational auto-encoders

vae-textures This is an experiment with using variational autoencoders (VAEs) to perform mesh parameterization. This was also my first project using J

Alex Nichol 41 May 24, 2022
Official repository of DeMFI (arXiv.)

DeMFI This is the official repository of DeMFI (Deep Joint Deblurring and Multi-Frame Interpolation). [ArXiv_ver.] Coming Soon. Reference Jihyong Oh a

Jihyong Oh 56 Dec 14, 2022
Unofficial PyTorch implementation of MobileViT.

MobileViT Overview This is a PyTorch implementation of MobileViT specified in "MobileViT: Light-weight, General-purpose, and Mobile-friendly Vision Tr

Chin-Hsuan Wu 348 Dec 23, 2022
Deploy a ML inference service on a budget in less than 10 lines of code.

BudgetML is perfect for practitioners who would like to quickly deploy their models to an endpoint, but not waste a lot of time, money, and effort trying to figure out how to do this end-to-end.

1.3k Dec 25, 2022
Deep Reinforcement Learning for Multiplayer Online Battle Arena

MOBA_RL Deep Reinforcement Learning for Multiplayer Online Battle Arena Prerequisite Python 3 gym-derk Tensorflow 2.4.1 Dotaservice of TimZaman Seed R

Dohyeong Kim 32 Dec 18, 2022
Simple Text-Generator with OpenAI gpt-2 Pytorch Implementation

GPT2-Pytorch with Text-Generator Better Language Models and Their Implications Our model, called GPT-2 (a successor to GPT), was trained simply to pre

Tae-Hwan Jung 775 Jan 08, 2023
GNN4Traffic - This is the repository for the collection of Graph Neural Network for Traffic Forecasting

GNN4Traffic - This is the repository for the collection of Graph Neural Network for Traffic Forecasting

564 Jan 02, 2023
DeepFill v1/v2 with Contextual Attention and Gated Convolution, CVPR 2018, and ICCV 2019 Oral

Generative Image Inpainting An open source framework for generative image inpainting task, with the support of Contextual Attention (CVPR 2018) and Ga

2.9k Dec 16, 2022
Spherical Confidence Learning for Face Recognition, accepted to CVPR2021.

Sphere Confidence Face (SCF) This repository contains the PyTorch implementation of Sphere Confidence Face (SCF) proposed in the CVPR2021 paper: Shen

Maths 70 Dec 09, 2022