File size: 337 Bytes
1961c08
d615911
a4a7478
1961c08
d615911
 
 
08831e4
017818e
6aa1eb0
08831e4
b79d7c8
1961c08
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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()