Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import pickle
|
| 3 |
-
from transformers import pipeline
|
| 4 |
-
|
| 5 |
-
def load_model(selected_model):
|
| 6 |
-
with open(selected_model, 'rb') as file:
|
| 7 |
-
loaded_model = pickle.load(file)
|
| 8 |
-
return loaded_model
|
| 9 |
-
|
| 10 |
-
encoder = {
|
| 11 |
-
'negative':'assets/negative.jpg',
|
| 12 |
-
'neutral':'assets/neutral.jpg',
|
| 13 |
-
'positive':'assets/positive.jpeg'
|
| 14 |
-
}
|
| 15 |
-
|
| 16 |
-
classifier = pipeline(task="zero-shot-classification", model="facebook/bart-large-mnli")
|
| 17 |
-
def analyze_sentiment(text):
|
| 18 |
-
results = classifier(text,["positive","negative",'neutral'],multi_label=True)
|
| 19 |
-
mx = max(results['scores'])
|
| 20 |
-
ind = results['scores'].index(mx)
|
| 21 |
-
result = results['labels'][ind]
|
| 22 |
-
return encoder[result]
|
| 23 |
-
|
| 24 |
-
demo = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="image", title="Sentiment Analysis")
|
| 25 |
-
demo.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|