Skip to content

Instantly share code, notes, and snippets.

@monogenea
Created Jun 19, 2021
Embed
What would you like to do?
#%% Load YOLOv3 COCO weights, configs and class IDs
# Import class names
with open('yolov3/coco.names', 'rt') as f:
classes = f.read().rstrip('\n').split('\n')
colors = np.random.randint(0, 255, (len(classes), 3))
# Give the configuration and weight files for the model and load the network using them
cfg = 'yolov3/yolov3.cfg'
weights = 'yolov3/yolov3.weights'
# Load model
model = cv2.dnn.readNetFromDarknet(cfg, weights)
# Extract names from output layers
layersNames = model.getLayerNames()
outputNames = [layersNames[i[0] - 1] for i in model.getUnconnectedOutLayers()]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment