Spaces:
Sleeping
Sleeping
MarkAdamsMSBA24
commited on
Commit
•
94849c1
1
Parent(s):
ab60db9
Upload 2 files
Browse files- app.py +27 -0
- requirements.txt +278 -0
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
3 |
+
import torch
|
4 |
+
|
5 |
+
# Load the model and tokenizer
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained("MarkAdamsMSBA24/ADRv2024")
|
7 |
+
model = AutoModelForSequenceClassification.from_pretrained("MarkAdamsMSBA24/ADRv2024")
|
8 |
+
|
9 |
+
# Define the prediction function
|
10 |
+
def get_prediction(text):
|
11 |
+
inputs = tokenizer(text, return_tensors="pt", max_length=512, truncation=True, padding=True)
|
12 |
+
with torch.no_grad():
|
13 |
+
outputs = model(**inputs)
|
14 |
+
prediction_scores = outputs.logits
|
15 |
+
predicted_class = torch.argmax(prediction_scores, dim=-1).item()
|
16 |
+
return f"Predicted Class: {predicted_class}", prediction_scores.tolist()
|
17 |
+
|
18 |
+
iface = gr.Interface(
|
19 |
+
fn=get_prediction,
|
20 |
+
inputs=gr.Textbox(lines=4, placeholder="Type your text..."),
|
21 |
+
outputs=[gr.Textbox(label="Prediction"), gr.Dataframe(label="Scores")],
|
22 |
+
title="BERT Sequence Classification Demo",
|
23 |
+
description="This demo uses a BERT model hosted on Hugging Face to classify text sequences."
|
24 |
+
)
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 |
+
absl-py==2.1.0
|
2 |
+
accelerate==0.29.3
|
3 |
+
aiofiles==23.2.1
|
4 |
+
aiohttp==3.8.4
|
5 |
+
aiosignal==1.3.1
|
6 |
+
altair==5.3.0
|
7 |
+
annotated-types==0.6.0
|
8 |
+
anyio==3.6.2
|
9 |
+
argon2-cffi==21.3.0
|
10 |
+
argon2-cffi-bindings==21.2.0
|
11 |
+
arrow==1.2.3
|
12 |
+
asttokens==2.2.1
|
13 |
+
astunparse==1.6.3
|
14 |
+
async-timeout==4.0.2
|
15 |
+
attrs==22.2.0
|
16 |
+
backcall==0.2.0
|
17 |
+
beautifulsoup4==4.12.0
|
18 |
+
bleach==6.0.0
|
19 |
+
blessed==1.20.0
|
20 |
+
blinker==1.8.2
|
21 |
+
blis==0.7.11
|
22 |
+
botorch==0.6.5
|
23 |
+
cachetools==5.3.3
|
24 |
+
catalogue==2.0.10
|
25 |
+
certifi==2022.12.7
|
26 |
+
cffi==1.15.1
|
27 |
+
charset-normalizer==3.1.0
|
28 |
+
click==8.1.3
|
29 |
+
cloudpathlib==0.16.0
|
30 |
+
cloudpickle==3.0.0
|
31 |
+
comm==0.1.3
|
32 |
+
confection==0.1.4
|
33 |
+
croniter==1.3.8
|
34 |
+
cycler==0.11.0
|
35 |
+
cymem==2.0.8
|
36 |
+
Cython==0.29.34
|
37 |
+
datasets==2.18.0
|
38 |
+
dateutils==0.6.12
|
39 |
+
debugpy==1.6.6
|
40 |
+
decorator==4.4.2
|
41 |
+
deepdiff==6.3.0
|
42 |
+
defusedxml==0.7.1
|
43 |
+
dill==0.3.8
|
44 |
+
dnspython==2.3.0
|
45 |
+
email_validator==2.1.1
|
46 |
+
en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.1/en_core_web_sm-3.7.1-py3-none-any.whl
|
47 |
+
evaluate==0.4.1
|
48 |
+
executing==1.2.0
|
49 |
+
fastapi==0.88.0
|
50 |
+
fastapi-cli==0.0.3
|
51 |
+
fastjsonschema==2.16.3
|
52 |
+
ffmpy==0.3.2
|
53 |
+
filelock==3.13.4
|
54 |
+
flatbuffers==24.3.25
|
55 |
+
fonttools==4.39.3
|
56 |
+
fqdn==1.5.1
|
57 |
+
frozenlist==1.3.3
|
58 |
+
fsspec==2024.2.0
|
59 |
+
gast==0.5.4
|
60 |
+
gdown==5.1.0
|
61 |
+
gitdb==4.0.11
|
62 |
+
GitPython==3.1.43
|
63 |
+
google-pasta==0.2.0
|
64 |
+
gpytorch==1.9.1
|
65 |
+
gradio==3.50.2
|
66 |
+
gradio_client==0.6.1
|
67 |
+
grpcio==1.62.1
|
68 |
+
h11==0.14.0
|
69 |
+
h5py==3.11.0
|
70 |
+
httpcore==1.0.5
|
71 |
+
httptools==0.5.0
|
72 |
+
httpx==0.27.0
|
73 |
+
huggingface-hub==0.22.2
|
74 |
+
idna==3.4
|
75 |
+
ignite==1.1.0
|
76 |
+
imageio==2.27.0
|
77 |
+
importlib-metadata==6.1.0
|
78 |
+
importlib_resources==6.4.0
|
79 |
+
inquirer==3.1.3
|
80 |
+
ipykernel==6.22.0
|
81 |
+
ipython==8.12.0
|
82 |
+
ipython-genutils==0.2.0
|
83 |
+
ipywidgets==8.0.6
|
84 |
+
isoduration==20.11.0
|
85 |
+
itsdangerous==2.1.2
|
86 |
+
jedi==0.18.2
|
87 |
+
Jinja2==3.1.2
|
88 |
+
joblib==1.2.0
|
89 |
+
jsonpointer==2.3
|
90 |
+
jsonschema==4.17.3
|
91 |
+
jupyter==1.0.0
|
92 |
+
jupyter-console==6.6.3
|
93 |
+
jupyter-events==0.6.3
|
94 |
+
jupyter_client==8.1.0
|
95 |
+
jupyter_core==5.3.0
|
96 |
+
jupyter_server==2.5.0
|
97 |
+
jupyter_server_terminals==0.4.4
|
98 |
+
jupyterlab-pygments==0.2.2
|
99 |
+
jupyterlab-widgets==3.0.7
|
100 |
+
keras==3.2.1
|
101 |
+
kiwisolver==1.4.4
|
102 |
+
langcodes==3.3.0
|
103 |
+
libclang==18.1.1
|
104 |
+
lightning @ https://github.com/PyTorchLightning/pytorch-lightning/archive/master.zip
|
105 |
+
lightning-cloud==0.5.32
|
106 |
+
lightning-utilities==0.8.0
|
107 |
+
linear-operator==0.3.0
|
108 |
+
llvmlite==0.42.0
|
109 |
+
Markdown==3.6
|
110 |
+
markdown-it-py==2.2.0
|
111 |
+
MarkupSafe==2.1.2
|
112 |
+
matplotlib==3.5.2
|
113 |
+
matplotlib-inline==0.1.6
|
114 |
+
mdurl==0.1.2
|
115 |
+
mistune==2.0.5
|
116 |
+
ml-dtypes==0.3.2
|
117 |
+
multidict==6.0.4
|
118 |
+
multipledispatch==0.6.0
|
119 |
+
multiprocess==0.70.16
|
120 |
+
murmurhash==1.0.10
|
121 |
+
mypy-extensions==1.0.0
|
122 |
+
namex==0.0.7
|
123 |
+
nbclassic==0.5.4
|
124 |
+
nbclient==0.7.3
|
125 |
+
nbconvert==7.2.10
|
126 |
+
nbformat==5.8.0
|
127 |
+
nest-asyncio==1.5.6
|
128 |
+
networkx==3.0
|
129 |
+
nlpaug==1.1.11
|
130 |
+
nltk==3.8.1
|
131 |
+
notebook==6.5.3
|
132 |
+
notebook_shim==0.2.2
|
133 |
+
numba==0.59.1
|
134 |
+
numpy==1.23.0
|
135 |
+
opencv-python==4.6.0.66
|
136 |
+
openslide-python==1.2.0
|
137 |
+
opt-einsum==3.3.0
|
138 |
+
optree==0.11.0
|
139 |
+
ordered-set==4.1.0
|
140 |
+
orjson==3.8.9
|
141 |
+
packaging==23.0
|
142 |
+
pandas==1.3.5
|
143 |
+
pandocfilters==1.5.0
|
144 |
+
parso==0.8.3
|
145 |
+
pexpect==4.8.0
|
146 |
+
pickleshare==0.7.5
|
147 |
+
Pillow==9.5.0
|
148 |
+
platformdirs==3.2.0
|
149 |
+
preshed==3.0.9
|
150 |
+
prometheus-client==0.16.0
|
151 |
+
prompt-toolkit==3.0.38
|
152 |
+
protobuf==4.25.3
|
153 |
+
psutil==5.9.4
|
154 |
+
ptyprocess==0.7.0
|
155 |
+
pure-eval==0.2.2
|
156 |
+
pyarrow==15.0.2
|
157 |
+
pyarrow-hotfix==0.6
|
158 |
+
pycparser==2.21
|
159 |
+
pydantic==1.10.7
|
160 |
+
pydantic_core==2.18.2
|
161 |
+
pydeck==0.9.1
|
162 |
+
pydub==0.25.1
|
163 |
+
Pygments==2.14.0
|
164 |
+
PyJWT==2.6.0
|
165 |
+
pyparsing==3.0.9
|
166 |
+
PyQt5==5.15.9
|
167 |
+
pyqt5-plugins==5.15.9.2.3
|
168 |
+
PyQt5-Qt5==5.15.2
|
169 |
+
PyQt5-sip==12.11.1
|
170 |
+
pyqt5-tools==5.15.9.3.3
|
171 |
+
pyro-api==0.1.2
|
172 |
+
pyro-ppl==1.8.4
|
173 |
+
pyrsistent==0.19.3
|
174 |
+
PySocks==1.7.1
|
175 |
+
python-dateutil==2.8.2
|
176 |
+
python-dotenv==1.0.0
|
177 |
+
python-editor==1.0.4
|
178 |
+
python-json-logger==2.0.7
|
179 |
+
python-multipart==0.0.9
|
180 |
+
python-poppler==0.4.0
|
181 |
+
pytorch-lightning==2.0.1
|
182 |
+
pytz==2023.3
|
183 |
+
PyWavelets==1.4.1
|
184 |
+
PyYAML==6.0
|
185 |
+
pyzmq==25.0.2
|
186 |
+
qt5-applications==5.15.2.2.3
|
187 |
+
qt5-tools==5.15.2.1.3
|
188 |
+
qtconsole==5.4.2
|
189 |
+
QtPy==2.3.1
|
190 |
+
readchar==4.0.5
|
191 |
+
regex==2023.12.25
|
192 |
+
requests==2.31.0
|
193 |
+
responses==0.18.0
|
194 |
+
rfc3339-validator==0.1.4
|
195 |
+
rfc3986==1.5.0
|
196 |
+
rfc3986-validator==0.1.1
|
197 |
+
rich==13.3.3
|
198 |
+
ruff==0.4.4
|
199 |
+
safetensors==0.4.2
|
200 |
+
scikit-image==0.19.3
|
201 |
+
scikit-learn==1.1.1
|
202 |
+
scipy==1.8.1
|
203 |
+
seaborn==0.11.2
|
204 |
+
semantic-version==2.10.0
|
205 |
+
Send2Trash==1.8.0
|
206 |
+
sentencepiece==0.2.0
|
207 |
+
shap==0.45.0
|
208 |
+
shellingham==1.5.4
|
209 |
+
six==1.16.0
|
210 |
+
slicer==0.0.7
|
211 |
+
smart-open==6.4.0
|
212 |
+
smmap==5.0.1
|
213 |
+
sniffio==1.3.0
|
214 |
+
soupsieve==2.4
|
215 |
+
sox==1.4.1
|
216 |
+
spacy==3.7.4
|
217 |
+
spacy-legacy==3.0.12
|
218 |
+
spacy-loggers==1.0.5
|
219 |
+
srsly==2.4.8
|
220 |
+
stack-data==0.6.2
|
221 |
+
starlette==0.22.0
|
222 |
+
starsessions==1.3.0
|
223 |
+
streamlit==1.34.0
|
224 |
+
tenacity==8.3.0
|
225 |
+
tensorboard==2.16.2
|
226 |
+
tensorboard-data-server==0.7.2
|
227 |
+
tensorflow==2.16.1
|
228 |
+
tensorflow-io-gcs-filesystem==0.36.0
|
229 |
+
termcolor==2.4.0
|
230 |
+
terminado==0.17.1
|
231 |
+
tf_keras==2.16.0
|
232 |
+
thinc==8.2.3
|
233 |
+
threadpoolctl==3.1.0
|
234 |
+
tifffile==2023.3.21
|
235 |
+
tinycss2==1.2.1
|
236 |
+
tokenizers==0.15.2
|
237 |
+
toml==0.10.2
|
238 |
+
tomlkit==0.12.0
|
239 |
+
toolz==0.12.1
|
240 |
+
torch==1.12.0+cu113
|
241 |
+
torch-cluster==1.6.0+pt112cu113
|
242 |
+
torch-geometric==2.1.0
|
243 |
+
torch-geometric-temporal==0.54.0
|
244 |
+
torch-scatter==2.0.9
|
245 |
+
torch-sparse==0.6.15+pt112cu113
|
246 |
+
torch-spline-conv==1.2.1+pt112cu113
|
247 |
+
torchaudio==0.12.0+cu113
|
248 |
+
torchmetrics==0.11.4
|
249 |
+
torchtext==0.13.0
|
250 |
+
torchvision==0.13.0+cu113
|
251 |
+
tornado==6.2
|
252 |
+
tqdm==4.65.0
|
253 |
+
traitlets==5.9.0
|
254 |
+
transformers==4.39.3
|
255 |
+
typer==0.12.3
|
256 |
+
typing-inspect==0.8.0
|
257 |
+
typing_extensions==4.11.0
|
258 |
+
ujson==5.7.0
|
259 |
+
uri-template==1.2.0
|
260 |
+
urllib3==2.2.1
|
261 |
+
uvicorn==0.21.1
|
262 |
+
uvloop==0.17.0
|
263 |
+
wasabi==1.1.2
|
264 |
+
watchdog==4.0.0
|
265 |
+
watchfiles==0.19.0
|
266 |
+
wcwidth==0.2.6
|
267 |
+
weasel==0.3.4
|
268 |
+
webcolors==1.13
|
269 |
+
webencodings==0.5.1
|
270 |
+
websocket-client==1.5.1
|
271 |
+
websockets==11.0
|
272 |
+
Werkzeug==3.0.2
|
273 |
+
widgetsnbextension==4.0.7
|
274 |
+
wordcloud==1.9.3
|
275 |
+
wrapt==1.15.0
|
276 |
+
xxhash==3.4.1
|
277 |
+
yarl==1.8.2
|
278 |
+
zipp==3.15.0
|