Пример #1
0
pos_input = Input(shape=(max_len, ))
pos_emb = Embedding(input_dim=len(pos), output_dim=10,
                    input_length=max_len)(pos_input)
modified_input = keras.layers.concatenate([word_emb, pos_emb])
model_1 = Bidirectional(
    LSTM(units=50, return_sequences=True,
         recurrent_dropout=0.1))(modified_input)
model = TimeDistributed(Dense(50, activation="relu"))(
    model_1)  # a dense layer as suggested by neuralNer
crf = CRF(n_tags)  # CRF layer
out = crf(model)  # output
model = Model([input, pos_input], out)
model.compile(optimizer="rmsprop",
              loss=crf.loss_function,
              metrics=[crf.accuracy])
model.load_weights("BILSTM+CRF_with_pos_without_embeddings.model")

nlp = spacy.load("en_core_web_sm")


# model1 = save_load_utils.load_all_weights('BILSTM+CRF_without_pos_without_embeddings.model')
# model2 = load_model('BILSTM+CRF_with_pos_without_embeddings.model,')
#model = load_model("BILSTM+CRF_with_pos_without_embeddings.model", custom_objects={'CRF': CRF, 'loss':fake_loss })
# (model,filename)
@app.route("/")
def hello():
    return "Hello World!"


@app.route("/model1/<sentence>")
def model1(sentence):