Пример #1
0
    def __init__(self,
                 model_path,
                 tag_lookup_file=None,
                 vocabulary_lookup_file=None):
        self.tag_lookup_table = Lookuper.load_from_file(tag_lookup_file)
        self.vocabulary_lookup_table = Lookuper.load_from_file(
            vocabulary_lookup_file)

        super(KerasInferenceBase, self).__init__(model_path)
Пример #2
0
    def __init__(self, model_path, tag_lookup_file=None, vocabulary_lookup_file=None):
        # load model
        self.model_dir = model_path

        # TODO: temp bugfix
        self.model = tf.keras.models.load_model(model_path, custom_objects={"crf_accuracy": crf_accuracy, "sequence_span_accuracy": sequence_span_accuracy})
        self.predict_fn = self.model.predict

        self.tag_lookup_table = Lookuper.load_from_file(tag_lookup_file)
        self.vocabulary_lookup_table = Lookuper.load_from_file(vocabulary_lookup_file)
    def __init__(self,
                 model_path,
                 tag_lookup_file=None,
                 vocabulary_lookup_file=None):
        # load model
        self.model_dir = model_path

        # TODO: temp bugfix
        self.model = tf.keras.models.load_model(model_path)
        self.predict_fn = self.model.predict

        self.tag_lookup_table = Lookuper.load_from_file(tag_lookup_file)
        self.vocabulary_lookup_table = Lookuper.load_from_file(
            vocabulary_lookup_file)
Пример #4
0
    def load(cls, parameter: dict, asset_dir) -> "ProcessorBase":
        from seq2annotation.input import Lookuper

        lookup_table_registry = {}

        for instance_name in parameter["lookup_table"]:
            instance_asset = asset_dir / instance_name
            lookup_table_instance = Lookuper.load_from_file(instance_asset)

            lookup_table_registry[instance_name] = lookup_table_instance

        init_parameter = copy.deepcopy(parameter)
        init_parameter.pop("lookup_table")
        init_parameter["lookup_table_registry"] = lookup_table_registry

        self = cls(**init_parameter)

        return self