imagesfolder that comes with the dataset are listed below.¶
Before using this notebook, please ensure that OpenCV and Pytorch packages are installed so that the Jupyter notebook can access it.
import cv2 import matplotlib.pyplot as plt from utils import * from darknet import Darknet
YOLOv3 is the version three of the YOLO system (YOLOv3 Paper). The neural network model architecture is stored in the
yolov3.cfg file, and the pre-trained weights of the neural network are stored in
yolov3.weights. There is a file called
coco.names that has the list of 80 object class that the model will be able to detect. The model has been trained only on these 80 object classes.
# Copy the neural network architecture cfg_file = 'yolov3.cfg' # Copy the pre-trained weights weight_file = 'yolov3.weights' # Copy the names of the classes namesfile = 'coco.names' # Load the neural network architecture m = Darknet(cfg_file) # Load the pre-trained weights m.load_weights(weight_file) # Load the names of the classes class_names = load_class_names(namesfile) ## You can visualize the neural network in YOLOv3 by uncommenting the following command # m.print_network()
Loading weights. Please Wait...100.00% Complete
imagesfolder and modify the name of the image below.¶
# Load the image img = cv2.imread('./images/manbike.jpg') # Converting the image to RGB original_image = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # Resizing the image resized_image = cv2.resize(original_image, (m.width, m.height)) # Display the images plt.subplot(121) plt.title('Input Image') plt.imshow(original_image) plt.subplot(122) plt.title('Resized Input Image') plt.imshow(resized_image) plt.show()