Update app.py
Browse files
app.py
CHANGED
@@ -9,9 +9,13 @@ import config
|
|
9 |
|
10 |
import gradio as gr
|
11 |
|
12 |
-
MODEL = None
|
13 |
DEVICE = config.device
|
14 |
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
T = tokenizer.TweetTokenizer(
|
17 |
preserve_handles=True, preserve_hashes=True, preserve_case=False, preserve_url=False)
|
@@ -59,15 +63,12 @@ def sentence_prediction(sentence):
|
|
59 |
# model_path, map_location=torch.device(device)))
|
60 |
# model.to(device)
|
61 |
|
62 |
-
outputs, [] = engine.predict_fn(test_data_loader,
|
63 |
print(outputs)
|
64 |
return {"label":outputs[0]}
|
65 |
|
66 |
if __name__ == "__main__":
|
67 |
-
|
68 |
-
MODEL.load_state_dict(torch.load(
|
69 |
-
config.MODEL_PATH, map_location=torch.device(DEVICE)))
|
70 |
-
MODEL.eval()
|
71 |
|
72 |
demo = gr.Interface(
|
73 |
fn=sentence_prediction,
|
|
|
9 |
|
10 |
import gradio as gr
|
11 |
|
|
|
12 |
DEVICE = config.device
|
13 |
|
14 |
+
MODEL = BERTBaseUncased()
|
15 |
+
MODEL.load_state_dict(torch.load(config.MODEL_PATH, map_location=torch.device(DEVICE)))
|
16 |
+
MODEL.eval()
|
17 |
+
|
18 |
+
|
19 |
|
20 |
T = tokenizer.TweetTokenizer(
|
21 |
preserve_handles=True, preserve_hashes=True, preserve_case=False, preserve_url=False)
|
|
|
63 |
# model_path, map_location=torch.device(device)))
|
64 |
# model.to(device)
|
65 |
|
66 |
+
outputs, [] = engine.predict_fn(test_data_loader, MODEL, device)
|
67 |
print(outputs)
|
68 |
return {"label":outputs[0]}
|
69 |
|
70 |
if __name__ == "__main__":
|
71 |
+
|
|
|
|
|
|
|
72 |
|
73 |
demo = gr.Interface(
|
74 |
fn=sentence_prediction,
|