"nms_thres": 0.4, "img_size": 416, "device": device } classes = load_classes(yolo_params["class_path"]) #Colors cmap = plt.get_cmap("rainbow") colors = np.array([cmap(i) for i in np.linspace(0, 1, 13)]) #np.random.shuffle(colors) # model = 'yolo' detectron = YOLOv3Predictor(params=yolo_params) dir = "tests" for image in os.listdir(dir): path = os.path.join(dir, image) print(path) img = cv2.imread(path) detections = detectron.get_detections(img) if len(detections) != 0: detections.sort(reverse=False, key=lambda x: x[4]) for x1, y1, x2, y2, cls_conf, cls_pred in detections: print("Item: %s, Conf: %.5f" % (classes[int(cls_pred)], cls_conf)) color = colors[int(cls_pred)]
#Classes classes = load_classes(yolo_params["class_path"]) #Colors cmap = plt.get_cmap("tab20") colors = np.array([cmap(i) for i in np.linspace(0, 1, 20)]) np.random.shuffle(colors) #Faster RCNN / RetinaNet #model = 'faster' #detectron = Predictor(model='retinanet',dataset= dataset, CATEGORIES = classes) #YOLO yolo = YOLOv3Predictor(params=yolo_params) img = cv2.imread('galymzhan.jpeg') #detections = detectron.get_detections(img) detections = yolo.get_detections(img) #print(detections) unique_labels = np.array(list(set([det[-1] for det in detections]))) n_cls_preds = len(unique_labels) bbox_colors = colors[:n_cls_preds]