File size: 454 Bytes
1961c08
d615911
a4a7478
1961c08
d615911
 
4d20f8e
6f8a72b
4d20f8e
08831e4
017818e
ea3f038
08831e4
67bdbbf
1961c08
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import gradio as gr
import torch
from transformers import pipeline

device = 0 if torch.cuda.is_available() else -1

sentiment_pipeline = pipeline("text-classification", 
                              model="winain7788/bert-finetuned-sem_eval-english", 
                              device=device)

async def get_sentiment(text):
    return sentiment_pipeline([text])

demo = gr.Interface(fn=get_sentiment, inputs="text", outputs="json")

demo.launch()