PyTorch implementation of the YOLO (You Only Look Once) v2

Overview

PyTorch implementation of the YOLO (You Only Look Once) v2

The YOLOv2 is one of the most popular one-stage object detector. This project adopts PyTorch as the developing framework to increase productivity, and utilize ONNX to convert models into Caffe 2 to benefit engineering deployment. If you are benefited from this project, a donation will be appreciated (via PayPal, 微信支付 or 支付宝).

Designs

  • Flexible configuration design. Program settings are configurable and can be modified (via configure file overlaping (-c/--config option) or command editing (-m/--modify option)) using command line argument.

  • Monitoring via TensorBoard. Such as the loss values and the debugging images (such as IoU heatmap, ground truth and predict bounding boxes).

  • Parallel model training design. Different models are saved into different directories so that can be trained simultaneously.

  • Using a NoSQL database to store evaluation results with multiple dimension of information. This design is useful when analyzing a large amount of experiment results.

  • Time-based output design. Running information (such as the model, the summaries (produced by TensorBoard), and the evaluation results) are saved periodically via a predefined time.

  • Checkpoint management. Several latest checkpoint files (.pth) are preserved in the model directory and the older ones are deleted.

  • NaN debug. When a NaN loss is detected, the running environment (data batch) and the model will be exported to analyze the reason.

  • Unified data cache design. Various dataset are converted into a unified data cache via corresponding cache plugins. Some plugins are already implemented. Such as PASCAL VOC and MS COCO.

  • Arbitrarily replaceable model plugin design. The main deep neural network (DNN) can be easily replaced via configuration settings. Multiple models are already provided. Such as Darknet, ResNet, Inception v3 and v4, MobileNet and DenseNet.

  • Extendable data preprocess plugin design. The original images (in different sizes) and labels are processed via a sequence of operations to form a training batch (images with the same size, and bounding boxes list are padded). Multiple preprocess plugins are already implemented. Such as augmentation operators to process images and labels (such as random rotate and random flip) simultaneously, operators to resize both images and labels into a fixed size in a batch (such as random crop), and operators to augment images without labels (such as random blur, random saturation and random brightness).

Feautures

  • Reproduce the original paper's training results.
  • Multi-scale training.
  • Dimension cluster.
  • Darknet model file (.weights) parser.
  • Detection from image and camera.
  • Processing Video file.
  • Multi-GPU supporting.
  • Distributed training.
  • Focal loss.
  • Channel-wise model parameter analyzer.
  • Automatically change the number of channels.
  • Receptive field analyzer.

Quick Start

This project uses Python 3. To install the dependent libraries, type the following command in a terminal.

sudo pip3 install -r requirements.txt

quick_start.sh contains the examples to perform detection and evaluation. Run this script. Multiple datasets and models (the original Darknet's format, will be converted into PyTorch's format) will be downloaded (aria2 is required). These datasets are cached into different data profiles, and the models are evaluated over the cached data. The models are used to detect objects in an example image, and the detection results will be shown.

License

This project is released as the open source software with the GNU Lesser General Public License version 3 (LGPL v3).

Comments
  • ImportError: cannot import name 'pystone' help

    ImportError: cannot import name 'pystone' help

    Traceback (most recent call last): File "detect.py", line 27, in import pybenchmark File "/home/a/anaconda3/lib/python3.6/site-packages/pybenchmark/init.py", line 1, in from .profile import profile, stats, kpystones, pystones File "/home/a/anaconda3/lib/python3.6/site-packages/pybenchmark/profile.py", line 3, in from test import pystone # native python-core "PYSTONE" Benchmark Program ImportError: cannot import name 'pystone'

    opened by 232824787 9
  • Error when convert darknet model to torch

    Error when convert darknet model to torch

    When convert the darknet yolo-voc weight to torch model, error occurs like this:

    Traceback (most recent call last):
      File "convert_darknet_torch.py", line 140, in <module>
        main()
      File "convert_darknet_torch.py", line 105, in main
        val = np.array(struct.unpack('%df' % cnt, f.read(cnt * 4)), np.float32)
    struct.error: unpack requires a bytes object of length 4096
    

    Because I only want to obtain a torch model and evaluate it by myself, I didn't run quick_start.sh to do dataset caching. The main steps are as following:

    First, I downloaded weight file from website of darknet and put it in $ROOT, which is $HOME/model/darknet:

    wget http://pjreddie.com/media/files/darknet19_448.conv.23
    

    And the command I used to convert the model is (just copied from the quick_start.sh script):

    python3 convert_darknet_torch.py ~/model/darknet/darknet19_448.conv.23 -m model/name=model_voc model/dnn=model.yolo2.Darknet -d --copy ~/model/darknet/darknet19_448.conv.23.pth
    

    And could you tell me the difference of darknet19_448.conv.23 and yolo-voc.weights? I tried to convert yolo-voc.weights and it worked well.

    opened by xmfbit 2
  • cache.py not enough values to unpack (expected 2, got 1)

    cache.py not enough values to unpack (expected 2, got 1)

    INFO:root:load voc dataset Traceback (most recent call last): File "cache.py", line 70, in main() File "cache.py", line 50, in main module, func = dataset.rsplit('.', 1) ValueError: not enough values to unpack (expected 2, got 1)

    opened by ghost 2
  • yolo2-pytorch/model_20/model.yolo2.Darknet.ini not found

    yolo2-pytorch/model_20/model.yolo2.Darknet.ini not found

    when i ran quick_start.sh,it show some warning. WARNING - training config (pre_model/yolo2-pytorch/model_20/model.yolo2.Darknet.ini) not found And i can't found model.yolo2.Darknet.ini in project.

    opened by QihuaCheng 1
  • Question on yolo backward function

    Question on yolo backward function

    Hi there, sorry about that to post this here, i was trying to write yolo in torch but struggled the backward function for so many days, but the gradients are always exploding slowly, could you kindly shed a light on my codes? Thank you so much.

    gradInput[{ {}, {}, 1, {}, {} }] = self.mse:backward(torch.cmul(self.x_buffer, x, coord_mask), tx)
    gradInput[{ {}, {}, 2, {}, {} }] = self.mse:backward(torch.cmul(self.y_buffer, y, coord_mask), ty)
    gradInput[{ {}, {}, 3, {}, {} }] = self.mse:backward(torch.cmul(self.w_buffer, w, coord_mask), tw)
    gradInput[{ {}, {}, 4, {}, {} }] = self.mse:backward(torch.cmul(self.h_buffer, h, coord_mask), th)
    gradInput[{ {}, {}, 5, {}, {} }] = self.mse:backward(torch.cmul(self.conf_buffer, conf, coord_mask), tconf)
    gradInput[{ {}, {}, { 6, 5 + nC }, {}, {} }][self.cls_mask] = self.ce:backward(torch.cmul(self.cls_buffer, cls), tcls)
    
    opened by shuieryin 0
  • Train with GTX 1080 and Anchor Boexes

    Train with GTX 1080 and Anchor Boexes

    Hi , Q1) Anchor_Boxes_Generator file generate 10 values of anchors , i have question about these values , as we have 5 anchors and this generator generate 10 values, more likely a first two of 10 values related to first anchor box , right ? if so , what are means of these two values ? W , H for first anchors for aspect ratio and scale for that anchor? Q2) Is it possible to fine-tuning this with one GTX 1080 (8G)?

    opened by PythonImageDeveloper 0
  • Caffe2 Deployment

    Caffe2 Deployment

    Great work on this setup.

    We can export the weights to Caffe2, but then how do we utilize the deployed weights in a Caffe2 instance on something like an nVidia Jetson TX2? There's no real Yolo2 for Caffe2, right?

    I'm confused as to why you're converting to Caffe2 and how that deployment would actually work.

    opened by lesreaper 0
  • Error happened when convert pretrained darknet model

    Error happened when convert pretrained darknet model

    When I convert pretrained darknet model with this command:

    python3 convert_darknet_torch.py ~/model/darknet/darknet19_448.conv.23 -m model/name=model_voc model/dnn=model.yolo2.Darknet -d --copy ~/model/darknet/darknet19_448.conv.23.pth

    error happened:

    Traceback (most recent call last): File "convert_darknet_torch.py", line 142, in main() File "convert_darknet_torch.py", line 107, in main val = np.array(struct.unpack('%df' % cnt, f.read(cnt * 4)), np.float32) struct.error: unpack requires a bytes object of length 4096

    opened by Brokenwind 0
Owner
申瑞珉 (Ruimin Shen)
申瑞珉 (Ruimin Shen)
You Only Hypothesize Once: Point Cloud Registration with Rotation-equivariant Descriptors

You Only Hypothesize Once: Point Cloud Registration with Rotation-equivariant Descriptors In this paper, we propose a novel local descriptor-based fra

Haiping Wang 80 Dec 15, 2022
Code for You Only Cut Once: Boosting Data Augmentation with a Single Cut

You Only Cut Once (YOCO) YOCO is a simple method/strategy of performing augmenta

null 88 Dec 28, 2022
LF-YOLO (Lighter and Faster YOLO) is used to detect defect of X-ray weld image.

This project is based on ultralytics/yolov3. LF-YOLO (Lighter and Faster YOLO) is used to detect defect of X-ray weld image. Download $ git clone http

null 26 Dec 13, 2022
Yolo ros - YOLO-ROS for HUAWEI ATLAS200

YOLO-ROS YOLO-ROS for NVIDIA YOLO-ROS for HUAWEI ATLAS200, please checkout for b

ChrisLiu 5 Oct 18, 2022
Yolo object detection - Yolo object detection with python

How to run download required files make build_image make download Docker versio

null 3 Jan 26, 2022
You Only Look One-level Feature (YOLOF), CVPR2021, Detectron2

You Only Look One-level Feature (YOLOF), CVPR2021 A simple, fast, and efficient object detector without FPN. This repo provides a neat implementation

qiang chen 273 Jan 3, 2023
A lane detection integrated Real-time Instance Segmentation based on YOLACT (You Only Look At CoefficienTs)

Real-time Instance Segmentation and Lane Detection This is a lane detection integrated Real-time Instance Segmentation based on YOLACT (You Only Look

Jin 4 Dec 30, 2022
Official implementation of "Not only Look, but also Listen: Learning Multimodal Violence Detection under Weak Supervision" ECCV2020

XDVioDet Official implementation of "Not only Look, but also Listen: Learning Multimodal Violence Detection under Weak Supervision" ECCV2020. The proj

peng 64 Dec 12, 2022
Based on Yolo's low-power, ultra-lightweight universal target detection algorithm, the parameter is only 250k, and the speed of the smart phone mobile terminal can reach ~300fps+

Based on Yolo's low-power, ultra-lightweight universal target detection algorithm, the parameter is only 250k, and the speed of the smart phone mobile terminal can reach ~300fps+

null 567 Dec 26, 2022
PyTorch implementation of the R2Plus1D convolution based ResNet architecture described in the paper "A Closer Look at Spatiotemporal Convolutions for Action Recognition"

R2Plus1D-PyTorch PyTorch implementation of the R2Plus1D convolution based ResNet architecture described in the paper "A Closer Look at Spatiotemporal

Irhum Shafkat 342 Dec 16, 2022
[CVPR2021] Look before you leap: learning landmark features for one-stage visual grounding.

LBYL-Net This repo implements paper Look Before You Leap: Learning Landmark Features For One-Stage Visual Grounding CVPR 2021. Getting Started Prerequ

SVIP Lab 45 Dec 12, 2022
a Pytorch easy re-implement of "YOLOX: Exceeding YOLO Series in 2021"

A pytorch easy re-implement of "YOLOX: Exceeding YOLO Series in 2021" 1. Notes This is a pytorch easy re-implement of "YOLOX: Exceeding YOLO Series in

null 91 Dec 26, 2022
pytorch, hand(object) detect ,yolo v5,手检测

YOLO V5 物体检测,包括手部检测。 项目介绍 手部检测 手部检测示例如下 : 视频示例: 项目配置 作者开发环境: Python 3.7 PyTorch >= 1.5.1 数据集 手部检测数据集 该项目数据集采用 TV-Hand 和 COCO-Hand (COCO-Hand-Big 部分) 进

Eric.Lee 11 Dec 20, 2022
A object detecting neural network powered by the yolo architecture and leveraging the PyTorch framework and associated libraries.

Yolo-Powered-Detector A object detecting neural network powered by the yolo architecture and leveraging the PyTorch framework and associated libraries

Luke Wilson 1 Dec 3, 2021
Object detection (YOLO) with pytorch, OpenCV and python

Real Time Object/Face Detection Using YOLO-v3 This project implements a real time object and face detection using YOLO algorithm. You only look once,

null 1 Aug 4, 2022
Implementation for the paper 'YOLO-ReT: Towards High Accuracy Real-time Object Detection on Edge GPUs'

YOLO-ReT This is the original implementation of the paper: YOLO-ReT: Towards High Accuracy Real-time Object Detection on Edge GPUs. Prakhar Ganesh, Ya

null 69 Oct 19, 2022
implementation of paper - You Only Learn One Representation: Unified Network for Multiple Tasks

YOLOR implementation of paper - You Only Learn One Representation: Unified Network for Multiple Tasks To reproduce the results in the paper, please us

Kin-Yiu, Wong 1.8k Jan 4, 2023
YOLTv4 builds upon YOLT and SIMRDWN, and updates these frameworks to use the most performant version of YOLO, YOLOv4

YOLTv4 builds upon YOLT and SIMRDWN, and updates these frameworks to use the most performant version of YOLO, YOLOv4. YOLTv4 is designed to detect objects in aerial or satellite imagery in arbitrarily large images that far exceed the ~600×600 pixel size typically ingested by deep learning object detection frameworks.

Adam Van Etten 161 Jan 6, 2023
Detection of drones using their thermal signatures from thermal camera through YOLO-V3 based CNN with modifications to encapsulate drone motion

Drone Detection using Thermal Signature This repository highlights the work for night-time drone detection using a using an Optris PI Lightweight ther

Chong Yu Quan 6 Dec 31, 2022