Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. def get_labels(labels_path):
  2. # load the COCO class labels our YOLO model was trained on
  3. #labelsPath = os.path.sep.join([yolo_path, "yolo_v3/coco.names"])
  4. lpath=os.path.sep.join([yolo_path, labels_path])
  5. LABELS = open(lpath).read().strip().split("\n")
  6. return LABELS
  7.  
  8. def get_colors(LABELS):
  9. # initialize a list of colors to represent each possible class label
  10. np.random.seed(42)
  11. COLORS = np.random.randint(0, 255, size=(len(LABELS), 3),dtype="uint8")
  12. return COLORS
  13.  
  14. def get_weights(weights_path):
  15. # derive the paths to the YOLO weights and model configuration
  16. weightsPath = os.path.sep.join([yolo_path, weights_path])
  17. return weightsPath
  18.  
  19. def get_config(config_path):
  20. configPath = os.path.sep.join([yolo_path, config_path])
  21. return configPath
  22.  
  23. def load_model(configpath,weightspath):
  24. # load our YOLO object detector trained on COCO dataset (80 classes)
  25. print("[INFO] loading YOLO from disk...")
  26. net = cv2.dnn.readNetFromDarknet(configpath, weightspath)
  27. return net
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement