Skip to content

Instantly share code, notes, and snippets.

@Jargon4072
Created September 25, 2019 13:47
Show Gist options
  • Save Jargon4072/e1ffdb272dbef7aaa14e4314ba905828 to your computer and use it in GitHub Desktop.
Save Jargon4072/e1ffdb272dbef7aaa14e4314ba905828 to your computer and use it in GitHub Desktop.
Yolov3_medium_2
def get_labels(labels_path):
# load the COCO class labels our YOLO model was trained on
#labelsPath = os.path.sep.join([yolo_path, "yolo_v3/coco.names"])
lpath=os.path.sep.join([yolo_path, labels_path])
LABELS = open(lpath).read().strip().split("\n")
return LABELS
def get_colors(LABELS):
# initialize a list of colors to represent each possible class label
np.random.seed(42)
COLORS = np.random.randint(0, 255, size=(len(LABELS), 3),dtype="uint8")
return COLORS
def get_weights(weights_path):
# derive the paths to the YOLO weights and model configuration
weightsPath = os.path.sep.join([yolo_path, weights_path])
return weightsPath
def get_config(config_path):
configPath = os.path.sep.join([yolo_path, config_path])
return configPath
def load_model(configpath,weightspath):
# load our YOLO object detector trained on COCO dataset (80 classes)
print("[INFO] loading YOLO from disk...")
net = cv2.dnn.readNetFromDarknet(configpath, weightspath)
return net
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment