Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
! pip install datasets transformers
|
| 2 |
+
!apt install git-lfs
|
| 3 |
+
from huggingface_hub import notebook_login
|
| 4 |
+
import transformers
|
| 5 |
+
from datasets import load_dataset
|
| 6 |
+
from transformers import AutoModelForSequenceClassification
|
| 7 |
+
model = AutoModelForSequenceClassification.from_pretrained("DioLiu/autotrain-test-2940485233")
|
| 8 |
+
from transformers import AutoTokenizer
|
| 9 |
+
model_checkpoint = "distilbert-base-uncased"
|
| 10 |
+
tokenizer = AutoTokenizer.from_pretrained("DioLiu/autotrain-test-2940485233")
|
| 11 |
+
from transformers import pipeline
|
| 12 |
+
import gradio as gr
|
| 13 |
+
from transformers import pipeline
|
| 14 |
+
|
| 15 |
+
classifier = pipeline("sentiment-analysis",model=model,tokenizer=tokenizer)
|
| 16 |
+
def get_sentiment(input_text):
|
| 17 |
+
return classifier(input_text)
|
| 18 |
+
|
| 19 |
+
iface = gr.Interface(fn= get_sentiment, inputs="text", outputs = ["text"], title="Sentiment Analysis")
|
| 20 |
+
iface.launch(inline = False,share=True)
|