import cv2
import numpy as np
# Load the pre-trained model
model = cv2.dnn.readNetFromDarknet('yolov3.cfg', 'yolov3.weights')
# Load the image
image = cv2.imread('image.jpg')
# Preprocess the image
blob = cv2.dnn.blobFromImage(image, 1/255, (416, 416), swapRB=True, crop=False)
# Set the input
model.setInput(blob)
# Forward pass through the network
output_layers_names = model.getUnconnectedOutLayersNames()
layer_outputs = model.forward(output_layers_names)
import cv2
import numpy as np
# Load the pre-trained model
model = cv2.dnn.readNetFromDarknet('yolov3.cfg', 'yolov3.weights')
# Load the image
image = cv2.imread('image.jpg')
# Preprocess the image
blob = cv2.dnn.blobFromImage(image, 1/255, (416, 416), swapRB=True, crop=False)
# Set the input
model.setInput(blob)
# Forward pass through the network
output_layers_names = model.getUnconnectedOutLayersNames()
layer_outputs = model.forward(output_layers_names)