Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ def predict_language(text, top_k=5):
|
|
20 |
probs = torch.nn.functional.softmax(logits, dim=-1).squeeze()
|
21 |
top_probs, top_indices = torch.topk(probs, top_k)
|
22 |
|
23 |
-
results = [f"{id2label[
|
24 |
return "\n".join(results)
|
25 |
|
26 |
# Create Gradio interface
|
|
|
20 |
probs = torch.nn.functional.softmax(logits, dim=-1).squeeze()
|
21 |
top_probs, top_indices = torch.topk(probs, top_k)
|
22 |
|
23 |
+
results = [f"{id2label[idx.item()]}: {prob:.4f}" for prob, idx in zip(top_probs, top_indices)]
|
24 |
return "\n".join(results)
|
25 |
|
26 |
# Create Gradio interface
|