Spaces:
Sleeping
Sleeping
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() | |