Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub import from_pretrained_fastai
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
repo_id = "pamunarr/P7EjOpc1-ModLen"
|
| 5 |
+
|
| 6 |
+
learner = from_pretrained_fastai(repo_id)
|
| 7 |
+
labels = ["World" , "Nigeria" , "Health" , "Africa" , "Politics"]
|
| 8 |
+
|
| 9 |
+
def predict(text):
|
| 10 |
+
_ , _ , probs = learner.predict(text)
|
| 11 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 12 |
+
|
| 13 |
+
gr.Interface(fn=predict, inputs="text", outputs=gr.components.Label(num_top_classes=5)).launch(share=False)
|