Spaces:
Sleeping
Sleeping
File size: 901 Bytes
5a1764f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
from transformers import pipeline
import gradio as gr
MODEL_NAME = "textClasisif"
HF_USER = "universalml"
def prediction_function(input_file):
repo_id = HF_USER + "/" + MODEL_NAME
model = pipeline("text-classification", model=repo_id)
try:
result = model(input_file)
predictions = {}
labels = []
for each_label in result:
predictions[each_label["label"]] = each_label["score"]
labels.append(each_label["label"])
result = predictions
except:
result = "no data provided!!"
return result
def create_interface():
interface = gr.Interface(
fn=prediction_function,
inputs=gr.Textbox(label="Input text", type="text"),
outputs=gr.Label(num_top_classes=3),
title=MODEL_NAME,
)
interface.launch(debug=True)
create_interface()
|