Skip to content

YOLO Algorithm (Yolov2 model) trained on COCO Dataset for Object Detection

License

Notifications You must be signed in to change notification settings

dabasajay/YOLO-Object-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YOLO Algorithm for Object Detection

Issues Forks Stars Ajay Dabas

In this project, I used YOLO algorithm trained on COCO dataset for object detection task. I used pretrained Yolov2 model which can downloaded from the official YOLO website.

Examples

Photo by Steffen Muldbjerg on Unsplash Photo by Alexander McFeron on Unsplash

Requirements

Recommended System Requirements to run model.

  • A good CPU and a GPU with atleast 4GB memory
  • Atleast 8GB of RAM
  • Active internet connection to download YOLOv2 weights and cfg file.

Required Libraries for Python along with their version numbers used while making & testing of this project

  • Python - 3.6.7
  • Numpy - 1.16.4
  • Tensorflow - 1.13.1
  • Keras - 2.2.4
  • PIL - 4.3.0

Some YOLOv2 Model information

  1. Total params: 50,983,561
  2. Trainable params: 50,962,889
  3. Non-trainable params: 20,672

How to Use

Just follow 6 simple steps :

  1. Clone repository to preserve directory structure
    git clone https://github.com/dabasajay/YOLO-Object-Detection.git
  2. Download Darknet model cfg and weights from the official YOLO website and put them in model_data/ folder.
    Direct terminal commands
    wget https://pjreddie.com/media/files/yolov2.weights
    mv yolov2.weights "model_data/yolov2.weights"
    wget https://github.com/pjreddie/darknet/raw/master/cfg/yolov2.cfg
    mv yolov2.cfg "model_data/yolov2.cfg"
  3. Review config.py for paths and other configurations (explained below)
  4. Run yad2k.py to convert YOLOv2 model from darknet to keras model which will be saved in model_data/ folder.
  5. Put all your images you want to test in images/ directory.
    Note: All images are resized to 608x608 to feed into YOLOv2 model
  6. Run YOLO.py and MAGIC! Output images will be saved in output/ directory

If you face any problem converting keras model or anything: email me at [email protected]

Acknowledgement: Script yad2k.py for conversion of darknet to keras model is taken from Allan Zelener - YAD2K: Yet Another Darknet 2 Keras github repo and modified a little bit.

Configurations (config.py)

  1. keras_model_path :- File path of keras converted yolov2 model in .hdf5 format
  2. model_weights :- File path of yolov2 weights file from darknet (Downloaded file)
  3. model_cfg :- File path of yolov2 configuration file from darknet (Downloaded file)
  4. anchors_path :- File path of yolo_anchors.txt
  5. classes_path :- File path of coco_classes.txt
  6. test_path :- Folder path containing images for testing model
  7. output_path :- Folder path containing output of images from test_path
  8. score_threshold :- Score(Confidence of predicted class) threshold. Lower value leads to more class predictions but less confident about predictions, higher leads to less class predictions but more confident about predictions.
  9. iou_threshold :- Intersection over union threshold.
  10. random_seed :- Random seed for reproducibility of results
  11. font_path :- File path of font to write on bounding boxes in image

References

The ideas presented in this repo came primarily from the two YOLO papers. The implementation here also took significant inspiration and used many components from Allan Zelener's github repository. The pretrained weights used in this project came from the official YOLO website.