Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,9 +9,13 @@ pipe = pipeline(
|
|
| 9 |
|
| 10 |
def predict(input_txt):
|
| 11 |
predictions = pipe(input_txt)[0] # Get first (and only) result
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# Convert list of dicts to a single dict
|
| 14 |
-
result = {pred['label']: pred['score'] for pred in predictions}
|
| 15 |
return result
|
| 16 |
|
| 17 |
gradio_app = gr.Interface(
|
|
|
|
| 9 |
|
| 10 |
def predict(input_txt):
|
| 11 |
predictions = pipe(input_txt)[0] # Get first (and only) result
|
| 12 |
+
label_map = {
|
| 13 |
+
'LABEL_0': 'SAFE',
|
| 14 |
+
'LABEL_1': 'QUESTIONABLE',
|
| 15 |
+
'LABEL_2': 'UNSAFE'
|
| 16 |
+
}
|
| 17 |
# Convert list of dicts to a single dict
|
| 18 |
+
result = {label_map[pred['label']]: pred['score'] for pred in predictions}
|
| 19 |
return result
|
| 20 |
|
| 21 |
gradio_app = gr.Interface(
|