Git Product home page Git Product logo

pytorch-yolo-v3-custom's Introduction

A Fork of PyTorch Implemation of YOLOv3 to Accomodate Custom Data

This fork is a work in progress and not ready for general use, yet. It will be noted here when this is working as expected and ready for broader use.

Status:

  • Fix the algorithm that, when evaluated with eval.py, returns the same results regardless of the input.

We love you COCO, but we have our own interests now.

This project is a "You Only Look Once" v3 sample using PyTorch, a fork of https://github.com/ayooshkathuria/pytorch-yolo-v3, with updates and improvements specifically for the Tiny architecture on custom data labeled with VoTT (versus the classic download of VOC or COCO data and labels). This fork allows the user to create their own dataset.

Note: This project is a work in progress and is based upon a research effort.

Setup

Collect and Label Data

  1. Use the VoTT labeling tool to create bounding boxes around objects of interest in images and export to YOLO format. The data output folder should be a subdirectory here with the images, labels and pointer file.
  2. If you wish to train on all labeled images, make sure they are all in the train.txt file (this is read by the customloader.py).

Train

Modifications for Custom

Filters

Ensure the yolov3-tiny.cfg is set up to train (see first lines of file). Note, the number of classes will affect the last convolutional layer filter numbers (conv layers before the yolo layer) as well as the yolo layers themselves - so will need to be modified manually to suit the needs of the user.

Modify the filter number of the CNN layer directly before each [yolo] layer to be: filters=(classes + 5)x3 in the 3. So, So if classes=1 then should be filters=18. If classes=2 then write filters=21, and so on.

Anchors

The tiny architecture has 6 anchors, whereas, the non-tiny or full sized YOLOv3 architecture has 9 anchors. These anchors should be manually discovered with kmeans.py and specified in the cfg file.

Run

Cmd:

python train.py --cfg cfg/yolov3-tiny.cfg --weights yolov3-tiny.weights --datacfg data/obj.data

Usage:

python train.py --help

Demo

Here, you will use your trained model in a live video feed. Ensure the yolov3-tiny.cfg is set up to test (see first lines of file). runs is where trained models get saved by default.

Run

Cmd:

python live.py --cfg cfg/yolov3-tiny.cfg --weights runs/<your trained model>.weights --datacfg data/obj.data --confidence 0.6

Usage:

python video_demo.py --help

Updates/Improvements

  • Custom data possibility
  • Clean up of several portions of code and generalizing/parameterizing

Helpful Definitions

  • YOLOv3: You Only Look Once v3. Improvments over v1, v2 and YOLO9000 which include Ref:
    • Predicts more bounding boxes per image (hence a bit slower)
    • Detections at 3 scales
    • Addressed issue of detecting small objects
    • New loss function (cross-entropy replaces squared error terms)
    • Can perform multi-label classification (no more mutually exclusive labels)
    • Performance on par with other architectures (a bit faster than SSD, even)
  • Tiny-YOLOv3: A reduced network architecture for smaller models designed for mobile, IoT and edge device scenarios
  • Anchors: There are 5 anchors per box. The anchor boxes are designed for a specific dataset using K-means clustering, i.e., a custom dataset must use K-means clustering to generate anchor boxes. It does not assume the aspect ratios or shapes of the boxes. Ref
  • Loss, loss.backward() and nn.MSELoss (for loss confidence): Mean Squared Error
  • IOU: intersection over union between predicted bounding boxes and ground truth boxes

The original YOLOv3 paper by Joseph Redmon and Ali Farhadi: https://arxiv.org/pdf/1804.02767.pdf

pytorch-yolo-v3-custom's People

Contributors

ayooshkathuria avatar michhar avatar ryoppippi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.