bright1 commited on
Commit
449d1c8
1 Parent(s): 77e127e

Removed all files from git

Browse files
Files changed (6) hide show
  1. .gitattributes +0 -34
  2. Dockerfile +0 -11
  3. README.md +0 -10
  4. app.py +0 -104
  5. requirements.txt +0 -14
  6. utils.py +0 -54
.gitattributes DELETED
@@ -1,34 +0,0 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tflite filter=lfs diff=lfs merge=lfs -text
29
- *.tgz filter=lfs diff=lfs merge=lfs -text
30
- *.wasm filter=lfs diff=lfs merge=lfs -text
31
- *.xz filter=lfs diff=lfs merge=lfs -text
32
- *.zip filter=lfs diff=lfs merge=lfs -text
33
- *.zst filter=lfs diff=lfs merge=lfs -text
34
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Dockerfile DELETED
@@ -1,11 +0,0 @@
1
- FROM python:3.9
2
-
3
- WORKDIR /code
4
-
5
- COPY ./requirements.txt /code/requirements.txt
6
-
7
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
-
9
- COPY . .
10
-
11
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
 
 
 
 
 
 
README.md DELETED
@@ -1,10 +0,0 @@
1
- ---
2
- title: My Second Docker App
3
- emoji: 👁
4
- colorFrom: yellow
5
- colorTo: indigo
6
- sdk: docker
7
- pinned: false
8
- ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
app.py DELETED
@@ -1,104 +0,0 @@
1
- import streamlit as st
2
- import pandas as pd
3
- import numpy as np
4
- # from scipy.special import softmax
5
- # import os
6
- from utils import run_sentiment_analysis, preprocess
7
- from transformers import AutoTokenizer, AutoConfig,AutoModelForSequenceClassification
8
- import os
9
- import time
10
-
11
- # Requirements
12
- model_path = "bright1/fine-tuned-distilbert-base-uncased"
13
- tokenizer = AutoTokenizer.from_pretrained(model_path)
14
- config = AutoConfig.from_pretrained(model_path)
15
- model = AutoModelForSequenceClassification.from_pretrained(model_path)
16
-
17
- # dark_theme = set_theme()
18
-
19
-
20
- st.set_page_config(
21
- page_title="Tweet Analyzer",
22
- page_icon="🤖",
23
- initial_sidebar_state="expanded",
24
- menu_items={
25
- 'About': "# This is a header. This is an *extremely* cool app!"
26
- }
27
- )
28
-
29
-
30
- my_expander = st.container()
31
-
32
-
33
- # st.sidebar.selectbox('Menu', ['About', 'Model'])
34
- with my_expander:
35
-
36
- st.markdown("""
37
- <style>
38
- h1 {
39
- text-align: center;
40
- }
41
- </style>
42
- """, unsafe_allow_html=True)
43
- st.title(':green[Covid-19 Vaccines Tweets Analyzer]')
44
- st.sidebar.markdown("""
45
- ## Demo App
46
-
47
- This app analyzes your tweets on covid vaccines and classifies them us Neutral, Negative or Positive
48
- """)
49
- # my_expander.write('Container')
50
- # create a three column layout
51
-
52
- col1, col2, col3 = st.columns((1.6, 1,0.3))
53
- # col2.markdown("""
54
- # <p style= font-color:red>
55
- # Results from Analyzer
56
- # </p>
57
- # """,unsafe_allow_html=True)
58
- st.markdown("""
59
- <style>
60
- p {
61
- font-color: blue;
62
- }
63
- </style>
64
- """, unsafe_allow_html=True)
65
- tweet = col1.text_area('Tweets to analyze',height=200, max_chars=520, placeholder='Write your Tweets here')
66
- colA, colb, colc, cold = st.columns(4)
67
- clear_button = colA.button(label='Clear', type='secondary', use_container_width=True)
68
- submit_button = colb.button(label='Submit', type='primary', use_container_width=True)
69
- empty_container = col2.container()
70
- empty_container.text("Results from Analyzer")
71
- empty_container2 = col3.container()
72
- empty_container2.text('Scores')
73
- text = preprocess(tweet)
74
- results = run_sentiment_analysis(text=text, model=model, tokenizer=tokenizer)
75
- if submit_button:
76
- success_message = st.success('Success', icon="✅")
77
-
78
- with empty_container:
79
-
80
- neutral = st.progress(value=results['Neutral'], text='Neutral',)
81
- negative = st.progress(value=results['Negative'], text='Negative')
82
- positive = st.progress(value=results['Positive'], text='Positive')
83
- with empty_container2:
84
- st.markdown(
85
- """
86
- <style>
87
- [data-testid="stMetricValue"] {
88
- font-size: 20px;
89
- }
90
- </style>
91
- """,
92
- unsafe_allow_html=True,
93
- )
94
- neutral_score = st.metric(label='Score', value=round(results['Neutral'], 4), label_visibility='collapsed')
95
- negative_score = st.metric(label='Score', value=round(results['Negative'], 4), label_visibility='collapsed')
96
- positive_score = st.metric(label='Score', value=round(results['Positive'], 4), label_visibility='collapsed')
97
- time.sleep(5)
98
- success_message.empty()
99
- interpret_button = col2.button(label='Interpret',type='secondary', use_container_width=True)
100
-
101
-
102
- # st.help()
103
- # create a date input to receive date
104
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt DELETED
@@ -1,14 +0,0 @@
1
- streamlit==1.22.0
2
- nltk==3.8.1
3
- torch==2.0.0
4
- datasets==2.12.0
5
- numpy==1.22.4
6
- pandas==1.5.3
7
- session_info==1.0.0
8
- scikit-learn==1.2.2
9
- transformers==4.28.1
10
- IPython==7.34.0
11
- jupyter_client==6.1.12
12
- jupyter_core==5.3.0
13
- notebook==6.4.8
14
- uvicorn[standard]==0.17.*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
utils.py DELETED
@@ -1,54 +0,0 @@
1
- import numpy as np
2
- import pandas as pd
3
- from transformers import AutoTokenizer, AutoConfig,AutoModelForSequenceClassification
4
- from scipy.special import softmax
5
- import os
6
-
7
- # Requirements
8
- # model_path = "bright1/fine-tuned-distilbert-base-uncased"
9
- # tokenizer = AutoTokenizer.from_pretrained(model_path)
10
- # config = AutoConfig.from_pretrained(model_path)
11
- # model = AutoModelForSequenceClassification.from_pretrained(model_path)
12
-
13
-
14
-
15
- # def check_csv(csv_file, data):
16
- # if os.path.isfile(csv_file):
17
- # data.to_csv(csv_file, mode='a', header=False, index=False, encoding='utf-8')
18
- # else:
19
- # history = data.copy()
20
- # history.to_csv(csv_file, index=False)
21
-
22
- #Preprocess text
23
- def preprocess(text):
24
- new_text = []
25
- for t in text.split(" "):
26
- t = "@user" if t.startswith("@") and len(t) > 1 else t
27
- t = "http" if t.startswith("http") else t
28
- print(t)
29
- new_text.append(t)
30
- print(new_text)
31
-
32
- return " ".join(new_text)
33
-
34
- #Process the input and return prediction
35
- def run_sentiment_analysis(text, tokenizer, model):
36
- # save_text = {'tweet': text}
37
- encoded_input = tokenizer(text, return_tensors = "pt") # for PyTorch-based models
38
- output = model(**encoded_input)
39
- scores_ = output[0][0].detach().numpy()
40
- scores_ = softmax(scores_)
41
-
42
- # Format output dict of scores
43
- labels = ["Negative", "Neutral", "Positive"]
44
- scores = {l:float(s) for (l,s) in zip(labels, scores_) }
45
- # save_text.update(scores)
46
- # user_data = {key: [value] for key,value in save_text.items()}
47
- # data = pd.DataFrame(user_data,)
48
- # check_csv('history.csv', data)
49
- # hist_df = pd.read_csv('history.csv')
50
- return scores
51
-
52
-
53
-
54
-