示例#1
0
    def load(self, path_to_model, mode="cpu", verbose=0):
        if path_to_model == "latest":
            model_info = download_latest_model("TextDetector",
                                               self.get_classname(),
                                               mode=mode)
            path_to_model = model_info["path"]

        self.MODEL = load_model(path_to_model, compile=False)

        net_inp = self.MODEL.get_layer(
            name='{}'.format(self.MODEL.layers[0].name)).input
        net_out = self.MODEL.get_layer(
            name='{}'.format(self.MODEL.layers[-1].name)).output

        self.MODEL = Model(inputs=net_inp, outputs=net_out)

        if verbose:
            self.MODEL.summary()

        return self.MODEL
示例#2
0
    def load(self, path_to_model, mode="cpu", verbose = 0):
        if path_to_model =="latest":
            model_info = download_latest_model("TextDetector", self.get_classname(), mode=mode)
            path_to_model = model_info["path"]


        self.MODEL = load_model(path_to_model, compile=False)

        net_inp = self.MODEL.get_layer(name='the_input_{}'.format(type(self).__name__)).input
        net_out = self.MODEL.get_layer(name='softmax_{}'.format(type(self).__name__)).output

        self.MODEL = Model(input=net_inp, output=net_out)

        if verbose:
            self.MODEL.summary()

        # the loss calc occurs elsewhere, so use a dummy lambda func for the loss
        #sgd = SGD(lr=0.02, decay=1e-6, momentum=0.9, nesterov=True, clipnorm=5)
        #self.MODEL.compile(loss={'ctc': lambda y_true, y_pred: y_pred}, optimizer=sgd)

        return self.MODEL