Spaces:
Sleeping
Sleeping
| from transformers import pipeline | |
| import gradio as gr | |
| pipe = pipeline("text-classification" , model = "ProsusAI/finbert") | |
| def predict(input_text): | |
| predictions = pipe(input_text,top_k=3 ) | |
| out = {} | |
| for item in predictions: | |
| out[item["label"]] = item["score"] | |
| return out | |
| gradio_app = gr.Interface( | |
| predict, | |
| inputs=gr.Textbox(label="Write a text"), | |
| outputs=gr.Label(), | |
| title="Sentiment Analysis", | |
| live=True, | |
| allow_flagging="never", | |
| ) | |
| gradio_app.launch() |