def generate(self):
    model_path = os.path.expanduser(self.model_path)
    assert model_path.endswith('.h5'), 'Keras model or weights must be a .h5 file.'
    num_anchors = len(self.anchors)
    num_classes = len(self.class_names)
    try:
        self.yolo_model = load_model(model_path, compile=False)
    except:
        self.yolo_model = yolo_body(Input(shape=(None, None, 3)), (num_anchors // 3), num_classes)
        self.yolo_model.load_weights(self.model_path)
    else:
        assert (self.yolo_model.layers[(- 1)].output_shape[(- 1)] == ((num_anchors / len(self.yolo_model.output)) * (num_classes + 5))), 'Mismatch between model and given anchor and class sizes'
    print('{} model, anchors, and classes loaded.'.format(model_path))
    hsv_tuples = [((x / len(self.class_names)), 1.0, 1.0) for x in range(len(self.class_names))]
    self.colors = list(map((lambda x: colorsys.hsv_to_rgb(*x)), hsv_tuples))
    self.colors = list(map((lambda x: (int((x[0] * 255)), int((x[1] * 255)), int((x[2] * 255)))), self.colors))
    np.random.seed(10101)
    np.random.shuffle(self.colors)
    np.random.seed(None)
    self.input_image_shape = K.placeholder(shape=(2,))
    (boxes, scores, classes) = yolo_eval(self.yolo_model.output, self.anchors, num_classes, self.input_image_shape, score_threshold=self.score, iou_threshold=self.iou)
    return (boxes, scores, classes)
def generate(self):
    model_path = os.path.expanduser(self.model_path)
    assert model_path.endswith('.h5'), 'Keras model or weights must be a .h5 file.'
    num_anchors = len(self.anchors)
    num_classes = len(self.class_names)
    try:
        self.yolo_model = load_model(model_path, compile=False)
    except:
        self.yolo_model = yolo_body(Input(shape=(None, None, 3)), (num_anchors // 3), num_classes)
        self.yolo_model.load_weights(self.model_path)
    else:
        assert (self.yolo_model.layers[(- 1)].output_shape[(- 1)] == ((num_anchors / len(self.yolo_model.output)) * (num_classes + 5))), 'Mismatch between model and given anchor and class sizes'
    print('{} model, anchors, and classes loaded.'.format(model_path))
    hsv_tuples = [((x / len(self.class_names)), 1.0, 1.0) for x in range(len(self.class_names))]
    self.colors = list(map((lambda x: colorsys.hsv_to_rgb(*x)), hsv_tuples))
    self.colors = list(map((lambda x: (int((x[0] * 255)), int((x[1] * 255)), int((x[2] * 255)))), self.colors))
    np.random.seed(10101)
    np.random.shuffle(self.colors)
    np.random.seed(None)
    self.input_image_shape = K.placeholder(shape=(2,))
    (boxes, scores, classes) = yolo_eval(self.yolo_model.output, self.anchors, num_classes, self.input_image_shape, score_threshold=self.score, iou_threshold=self.iou)
    return (boxes, scores, classes)