fix: JSON o/p instead of label
Browse files
app.py
CHANGED
@@ -13,18 +13,18 @@ def predict(text):
|
|
13 |
outputs = model(**inputs)
|
14 |
probs = outputs.logits.softmax(dim=-1)
|
15 |
pred_index = probs.argmax(dim=-1).item()
|
16 |
-
confidence_score = probs[0, pred_index]
|
17 |
id2label = model.config.id2label
|
18 |
pred_label = id2label[pred_index]
|
19 |
|
20 |
-
return {'topic': pred_label, 'confidence': confidence_score}
|
21 |
|
22 |
title = "URL content Topic Categorizer"
|
23 |
|
24 |
topic = gr.Interface(
|
25 |
fn=predict,
|
26 |
inputs='text',
|
27 |
-
outputs=
|
28 |
title=title,
|
29 |
)
|
30 |
|
|
|
13 |
outputs = model(**inputs)
|
14 |
probs = outputs.logits.softmax(dim=-1)
|
15 |
pred_index = probs.argmax(dim=-1).item()
|
16 |
+
confidence_score = probs[0, pred_index].item()
|
17 |
id2label = model.config.id2label
|
18 |
pred_label = id2label[pred_index]
|
19 |
|
20 |
+
return {'topic': pred_label, 'confidence': round(confidence_score, 4)}
|
21 |
|
22 |
title = "URL content Topic Categorizer"
|
23 |
|
24 |
topic = gr.Interface(
|
25 |
fn=predict,
|
26 |
inputs='text',
|
27 |
+
outputs= gr.JSON(),
|
28 |
title=title,
|
29 |
)
|
30 |
|