Spaces:
Runtime error
Runtime error
JulianHame
commited on
Commit
·
f6fe135
0
Parent(s):
Duplicate from JulianHame/sentiment-analysis-app
Browse files- .github/workflows/sync_to_huggingface.yml +20 -0
- README.md +14 -0
- app.py +45 -0
- requirements.txt +7 -0
.github/workflows/sync_to_huggingface.yml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Sync to Hugging Face hub
|
2 |
+
on:
|
3 |
+
push:
|
4 |
+
branches: [main]
|
5 |
+
|
6 |
+
# to run this workflow manually from the Actions tab
|
7 |
+
workflow_dispatch:
|
8 |
+
|
9 |
+
jobs:
|
10 |
+
sync-to-hub:
|
11 |
+
runs-on: ubuntu-latest
|
12 |
+
steps:
|
13 |
+
- uses: actions/checkout@v3
|
14 |
+
with:
|
15 |
+
fetch-depth: 0
|
16 |
+
lfs: true
|
17 |
+
- name: Push to hub
|
18 |
+
env:
|
19 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
20 |
+
run: git push --force https://JulianHame:$HF_TOKEN@huggingface.co/spaces/JulianHame/streamlit-application main
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Sentiment Analysis Application
|
3 |
+
emoji: 😻
|
4 |
+
colorFrom: red
|
5 |
+
colorTo: indigo
|
6 |
+
sdk: streamlit
|
7 |
+
sdk_version: 1.17.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
duplicated_from: JulianHame/sentiment-analysis-app
|
11 |
+
---
|
12 |
+
|
13 |
+
# CS482-project-streamlit-application
|
14 |
+
huggingface spaces deployment of a streamlit python application
|
app.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
st.title('Sentiment Analyser')
|
5 |
+
st.image("https://www.pngall.com/wp-content/uploads/5/Emotion-Transparent.png")
|
6 |
+
|
7 |
+
st.write("---")
|
8 |
+
st.header('Step 1 - Select a language model')
|
9 |
+
col1, col2 = st.columns(2)
|
10 |
+
|
11 |
+
selection = "N/A"
|
12 |
+
with col1:
|
13 |
+
selection = st.radio("Pick one of the four pre-trained models below:",
|
14 |
+
key = "modelChoice",
|
15 |
+
options = ["DistilBERT", "FinBERT", "SiEBERT", "Twitter-roBERTa"],
|
16 |
+
)
|
17 |
+
|
18 |
+
pipe = pipeline('sentiment-analysis')
|
19 |
+
if selection == "DistilBERT":
|
20 |
+
pipe = pipeline(model = "distilbert-base-uncased-finetuned-sst-2-english")
|
21 |
+
if selection == "FinBERT":
|
22 |
+
pipe = pipeline(model = "yiyanghkust/finbert-tone")
|
23 |
+
if selection == "Twitter-roBERTa":
|
24 |
+
pipe = pipeline(model = "cardiffnlp/twitter-roberta-base-sentiment-latest")
|
25 |
+
if selection == "SiEBERT":
|
26 |
+
pipe = pipeline(model = "siebert/sentiment-roberta-large-english")
|
27 |
+
|
28 |
+
with col2:
|
29 |
+
st.caption('DistilBERT - One of the most popular and widely-used language models. Labels text as POSITIVE or NEGATIVE. Developed by Hugging Face.')
|
30 |
+
st.caption('FinBERT - A finance-oriented model trained with analysis reports. Labels text as POSITIVE, NEGATIVE or NEUTRAL. Developed by yiyanghkust.')
|
31 |
+
st.caption('SiEBERT - A model trained on diverse text sources to improve generalization. Labels text as POSITIVE or NEGATIVE. Developed by siebert.')
|
32 |
+
st.caption('Twitter-roBERTa - A model trained on over 124M tweets. Labels text as POSITIVE, NEGATIVE or NEUTRAL. Developed by cardiffnlp.')
|
33 |
+
|
34 |
+
st.write("---")
|
35 |
+
st.header('Step 2 - Enter some text')
|
36 |
+
text = st.text_area('The sentiment of the text entered here will be determined based on the model you chose above.',
|
37 |
+
value = "It was the best of times, it was the worst of times.")
|
38 |
+
|
39 |
+
st.write("---")
|
40 |
+
st.header('Step 3 - View your results')
|
41 |
+
|
42 |
+
if text:
|
43 |
+
st.write('Model used: ', selection)
|
44 |
+
out = pipe(text)
|
45 |
+
st.json(out)
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
opencv-python-headless
|
3 |
+
numpy
|
4 |
+
easyocr
|
5 |
+
Pillow
|
6 |
+
torch
|
7 |
+
transformers
|