multi-label / app.py
winain7788's picture
fix bug
017818e
raw
history blame
337 Bytes
import gradio as gr
import torch
from transformers import pipeline
device = 0 if torch.cuda.is_available() else -1
sentiment_pipeline = pipeline("sentiment-analysis", device=device)
async def get_sentiment(text):
return sentiment_pipeline(text)
demo = gr.Interface(fn=get_sentiment, inputs="text", outputs="json")
demo.launch()