P7_MecAt / app.py
pamunarr's picture
Update app.py
0eeb5fa verified
raw
history blame contribute delete
528 Bytes
from transformers import pipeline
import gradio as gr
repo_id = "pamunarr/P7EjOpc1-MecAt"
classifier = pipeline('text-classification', model=repo_id)
labels = {
"LABEL_0" : "World" , "LABEL_1" : "Nigeria" , "LABEL_2" : "Health" ,
"LABEL_3" : "Africa" , "LABEL_4" : "Politics"
}
def predict(text):
scores = classifier(text , top_k = 5)
return {labels[dicc["label"]] : dicc["score"] for dicc in scores}
gr.Interface(fn=predict, inputs="text", outputs=gr.components.Label(num_top_classes=5)).launch(share=False)