Created
June 19, 2021 10:57
-
-
Save monogenea/be8c7fba296acc6a0d86682248254639 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#%% 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