def __init__(self): CONFIG = get_config("SSD_1") self.CONFIDENCE_THRESHOLD = CONFIG["confidence_threshold"] self.num_predictions = CONFIG["num_predictions"] self.show_class_label = CONFIG["show_class_label"] weights = CONFIG["weights_path"] self.class_names = list(CONFIG["labels"].keys()) self.THRESHS = CONFIG["labels"] args = { 'config': CONFIG["config"], 'weights': weights, 'label_maps': self.class_names, 'confidence_threshold': self.CONFIDENCE_THRESHOLD, 'num_predictions': self.num_predictions, 'show_class_label': self.show_class_label } with open(CONFIG["config"], "r") as config_file: config = json.load(config_file) self.input_size = config["model"]["input_size"] model, process_input_fn = inference_utils.inference_ssd_vgg16( config, args) model.load_weights(args["weights"]) self.model = model self.process_input_fn = process_input_fn
def __init__(self): CONFIG = get_config("yolov4") self.CONFIDENCE_THRESHOLD = CONFIG["confidence_threshold"] self.NMS_THRESHOLD = CONFIG["nms_threshold"] self.class_names = list(CONFIG["labels"].keys()) self.THRESHS = CONFIG["labels"] weights = CONFIG["weights_path"] model_config = CONFIG["cfg_path"] input_width = CONFIG["input_width"] input_height = CONFIG["input_height"] net = cv2.dnn.readNet(weights, model_config) model = cv2.dnn_DetectionModel(net) model.setInputParams(size=(input_width, input_height), scale=1 / 255, swapRB=True) self.model = model