File size: 456 Bytes
318145a
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
from huggingface_hub import from_pretrained_fastai
import gradio as gr

repo_id = "pamunarr/P7EjOpc1-ModLen"

learner = from_pretrained_fastai(repo_id)
labels = ["World" , "Nigeria" , "Health" , "Africa" , "Politics"]

def predict(text):
    _ , _ , probs = learner.predict(text)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}

gr.Interface(fn=predict, inputs="text", outputs=gr.components.Label(num_top_classes=5)).launch(share=False)