This repository contains the code to create and run a pretrained object detection model named YOLOv3. The model is trained on the MSCOCO dataset. The code is based pretty much in it's entirety on the GitHub repository keras-yolo3 created by the user experiencor.
I made some minor additions needed in order to be able to run it in my computer. I've also added a few example jpg images you can use to test out the model.
-
Download the pretrained weights to the model using the following link:
-
Run the yolo_prepare_model.py script in order to create the model.h5 file which will contain the model.
-
Use the yolo_predict.py script to make predictions on individual images. To do this correctly do the following steps:
i. Look at the labels variable in the script to see all the classes which the model was trained to predict.
ii. Download from Google Images an image of one of the classes (e.g., an image of an airplane or a sandwich) and save it in the same directory as the script. The image can be jpg or png. Also make sure that the image is in a size close to the 416x416 size expected by the model. Anything between 400 and 700 should work just fine.
iii. Look for the photo_filename variable in the yolo_predict.py script and change its value to a string with the name of the image you downloaded (e.g., photo_filename = 'sandwich.jpg').
iv. Run the yolo_predict.py script.
The outputs of the script will be your image with a bounding box around the object along with the label and confidence score.
That's all there is to it!