Spaces:
Sleeping
Sleeping
Upload 5 files
Browse files- app.py +24 -0
- c_intent_vectorizer +0 -0
- intent_classifier +0 -0
- intent_vectorizer +0 -0
- requirements.txt +0 -0
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import joblib
|
| 3 |
+
|
| 4 |
+
with open('intent_classifier', 'rb') as file:
|
| 5 |
+
model = joblib.load(file)
|
| 6 |
+
|
| 7 |
+
with open('c_intent_vectorizer', 'rb') as file:
|
| 8 |
+
vectorizer = joblib.load(file)
|
| 9 |
+
|
| 10 |
+
def preprocess_input(data):
|
| 11 |
+
tokens = data.lower().split()
|
| 12 |
+
filtered = [text for text in tokens if text.isalpha()]
|
| 13 |
+
return ' '.join(filtered)
|
| 14 |
+
|
| 15 |
+
def predict(text):
|
| 16 |
+
model_input = preprocess_input(text)
|
| 17 |
+
vectorized_input = vectorizer.transform([model_input])
|
| 18 |
+
prediction = model.predict(vectorized_input)
|
| 19 |
+
return prediction
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
demo = gr.Interface(fn=predict, inputs="textbox", outputs="textbox")
|
| 23 |
+
|
| 24 |
+
demo.launch()
|
c_intent_vectorizer
ADDED
|
Binary file (751 Bytes). View file
|
|
|
intent_classifier
ADDED
|
Binary file (1.78 kB). View file
|
|
|
intent_vectorizer
ADDED
|
Binary file (1.32 kB). View file
|
|
|
requirements.txt
ADDED
|
File without changes
|