Spaces:
Runtime error
Runtime error
Commit
·
fb22d07
0
Parent(s):
merge develop.milestone-3
Browse filesmerge containing work on the actual milestone-3 and the renaming of the folder for multi-object tracking to the correct name. No adjustment to the branches will be done to preserve the hf space settings.
- README.md +16 -0
- language_models_project/__init__.py +0 -0
- language_models_project/app.py +45 -0
- language_models_project/main.py +12 -0
- requirements.txt +156 -0
README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Milestone 2
|
| 3 |
+
emoji: 📹
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: red
|
| 6 |
+
sdk: streamlit
|
| 7 |
+
app_file: language_models_project/app.py
|
| 8 |
+
python_version: 3.10.4
|
| 9 |
+
pinned: false
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
# image2textapp
|
| 14 |
+
demo of 🤗 spaces deployment of a streamlit python app
|
| 15 |
+
|
| 16 |
+
deployed at https://huggingface.co/spaces/NativeVex/large-language-models
|
language_models_project/__init__.py
ADDED
|
File without changes
|
language_models_project/app.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st # Web App
|
| 2 |
+
from main import classify
|
| 3 |
+
|
| 4 |
+
demo_phrases = """ Here are some examples:
|
| 5 |
+
this is a phrase
|
| 6 |
+
is it neutral
|
| 7 |
+
nothing else to say
|
| 8 |
+
man I'm so damn angry
|
| 9 |
+
sarcasm lol
|
| 10 |
+
I love this product
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
# title
|
| 14 |
+
st.title("Sentiment Analysis")
|
| 15 |
+
|
| 16 |
+
# subtitle
|
| 17 |
+
st.markdown("## A selection of popular sentiment analysis models - hosted on 🤗 Spaces")
|
| 18 |
+
|
| 19 |
+
model_name = st.selectbox(
|
| 20 |
+
"Select a pre-trained model",
|
| 21 |
+
[
|
| 22 |
+
"finiteautomata/bertweet-base-sentiment-analysis",
|
| 23 |
+
"ahmedrachid/FinancialBERT-Sentiment-Analysis",
|
| 24 |
+
"finiteautomata/beto-sentiment-analysis",
|
| 25 |
+
],
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
input_sentences = st.text_area("Sentences", value=demo_phrases, height=200)
|
| 29 |
+
|
| 30 |
+
data = input_sentences.split("\n")
|
| 31 |
+
|
| 32 |
+
if st.button("Classify"):
|
| 33 |
+
st.write("Please allow a few minutes for the model to run/download")
|
| 34 |
+
for i in range(len(data)):
|
| 35 |
+
j = classify(model_name.strip(), data[i])[0]
|
| 36 |
+
sentiment = j["label"]
|
| 37 |
+
confidence = j["score"]
|
| 38 |
+
st.write(
|
| 39 |
+
f"{i}. {data[i]} :: Classification - {sentiment} with confidence {confidence}"
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
st.markdown(
|
| 44 |
+
"Link to the app - [image-to-text-app on 🤗 Spaces](https://huggingface.co/spaces/Amrrs/image-to-text-app)"
|
| 45 |
+
)
|
language_models_project/main.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 3 |
+
|
| 4 |
+
def classify(model_string: str, *args, **kwargs):
|
| 5 |
+
tokenizer = AutoTokenizer.from_pretrained(model_string)
|
| 6 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_string)
|
| 7 |
+
sentiment_pipeline = pipeline(
|
| 8 |
+
"sentiment-analysis",
|
| 9 |
+
model=model,
|
| 10 |
+
tokenizer=tokenizer
|
| 11 |
+
)
|
| 12 |
+
return sentiment_pipeline(*args, **kwargs)
|
requirements.txt
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
aiofiles==22.1.0
|
| 2 |
+
aiosqlite==0.18.0
|
| 3 |
+
antlr4-python3-runtime==4.9.3
|
| 4 |
+
anyconfig==0.10.1
|
| 5 |
+
anyio==3.6.2
|
| 6 |
+
argon2-cffi==21.3.0
|
| 7 |
+
argon2-cffi-bindings==21.2.0
|
| 8 |
+
arrow==1.2.3
|
| 9 |
+
asttokens==2.2.1
|
| 10 |
+
attrs==22.2.0
|
| 11 |
+
Babel==2.12.1
|
| 12 |
+
backcall==0.2.0
|
| 13 |
+
beautifulsoup4==4.12.2
|
| 14 |
+
binaryornot==0.4.4
|
| 15 |
+
bleach==6.0.0
|
| 16 |
+
build==0.10.0
|
| 17 |
+
cachetools==5.3.0
|
| 18 |
+
certifi==2022.12.7
|
| 19 |
+
cffi==1.15.1
|
| 20 |
+
chardet==5.1.0
|
| 21 |
+
charset-normalizer==3.1.0
|
| 22 |
+
click==8.1.3
|
| 23 |
+
cmake==3.26.1
|
| 24 |
+
comm==0.1.3
|
| 25 |
+
cookiecutter==2.1.1
|
| 26 |
+
debugpy==1.6.7
|
| 27 |
+
decorator==5.1.1
|
| 28 |
+
defusedxml==0.7.1
|
| 29 |
+
dynaconf==3.1.12
|
| 30 |
+
executing==1.2.0
|
| 31 |
+
fastjsonschema==2.16.3
|
| 32 |
+
filelock==3.11.0
|
| 33 |
+
fqdn==1.5.1
|
| 34 |
+
fsspec==2023.3.0
|
| 35 |
+
gitdb==4.0.10
|
| 36 |
+
GitPython==3.1.31
|
| 37 |
+
huggingface-hub==0.13.4
|
| 38 |
+
idna==3.4
|
| 39 |
+
importlib-metadata==6.2.1
|
| 40 |
+
importlib-resources==5.12.0
|
| 41 |
+
ipykernel==6.22.0
|
| 42 |
+
ipython==8.12.0
|
| 43 |
+
ipython-genutils==0.2.0
|
| 44 |
+
isoduration==20.11.0
|
| 45 |
+
jedi==0.18.2
|
| 46 |
+
Jinja2==3.1.2
|
| 47 |
+
jinja2-time==0.2.0
|
| 48 |
+
jmespath==0.10.0
|
| 49 |
+
json5==0.9.11
|
| 50 |
+
jsonpointer==2.3
|
| 51 |
+
jsonschema==4.17.3
|
| 52 |
+
jupyter-events==0.6.3
|
| 53 |
+
jupyter-ydoc==0.2.3
|
| 54 |
+
jupyter_client==8.1.0
|
| 55 |
+
jupyter_core==5.3.0
|
| 56 |
+
jupyter_server==2.5.0
|
| 57 |
+
jupyter_server_fileid==0.9.0
|
| 58 |
+
jupyter_server_terminals==0.4.4
|
| 59 |
+
jupyter_server_ydoc==0.8.0
|
| 60 |
+
jupyterlab==3.6.3
|
| 61 |
+
jupyterlab-pygments==0.2.2
|
| 62 |
+
jupyterlab_server==2.22.0
|
| 63 |
+
kedro==0.18.7
|
| 64 |
+
lit==16.0.0
|
| 65 |
+
markdown-it-py==2.2.0
|
| 66 |
+
MarkupSafe==2.1.2
|
| 67 |
+
matplotlib-inline==0.1.6
|
| 68 |
+
mdurl==0.1.2
|
| 69 |
+
mistune==2.0.5
|
| 70 |
+
more-itertools==9.1.0
|
| 71 |
+
mpmath==1.3.0
|
| 72 |
+
nbclassic==0.5.5
|
| 73 |
+
nbclient==0.7.3
|
| 74 |
+
nbconvert==7.3.0
|
| 75 |
+
nbformat==5.8.0
|
| 76 |
+
nest-asyncio==1.5.6
|
| 77 |
+
networkx==3.1
|
| 78 |
+
notebook==6.5.4
|
| 79 |
+
notebook_shim==0.2.2
|
| 80 |
+
numpy==1.24.2
|
| 81 |
+
nvidia-cublas-cu11==11.10.3.66
|
| 82 |
+
nvidia-cuda-cupti-cu11==11.7.101
|
| 83 |
+
nvidia-cuda-nvrtc-cu11==11.7.99
|
| 84 |
+
nvidia-cuda-runtime-cu11==11.7.99
|
| 85 |
+
nvidia-cudnn-cu11==8.5.0.96
|
| 86 |
+
nvidia-cufft-cu11==10.9.0.58
|
| 87 |
+
nvidia-curand-cu11==10.2.10.91
|
| 88 |
+
nvidia-cusolver-cu11==11.4.0.1
|
| 89 |
+
nvidia-cusparse-cu11==11.7.4.91
|
| 90 |
+
nvidia-nccl-cu11==2.14.3
|
| 91 |
+
nvidia-nvtx-cu11==11.7.91
|
| 92 |
+
omegaconf==2.3.0
|
| 93 |
+
packaging==23.0
|
| 94 |
+
pandas==2.0.0
|
| 95 |
+
pandocfilters==1.5.0
|
| 96 |
+
parso==0.8.3
|
| 97 |
+
pexpect==4.8.0
|
| 98 |
+
pickleshare==0.7.5
|
| 99 |
+
pip-tools==6.13.0
|
| 100 |
+
platformdirs==3.2.0
|
| 101 |
+
pluggy==1.0.0
|
| 102 |
+
prometheus-client==0.16.0
|
| 103 |
+
prompt-toolkit==3.0.38
|
| 104 |
+
protobuf==3.20.3
|
| 105 |
+
psutil==5.9.4
|
| 106 |
+
ptyprocess==0.7.0
|
| 107 |
+
pure-eval==0.2.2
|
| 108 |
+
pycparser==2.21
|
| 109 |
+
Pygments==2.14.0
|
| 110 |
+
pyproject_hooks==1.0.0
|
| 111 |
+
pyrsistent==0.19.3
|
| 112 |
+
python-dateutil==2.8.2
|
| 113 |
+
python-json-logger==2.0.7
|
| 114 |
+
python-slugify==8.0.1
|
| 115 |
+
pytoolconfig==1.2.5
|
| 116 |
+
pytz==2023.3
|
| 117 |
+
PyYAML==6.0
|
| 118 |
+
pyzmq==25.0.2
|
| 119 |
+
regex==2023.3.23
|
| 120 |
+
requests==2.28.2
|
| 121 |
+
rfc3339-validator==0.1.4
|
| 122 |
+
rfc3986-validator==0.1.1
|
| 123 |
+
rich==13.3.3
|
| 124 |
+
rope==1.7.0
|
| 125 |
+
Send2Trash==1.8.0
|
| 126 |
+
sentencepiece==0.1.97
|
| 127 |
+
six==1.16.0
|
| 128 |
+
smmap==5.0.0
|
| 129 |
+
sniffio==1.3.0
|
| 130 |
+
soupsieve==2.4
|
| 131 |
+
stack-data==0.6.2
|
| 132 |
+
sympy==1.11.1
|
| 133 |
+
terminado==0.17.1
|
| 134 |
+
text-unidecode==1.3
|
| 135 |
+
tinycss2==1.2.1
|
| 136 |
+
tokenizers==0.13.3
|
| 137 |
+
toml==0.10.2
|
| 138 |
+
tomli==2.0.1
|
| 139 |
+
toposort==1.10
|
| 140 |
+
torch==2.0.0
|
| 141 |
+
tornado==6.2
|
| 142 |
+
tqdm==4.65.0
|
| 143 |
+
traitlets==5.9.0
|
| 144 |
+
transformers==4.27.4
|
| 145 |
+
triton==2.0.0
|
| 146 |
+
typing_extensions==4.5.0
|
| 147 |
+
tzdata==2023.3
|
| 148 |
+
uri-template==1.2.0
|
| 149 |
+
urllib3==1.26.15
|
| 150 |
+
wcwidth==0.2.6
|
| 151 |
+
webcolors==1.13
|
| 152 |
+
webencodings==0.5.1
|
| 153 |
+
websocket-client==1.5.1
|
| 154 |
+
y-py==0.5.9
|
| 155 |
+
ypy-websocket==0.8.2
|
| 156 |
+
zipp==3.15.0
|