GithubHelp home page GithubHelp logo

doutdex / yolov2-tensorflow-2.0 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jmpap/yolov2-tensorflow-2.0

0.0 1.0 0.0 90 MB

Just another YOLO V2 implementation. Train your own dataset in a jupyter notebook!

License: MIT License

Jupyter Notebook 100.00%

yolov2-tensorflow-2.0's Introduction

YOLO V2 with TensorFlow 2.0

Here is a jupyter notebook featuring a complete implementation from scratch of YOLOV2 with TensorFlow 2.0 :

  • Dataset pipeline with data augmentation
  • Training from YOLO pretrained weights
  • Visualization of object detection

I use this notebook to train a model to detect crop and weeds in a field. The goal is to detect crop in real time for tractor guidance and to detect weeds to remove them.

Original paper : YOLO9000: Better, Faster, Stronger by Joseph Redmond and Ali Farhadi.

Files

  • Yolo_V2_tf_2.ipynb : Yolo V2 implementation with Tensorflow 2.0
  • Yolo_V2_tf_eager.ipynb : old notebook, Yolo V2 implementation with Tensorflow 1.x with eager execution

Requirements

  • tensorflow 2.0
  • imgaug
  • cv2

Before using the notebook

  • Download pretrained weights here. Place this weights file in notebook directory and name it yolo.weights
  • The training requires four directories containing images and annotations :

train_image_folder/ : contains images files used during training (png format)

train_annot_folder/ : contains annotations in PASCAL VOC format (one xml file for each image)

val_image_folder/ : contains images files used for validation

val_annot_folder/ : contains annotations in PASCAL VOC format

Using the notebook

  • Define object's labels to detect (same labels as defined in PASCAL VOC xml file). Example :
	LABELS           = ('sugarbeet', 'weed')
  • Define image size in dataset and YOLO grid size. Image size must be YOLO grid size * 32.
	IMAGE_H, IMAGE_W = 512, 512
	GRID_H,  GRID_W  = 16, 16 # GRID size = IMAGE size / 32
  • Define train batch size and validation batch size : depends on image size and video card RAM.
	TRAIN_BATCH_SIZE = 10
	VAL_BATCH_SIZE   = 10
  • Define path to dataset directories.
	# Train and validation directories

	train_image_folder = 'data/train/image/'
	train_annot_folder = 'data/train/annotation/'
	val_image_folder = 'data/val/image/'
	val_annot_folder = 'data/val/annotation/'

That's it, just run notebook cells to train YOLO on your own data!

Example of use

YOLO model trained on sugarbeet and weed dataset (two labels) :

Credits

Many thanks to these great repositories:

https://github.com/experiencor/keras-yolo2

https://github.com/allanzelener/YAD2K

and to this very good explanation of the YOLO V2 loss function:

https://fairyonice.github.io/Part_4_Object_Detection_with_Yolo_using_VOC_2012_data_loss.html

yolov2-tensorflow-2.0's People

Contributors

jmpap avatar

Watchers

James Cloos 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.