Spaces:
Running
Running
admchiem
commited on
Commit
·
d8e1c23
1
Parent(s):
ca36db7
Amélioration du texte de description et du titre
Browse files- __pycache__/inference.cpython-39.pyc +0 -0
- app.py +17 -5
- inference.py +4 -3
__pycache__/inference.cpython-39.pyc
ADDED
|
Binary file (4.72 kB). View file
|
|
|
app.py
CHANGED
|
@@ -1,16 +1,28 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from inference import model
|
| 3 |
|
| 4 |
def predict_intent(text):
|
| 5 |
result = model.predict(text)
|
| 6 |
-
return f"Intent: {result['intent']}\
|
| 7 |
|
| 8 |
iface = gr.Interface(
|
| 9 |
fn=predict_intent,
|
| 10 |
-
inputs=gr.Textbox(lines=2, placeholder="Enter a sentence..."),
|
| 11 |
outputs="text",
|
| 12 |
-
title="Intent & OOS Detector",
|
| 13 |
-
description="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
)
|
| 15 |
|
| 16 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from inference import model
|
| 3 |
|
| 4 |
def predict_intent(text):
|
| 5 |
result = model.predict(text)
|
| 6 |
+
return f"Intent: {result['intent']}\nConfidence: {result['confidence']}\nOOS Score: {result['oos_score']:.3f}"
|
| 7 |
|
| 8 |
iface = gr.Interface(
|
| 9 |
fn=predict_intent,
|
| 10 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter a sentence...", value="Do you know Roger?"),
|
| 11 |
outputs="text",
|
| 12 |
+
title="Intent Classifier & OOS Detector",
|
| 13 |
+
description="""
|
| 14 |
+
<span style="font-size: 18px;">Type a sentence and get its predicted intent or detect if it's out-of-scope.</span>
|
| 15 |
+
|
| 16 |
+
Supported intents include (not exhaustive): `weather`, `translate`, `play_music`,...
|
| 17 |
+
|
| 18 |
+
The output will include:
|
| 19 |
+
- The predicted intent (or `"oos"` if out-of-scope),
|
| 20 |
+
- The confidence score of the predicted intent (or `None` if out-of-scope),
|
| 21 |
+
- The OOS score (higher = more likely to be out-of-scope).
|
| 22 |
+
|
| 23 |
+
🇬🇧 This model was trained on English-only data.
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
)
|
| 27 |
|
| 28 |
iface.launch()
|
inference.py
CHANGED
|
@@ -146,6 +146,7 @@ model = IntentClassifierWithOOS(
|
|
| 146 |
device="cpu"
|
| 147 |
)
|
| 148 |
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
|
|
|
|
|
| 146 |
device="cpu"
|
| 147 |
)
|
| 148 |
|
| 149 |
+
if __name__ == "__main__":
|
| 150 |
+
# Test with a sample query
|
| 151 |
+
result = model.predict("Can you play some jazz music?")
|
| 152 |
+
print(result)
|