EllyOkumuAzubi commited on
Commit
8bd8000
1 Parent(s): 092d8bb

First commit on app.py

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. app.py +56 -0
  3. requirements.txt +439 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .gitattributes/
app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from transformers import AutoModelForSequenceClassification
4
+ from transformers import TFAutoModelForSequenceClassification
5
+ from transformers import AutoTokenizer, AutoConfig
6
+ import numpy as np
7
+ from scipy.special import softmax
8
+
9
+
10
+ # setting up the requiremnts
11
+
12
+ model_path = f"mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis"
13
+ tokenizer = AutoTokenizer.from_pretrained('mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis')
14
+ config = AutoConfig.from_pretrained(model_path)
15
+ model = AutoModelForSequenceClassification.from_pretrained(model_path)
16
+
17
+ # Preprocess text (username and link placeholders)
18
+ def preprocess(text):
19
+ new_text = []
20
+ for t in text.split(" "):
21
+ t = '@user' if t.startswith('@') and len(t) > 1 else t
22
+ t = 'http' if t.startswith('http') else t
23
+ new_text.append(t)
24
+ return " ".join(new_text)
25
+
26
+ # Defining the main function
27
+ def sentiment_analysis(text):
28
+ text = preprocess(text)
29
+
30
+ # PyTorch-based models
31
+ encoded_input = tokenizer(text, return_tensors='pt')
32
+ output = model(**encoded_input)
33
+ scores_ = output[0][0].detach().numpy()
34
+ scores_ = softmax(scores_)
35
+
36
+ # Format output dict of scores
37
+ labels = ['Negative😢😢', 'Neutral', 'Positive😃😃']
38
+ scores = {l:float(s) for (l,s) in zip(labels, scores_) }
39
+
40
+ return scores
41
+
42
+ welcome_message = "Welcome to Team Paris tweets first shot Sentimental Analysis App 😃 😃 😃 😃 "
43
+ demo = gr.Interface(
44
+ fn=sentiment_analysis,
45
+ inputs=gr.Textbox(placeholder="Write your tweet here..."),
46
+ outputs="label",
47
+ interpretation="default",
48
+ examples=[["This is wonderful!"]],
49
+ title=welcome_message
50
+ )
51
+ demo.launch()
52
+ # def greet(name):
53
+ # return "Hello " + name + "!!"
54
+
55
+ # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
56
+ # iface.launch()
requirements.txt ADDED
@@ -0,0 +1,439 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ absl-py==1.4.0
2
+ aiofiles==23.1.0
3
+ aiohttp==3.8.4
4
+ aiosignal==1.3.1
5
+ alabaster==0.7.13
6
+ albumentations==1.2.1
7
+ altair==4.2.2
8
+ anyio==3.7.1
9
+ appdirs==1.4.4
10
+ argon2-cffi==21.3.0
11
+ argon2-cffi-bindings==21.2.0
12
+ array-record==0.4.0
13
+ arviz==0.15.1
14
+ astropy==5.2.2
15
+ astunparse==1.6.3
16
+ async-timeout==4.0.2
17
+ attrs==23.1.0
18
+ audioread==3.0.0
19
+ autograd==1.6.2
20
+ Babel==2.12.1
21
+ backcall==0.2.0
22
+ beautifulsoup4==4.11.2
23
+ bleach==6.0.0
24
+ blis==0.7.9
25
+ blosc2==2.0.0
26
+ bokeh==2.4.3
27
+ branca==0.6.0
28
+ build==0.10.0
29
+ CacheControl==0.13.1
30
+ cachetools==5.3.1
31
+ catalogue==2.0.8
32
+ certifi==2023.5.7
33
+ cffi==1.15.1
34
+ chardet==4.0.0
35
+ charset-normalizer==2.0.12
36
+ chex==0.1.7
37
+ click==8.1.4
38
+ click-plugins==1.1.1
39
+ cligj==0.7.2
40
+ cloudpickle==2.2.1
41
+ cmake==3.25.2
42
+ cmdstanpy==1.1.0
43
+ colorcet==3.0.1
44
+ colorlover==0.3.0
45
+ community==1.0.0b1
46
+ confection==0.1.0
47
+ cons==0.4.6
48
+ contextlib2==21.6.0
49
+ contourpy==1.1.0
50
+ convertdate==2.4.0
51
+ cufflinks==0.17.3
52
+ cvxopt==1.3.1
53
+ cvxpy==1.3.2
54
+ cycler==0.11.0
55
+ cymem==2.0.7
56
+ Cython==0.29.36
57
+ dask==2022.12.1
58
+ datascience==0.17.6
59
+ db-dtypes==1.1.1
60
+ dbus-python==1.2.16
61
+ debugpy==1.6.6
62
+ decorator==4.4.2
63
+ defusedxml==0.7.1
64
+ distributed==2022.12.1
65
+ dlib==19.24.2
66
+ dm-tree==0.1.8
67
+ docutils==0.16
68
+ dopamine-rl==4.0.6
69
+ duckdb==0.8.1
70
+ earthengine-api==0.1.358
71
+ easydict==1.10
72
+ ecos==2.0.12
73
+ editdistance==0.6.2
74
+ en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0-py3-none-any.whl#sha256=0964370218b7e1672a30ac50d72cdc6b16f7c867496f1d60925691188f4d2510
75
+ entrypoints==0.4
76
+ ephem==4.1.4
77
+ et-xmlfile==1.1.0
78
+ etils==1.3.0
79
+ etuples==0.3.9
80
+ exceptiongroup==1.1.2
81
+ fastai==2.7.12
82
+ fastapi==0.100.0
83
+ fastcore==1.5.29
84
+ fastdownload==0.0.7
85
+ fastjsonschema==2.17.1
86
+ fastprogress==1.0.3
87
+ fastrlock==0.8.1
88
+ ffmpy==0.3.1
89
+ filelock==3.12.2
90
+ Fiona==1.9.4.post1
91
+ firebase-admin==5.3.0
92
+ Flask==2.2.5
93
+ flatbuffers==23.5.26
94
+ flax==0.7.0
95
+ folium==0.14.0
96
+ fonttools==4.41.0
97
+ frozendict==2.3.8
98
+ frozenlist==1.4.0
99
+ fsspec==2023.6.0
100
+ future==0.18.3
101
+ gast==0.4.0
102
+ gcsfs==2023.6.0
103
+ GDAL==3.3.2
104
+ gdown==4.6.6
105
+ gensim==4.3.1
106
+ geographiclib==2.0
107
+ geopandas==0.13.2
108
+ geopy==2.3.0
109
+ gin-config==0.5.0
110
+ glob2==0.7
111
+ google==2.0.3
112
+ google-api-core==2.11.1
113
+ google-api-python-client==2.84.0
114
+ google-auth==2.17.3
115
+ google-auth-httplib2==0.1.0
116
+ google-auth-oauthlib==1.0.0
117
+ google-cloud-bigquery==3.10.0
118
+ google-cloud-bigquery-connection==1.12.1
119
+ google-cloud-bigquery-storage==2.22.0
120
+ google-cloud-core==2.3.3
121
+ google-cloud-datastore==2.15.2
122
+ google-cloud-firestore==2.11.1
123
+ google-cloud-functions==1.13.1
124
+ google-cloud-language==2.9.1
125
+ google-cloud-storage==2.8.0
126
+ google-cloud-translate==3.11.2
127
+ google-colab @ file:///colabtools/dist/google-colab-1.0.0.tar.gz#sha256=2e10bed2c625e2b3c507effd522aed50d6e1d6ff239e76c72dc797521ff859c0
128
+ google-crc32c==1.5.0
129
+ google-pasta==0.2.0
130
+ google-resumable-media==2.5.0
131
+ googleapis-common-protos==1.59.1
132
+ googledrivedownloader==0.4
133
+ gradio==3.37.0
134
+ gradio_client==0.2.10
135
+ graphviz==0.20.1
136
+ greenlet==2.0.2
137
+ grpc-google-iam-v1==0.12.6
138
+ grpcio==1.56.0
139
+ grpcio-status==1.48.2
140
+ gspread==3.4.2
141
+ gspread-dataframe==3.3.1
142
+ gym==0.25.2
143
+ gym-notices==0.0.8
144
+ h11==0.14.0
145
+ h5netcdf==1.2.0
146
+ h5py==3.8.0
147
+ holidays==0.28
148
+ holoviews==1.15.4
149
+ html5lib==1.1
150
+ httpcore==0.17.3
151
+ httpimport==1.3.0
152
+ httplib2==0.21.0
153
+ httpx==0.24.1
154
+ huggingface-hub==0.16.4
155
+ humanize==4.6.0
156
+ hyperopt==0.2.7
157
+ idna==3.4
158
+ imageio==2.25.1
159
+ imageio-ffmpeg==0.4.8
160
+ imagesize==1.4.1
161
+ imbalanced-learn==0.10.1
162
+ imgaug==0.4.0
163
+ importlib-resources==6.0.0
164
+ imutils==0.5.4
165
+ inflect==6.0.5
166
+ iniconfig==2.0.0
167
+ intel-openmp==2023.1.0
168
+ ipykernel==5.5.6
169
+ ipython==7.34.0
170
+ ipython-genutils==0.2.0
171
+ ipython-sql==0.4.1
172
+ ipywidgets==7.7.1
173
+ itsdangerous==2.1.2
174
+ jax==0.4.13
175
+ jaxlib @ https://storage.googleapis.com/jax-releases/cuda11/jaxlib-0.4.13+cuda11.cudnn86-cp310-cp310-manylinux2014_x86_64.whl#sha256=af30095a0adf342b837a0ed9607e13177ee66f4e654c031a383aa546cd21d815
176
+ jieba==0.42.1
177
+ Jinja2==3.1.2
178
+ joblib==1.3.1
179
+ jsonpickle==3.0.1
180
+ jsonschema==4.3.3
181
+ jupyter-client==6.1.12
182
+ jupyter-console==6.1.0
183
+ jupyter-server==1.24.0
184
+ jupyter_core==5.3.1
185
+ jupyterlab-pygments==0.2.2
186
+ jupyterlab-widgets==3.0.8
187
+ kaggle==1.5.15
188
+ keras==2.12.0
189
+ kiwisolver==1.4.4
190
+ langcodes==3.3.0
191
+ lazy_loader==0.3
192
+ libclang==16.0.0
193
+ librosa==0.10.0.post2
194
+ lightgbm==3.3.5
195
+ linkify-it-py==2.0.2
196
+ lit==16.0.6
197
+ llvmlite==0.39.1
198
+ locket==1.0.0
199
+ logical-unification==0.4.6
200
+ LunarCalendar==0.0.9
201
+ lxml==4.9.3
202
+ Markdown==3.4.3
203
+ markdown-it-py==2.2.0
204
+ MarkupSafe==2.1.3
205
+ matplotlib==3.7.1
206
+ matplotlib-inline==0.1.6
207
+ matplotlib-venn==0.11.9
208
+ mdit-py-plugins==0.3.3
209
+ mdurl==0.1.2
210
+ miniKanren==1.0.3
211
+ missingno==0.5.2
212
+ mistune==0.8.4
213
+ mizani==0.8.1
214
+ mkl==2019.0
215
+ ml-dtypes==0.2.0
216
+ mlxtend==0.22.0
217
+ more-itertools==9.1.0
218
+ moviepy==1.0.3
219
+ mpmath==1.3.0
220
+ msgpack==1.0.5
221
+ multidict==6.0.4
222
+ multipledispatch==1.0.0
223
+ multitasking==0.0.11
224
+ murmurhash==1.0.9
225
+ music21==8.1.0
226
+ natsort==8.3.1
227
+ nbclient==0.8.0
228
+ nbconvert==6.5.4
229
+ nbformat==5.9.1
230
+ nest-asyncio==1.5.6
231
+ networkx==3.1
232
+ nibabel==3.0.2
233
+ nltk==3.8.1
234
+ notebook==6.4.8
235
+ numba==0.56.4
236
+ numexpr==2.8.4
237
+ numpy==1.22.4
238
+ oauth2client==4.1.3
239
+ oauthlib==3.2.2
240
+ opencv-contrib-python==4.7.0.72
241
+ opencv-python==4.7.0.72
242
+ opencv-python-headless==4.8.0.74
243
+ openpyxl==3.0.10
244
+ opt-einsum==3.3.0
245
+ optax==0.1.5
246
+ orbax-checkpoint==0.2.7
247
+ orjson==3.9.2
248
+ osqp==0.6.2.post8
249
+ packaging==23.1
250
+ palettable==3.3.3
251
+ pandas==1.5.3
252
+ pandas-datareader==0.10.0
253
+ pandas-gbq==0.17.9
254
+ pandocfilters==1.5.0
255
+ panel==0.14.4
256
+ param==1.13.0
257
+ parso==0.8.3
258
+ partd==1.4.0
259
+ pathlib==1.0.1
260
+ pathy==0.10.2
261
+ patsy==0.5.3
262
+ pexpect==4.8.0
263
+ pickleshare==0.7.5
264
+ Pillow==8.4.0
265
+ pip-tools==6.13.0
266
+ platformdirs==3.8.1
267
+ plotly==5.13.1
268
+ plotnine==0.10.1
269
+ pluggy==1.2.0
270
+ polars==0.17.3
271
+ pooch==1.6.0
272
+ portpicker==1.5.2
273
+ prefetch-generator==1.0.3
274
+ preshed==3.0.8
275
+ prettytable==0.7.2
276
+ proglog==0.1.10
277
+ progressbar2==4.2.0
278
+ prometheus-client==0.17.1
279
+ promise==2.3
280
+ prompt-toolkit==3.0.39
281
+ prophet==1.1.4
282
+ proto-plus==1.22.3
283
+ protobuf==3.20.3
284
+ psutil==5.9.5
285
+ psycopg2==2.9.6
286
+ ptyprocess==0.7.0
287
+ py-cpuinfo==9.0.0
288
+ py4j==0.10.9.7
289
+ pyarrow==9.0.0
290
+ pyasn1==0.5.0
291
+ pyasn1-modules==0.3.0
292
+ pycocotools==2.0.6
293
+ pycparser==2.21
294
+ pyct==0.5.0
295
+ pydantic==1.10.11
296
+ pydata-google-auth==1.8.1
297
+ pydot==1.4.2
298
+ pydot-ng==2.0.0
299
+ pydotplus==2.0.2
300
+ PyDrive==1.3.1
301
+ pydub==0.25.1
302
+ pyerfa==2.0.0.3
303
+ pygame==2.5.0
304
+ Pygments==2.14.0
305
+ PyGObject==3.36.0
306
+ pymc==5.1.2
307
+ PyMeeus==0.5.12
308
+ pymystem3==0.2.0
309
+ PyOpenGL==3.1.7
310
+ pyparsing==3.1.0
311
+ pyproj==3.6.0
312
+ pyproject_hooks==1.0.0
313
+ pyrsistent==0.19.3
314
+ PySocks==1.7.1
315
+ pytensor==2.10.1
316
+ pytest==7.2.2
317
+ python-apt==0.0.0
318
+ python-dateutil==2.8.2
319
+ python-louvain==0.16
320
+ python-multipart==0.0.6
321
+ python-slugify==8.0.1
322
+ python-utils==3.7.0
323
+ pytz==2022.7.1
324
+ pyviz-comms==2.3.2
325
+ PyWavelets==1.4.1
326
+ PyYAML==6.0
327
+ pyzmq==23.2.1
328
+ qdldl==0.1.7.post0
329
+ qudida==0.0.4
330
+ regex==2022.10.31
331
+ requests==2.27.1
332
+ requests-oauthlib==1.3.1
333
+ requests-unixsocket==0.2.0
334
+ requirements-parser==0.5.0
335
+ rich==13.4.2
336
+ rpy2==3.5.5
337
+ rsa==4.9
338
+ safetensors==0.3.1
339
+ scikit-image==0.19.3
340
+ scikit-learn==1.2.2
341
+ scipy==1.10.1
342
+ scs==3.2.3
343
+ seaborn==0.12.2
344
+ semantic-version==2.10.0
345
+ Send2Trash==1.8.2
346
+ shapely==2.0.1
347
+ six==1.16.0
348
+ sklearn-pandas==2.2.0
349
+ smart-open==6.3.0
350
+ sniffio==1.3.0
351
+ snowballstemmer==2.2.0
352
+ sortedcontainers==2.4.0
353
+ soundfile==0.12.1
354
+ soupsieve==2.4.1
355
+ soxr==0.3.5
356
+ spacy==3.5.4
357
+ spacy-legacy==3.0.12
358
+ spacy-loggers==1.0.4
359
+ Sphinx==3.5.4
360
+ sphinxcontrib-applehelp==1.0.4
361
+ sphinxcontrib-devhelp==1.0.2
362
+ sphinxcontrib-htmlhelp==2.0.1
363
+ sphinxcontrib-jsmath==1.0.1
364
+ sphinxcontrib-qthelp==1.0.3
365
+ sphinxcontrib-serializinghtml==1.1.5
366
+ SQLAlchemy==2.0.18
367
+ sqlparse==0.4.4
368
+ srsly==2.4.6
369
+ starlette==0.27.0
370
+ statsmodels==0.13.5
371
+ sympy==1.11.1
372
+ tables==3.8.0
373
+ tabulate==0.8.10
374
+ tblib==2.0.0
375
+ tenacity==8.2.2
376
+ tensorboard==2.12.3
377
+ tensorboard-data-server==0.7.1
378
+ tensorflow==2.12.0
379
+ tensorflow-datasets==4.9.2
380
+ tensorflow-estimator==2.12.0
381
+ tensorflow-gcs-config==2.12.0
382
+ tensorflow-hub==0.14.0
383
+ tensorflow-io-gcs-filesystem==0.32.0
384
+ tensorflow-metadata==1.13.1
385
+ tensorflow-probability==0.20.1
386
+ tensorstore==0.1.40
387
+ termcolor==2.3.0
388
+ terminado==0.17.1
389
+ text-unidecode==1.3
390
+ textblob==0.17.1
391
+ tf-slim==1.1.0
392
+ thinc==8.1.10
393
+ threadpoolctl==3.1.0
394
+ tifffile==2023.7.10
395
+ tinycss2==1.2.1
396
+ tokenizers==0.13.3
397
+ toml==0.10.2
398
+ tomli==2.0.1
399
+ toolz==0.12.0
400
+ torch @ https://download.pytorch.org/whl/cu118/torch-2.0.1%2Bcu118-cp310-cp310-linux_x86_64.whl#sha256=a7a49d459bf4862f64f7bc1a68beccf8881c2fa9f3e0569608e16ba6f85ebf7b
401
+ torchaudio @ https://download.pytorch.org/whl/cu118/torchaudio-2.0.2%2Bcu118-cp310-cp310-linux_x86_64.whl#sha256=26692645ea061a005c57ec581a2d0425210ac6ba9f923edf11cc9b0ef3a111e9
402
+ torchdata==0.6.1
403
+ torchsummary==1.5.1
404
+ torchtext==0.15.2
405
+ torchvision @ https://download.pytorch.org/whl/cu118/torchvision-0.15.2%2Bcu118-cp310-cp310-linux_x86_64.whl#sha256=19ca4ab5d6179bbe53cff79df1a855ee6533c2861ddc7389f68349d8b9f8302a
406
+ tornado==6.3.1
407
+ tqdm==4.65.0
408
+ traitlets==5.7.1
409
+ transformers==4.31.0
410
+ triton==2.0.0
411
+ tweepy==4.13.0
412
+ typer==0.9.0
413
+ types-setuptools==68.0.0.2
414
+ typing_extensions==4.7.1
415
+ tzlocal==5.0.1
416
+ uc-micro-py==1.0.2
417
+ uritemplate==4.1.1
418
+ urllib3==1.26.16
419
+ uvicorn==0.23.1
420
+ vega-datasets==0.9.0
421
+ wasabi==1.1.2
422
+ wcwidth==0.2.6
423
+ webcolors==1.13
424
+ webencodings==0.5.1
425
+ websocket-client==1.6.1
426
+ websockets==11.0.3
427
+ Werkzeug==2.3.6
428
+ widgetsnbextension==3.6.4
429
+ wordcloud==1.8.2.2
430
+ wrapt==1.14.1
431
+ xarray==2022.12.0
432
+ xarray-einstats==0.6.0
433
+ xgboost==1.7.6
434
+ xlrd==2.0.1
435
+ yarl==1.9.2
436
+ yellowbrick==1.5
437
+ yfinance==0.2.22
438
+ zict==3.0.0
439
+ zipp==3.16.1