Spaces:
Sleeping
Sleeping
Add code formatting
Browse files
app.py
CHANGED
|
@@ -4,12 +4,13 @@ from keras.models import load_model
|
|
| 4 |
from keras_self_attention import SeqSelfAttention
|
| 5 |
import numpy as np
|
| 6 |
|
|
|
|
|
|
|
| 7 |
model = load_model("model.keras", custom_objects={"SeqSelfAttention": SeqSelfAttention})
|
|
|
|
| 8 |
with open("tokenizer.pckl", "rb") as file:
|
| 9 |
tokenizer = pickle.load(file)
|
| 10 |
|
| 11 |
-
l1, l2 = 10, 10
|
| 12 |
-
|
| 13 |
def classify(text: str, response: str):
|
| 14 |
question = list(tokenizer.texts_to_sequences([text.lower(),])[0])
|
| 15 |
answer = list(tokenizer.texts_to_sequences([response.lower(),])[0])
|
|
@@ -25,4 +26,4 @@ def classify(text: str, response: str):
|
|
| 25 |
return "Irrelevant "+str(prediction)
|
| 26 |
|
| 27 |
iface = gr.Interface(fn=classify, inputs=["text", "text"], outputs="text")
|
| 28 |
-
iface.launch()
|
|
|
|
| 4 |
from keras_self_attention import SeqSelfAttention
|
| 5 |
import numpy as np
|
| 6 |
|
| 7 |
+
|
| 8 |
+
l1, l2 = 10, 10
|
| 9 |
model = load_model("model.keras", custom_objects={"SeqSelfAttention": SeqSelfAttention})
|
| 10 |
+
|
| 11 |
with open("tokenizer.pckl", "rb") as file:
|
| 12 |
tokenizer = pickle.load(file)
|
| 13 |
|
|
|
|
|
|
|
| 14 |
def classify(text: str, response: str):
|
| 15 |
question = list(tokenizer.texts_to_sequences([text.lower(),])[0])
|
| 16 |
answer = list(tokenizer.texts_to_sequences([response.lower(),])[0])
|
|
|
|
| 26 |
return "Irrelevant "+str(prediction)
|
| 27 |
|
| 28 |
iface = gr.Interface(fn=classify, inputs=["text", "text"], outputs="text")
|
| 29 |
+
iface.launch()
|