Exemplo n.º 1
0
    def load_model(self, model_dir, is_default_model, is_scenario_model):
        if is_default_model:
            print('[INFO] Loading Default Model ...')

            model = None

            with open(model_dir + str('/cvexport.manifest')) as f:
                data = json.load(f)

            # FIXME to check whether we need to close the previous session
            if data['DomainType'] == 'ObjectDetection':
                model = ObjectDetection(data, model_dir, None)
                return model

        elif is_scenario_model:
            print('[INFO] Loading Default Model ...')
            with open(model_dir + '/labels.txt', 'r') as f:
                labels = [l.strip() for l in f.readlines()]
            model = ONNXRuntimeObjectDetection(model_dir + '/model.onnx',
                                               labels)

            return model

        else:
            print('[INFO] Loading Model ...')
            with open('model/labels.txt', 'r') as f:
                labels = [l.strip() for l in f.readlines()]
            model = ONNXRuntimeObjectDetection('model/model.onnx', labels)

            return model

        return None
    def load_model(self, model_dir, is_default_model, is_scenario_model):
        if is_default_model:
            print("[INFO] Loading Default Model ...")

            model = None

            with open(model_dir + str("/cvexport.manifest")) as f:
                data = json.load(f)

            # FIXME to check whether we need to close the previous session
            if data["DomainType"] == "ObjectDetection":
                model = ObjectDetection(data, model_dir, None)
                return model

        elif is_scenario_model:
            print("[INFO] Loading Default Model ...")
            with open(model_dir + "/labels.txt", "r") as f:
                labels = [l.strip() for l in f.readlines()]
            model = ONNXRuntimeObjectDetection(model_dir + "/model.onnx",
                                               labels)

            return model

        else:
            logger.info("Load Model ...")
            with open("model/labels.txt", "r") as f:
                labels = [l.strip() for l in f.readlines()]
            model = ONNXRuntimeObjectDetection("model/model.onnx", labels)
            logger.info("Load Model, success")

            return model

        return None
Exemplo n.º 3
0
def get_bear_detection_model():
    MODEL_FILENAME = 'Bear.onnx'
    LABELS_FILENAME = 'labels.txt'
    with open(LABELS_FILENAME, 'r') as f:
        labels = [l.strip() for l in f.readlines()]

    return ONNXRuntimeObjectDetection(MODEL_FILENAME, labels)