Spaces:
Build error
Build error
Commit
·
f09d32a
1
Parent(s):
47a6a10
init
Browse files- app.py +4 -6
- requirements.txt +46 -284
app.py
CHANGED
@@ -20,10 +20,8 @@ def load_model():
|
|
20 |
#
|
21 |
processor = Blip2Processor.from_pretrained("Salesforce/blip2-flan-t5-xl")
|
22 |
# device_map = {"": 0}
|
23 |
-
device_map = "auto"
|
24 |
-
model = Blip2ForConditionalGeneration.from_pretrained("Salesforce/blip2-flan-t5-xl"
|
25 |
-
load_in_8bit=True,
|
26 |
-
device_map=device_map)
|
27 |
model = PeftModel.from_pretrained(model, model_name)
|
28 |
model = get_peft_model(model, config)
|
29 |
return processor, model
|
@@ -48,8 +46,8 @@ def get_text():
|
|
48 |
def generate_output(image, prompt):
|
49 |
encoding = processor(images=image, text=prompt, max_length=512, truncation=True,
|
50 |
padding="max_length", return_tensors="pt")
|
51 |
-
predictions = model.generate(input_ids=encoding['input_ids']
|
52 |
-
pixel_values=encoding['pixel_values']
|
53 |
max_length=20)
|
54 |
p = processor.batch_decode(predictions, skip_special_tokens=True)
|
55 |
out = " ".join(p)
|
|
|
20 |
#
|
21 |
processor = Blip2Processor.from_pretrained("Salesforce/blip2-flan-t5-xl")
|
22 |
# device_map = {"": 0}
|
23 |
+
# device_map = "auto"
|
24 |
+
model = Blip2ForConditionalGeneration.from_pretrained("Salesforce/blip2-flan-t5-xl")
|
|
|
|
|
25 |
model = PeftModel.from_pretrained(model, model_name)
|
26 |
model = get_peft_model(model, config)
|
27 |
return processor, model
|
|
|
46 |
def generate_output(image, prompt):
|
47 |
encoding = processor(images=image, text=prompt, max_length=512, truncation=True,
|
48 |
padding="max_length", return_tensors="pt")
|
49 |
+
predictions = model.generate(input_ids=encoding['input_ids'],
|
50 |
+
pixel_values=encoding['pixel_values'],
|
51 |
max_length=20)
|
52 |
p = processor.batch_decode(predictions, skip_special_tokens=True)
|
53 |
out = " ".join(p)
|
requirements.txt
CHANGED
@@ -1,316 +1,78 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
aiostream==0.4.5
|
7 |
-
altair==4.2.0
|
8 |
-
antlr4-python3-runtime==4.9.3
|
9 |
-
anyio==3.6.1
|
10 |
-
arxiv==1.4.7
|
11 |
-
asttokens==2.2.1
|
12 |
-
async-timeout==4.0.2
|
13 |
-
attrs==22.2.0
|
14 |
-
backcall==0.2.0
|
15 |
-
beautifulsoup4==4.7.1
|
16 |
-
bitsandbytes==0.37.1
|
17 |
-
blinker==1.5
|
18 |
-
blis==0.7.9
|
19 |
-
blobfile==2.0.2
|
20 |
-
boto3==1.26.13
|
21 |
-
botocore==1.29.13
|
22 |
-
Bottleneck==1.3.5
|
23 |
-
braceexpand==0.1.7
|
24 |
brotlipy==0.7.0
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
certifi==2022.12.7
|
29 |
-
cffi==1.15.0
|
30 |
-
cfgv==3.3.1
|
31 |
-
chardet==3.0.4
|
32 |
charset-normalizer==2.0.4
|
33 |
-
chex==0.1.6
|
34 |
click==8.1.3
|
35 |
-
|
36 |
-
#clip-client==0.6.2
|
37 |
-
#clip-server==0.6.2
|
38 |
-
colorama==0.4.6
|
39 |
-
comet-ml==3.12.2
|
40 |
-
commonmark==0.9.1
|
41 |
-
confection==0.0.4
|
42 |
-
configobj==5.0.8
|
43 |
-
contexttimer==0.3.3
|
44 |
-
contourpy==1.0.5
|
45 |
-
cryptography==37.0.1
|
46 |
-
cssselect==1.0.3
|
47 |
-
cycler==0.11.0
|
48 |
-
cymem==2.0.7
|
49 |
-
#dataclasses==0.8
|
50 |
-
datasets==2.8.0
|
51 |
decorator==5.1.1
|
52 |
-
decord==0.6.0
|
53 |
-
deepspeed==0.8.3
|
54 |
-
dill==0.3.6
|
55 |
-
distlib==0.3.6
|
56 |
-
dm-tree==0.1.8
|
57 |
-
docarray==0.16.3
|
58 |
-
docker==6.0.0
|
59 |
-
docker-pycreds==0.4.0
|
60 |
-
dulwich==0.21.3
|
61 |
-
einops==0.6.0
|
62 |
-
#en-core-web-sm==3.4.1
|
63 |
entrypoints==0.4
|
64 |
-
etils==1.0.0
|
65 |
-
evaluate==0.4.0
|
66 |
-
everett==3.1.0
|
67 |
-
exceptiongroup==1.1.0
|
68 |
-
executing==1.2.0
|
69 |
-
fairscale==0.4.4
|
70 |
-
fastapi==0.82.0
|
71 |
-
feedfinder2==0.0.4
|
72 |
-
feedparser==5.2.1
|
73 |
-
ffmpy==0.3.0
|
74 |
filelock==3.9.0
|
75 |
-
|
76 |
-
Flask-Cors==3.0.7
|
77 |
-
flax==0.6.6
|
78 |
-
fonttools==4.37.1
|
79 |
-
frozenlist==1.3.3
|
80 |
-
fsspec==2022.11.0
|
81 |
-
ftfy==6.1.1
|
82 |
-
gdown==4.5.1
|
83 |
gitdb==4.0.10
|
84 |
-
GitPython==3.1.
|
85 |
-
|
86 |
-
|
87 |
-
gradio==3.25.0
|
88 |
-
gradio_client==0.1.3
|
89 |
-
grpcio==1.47.0
|
90 |
-
grpcio-health-checking
|
91 |
-
grpcio-reflection
|
92 |
-
h11==0.13.0
|
93 |
-
hjson==3.1.0
|
94 |
-
httpcore==0.17.0
|
95 |
-
httptools==0.4.0
|
96 |
-
httpx==0.24.0
|
97 |
-
huggingface-hub==0.13.4
|
98 |
-
identify==2.5.18
|
99 |
idna==3.4
|
100 |
-
|
101 |
-
imbalanced-learn==0.10.1
|
102 |
-
importlib-metadata==6.0.0
|
103 |
-
importlib-resources==5.12.0
|
104 |
-
iniconfig==2.0.0
|
105 |
-
iopath==0.1.10
|
106 |
-
ipython==8.11.0
|
107 |
-
itsdangerous==1.1.0
|
108 |
-
jax==0.4.5
|
109 |
-
jaxlib==0.4.4
|
110 |
-
jcloud==0.0.35
|
111 |
-
jedi==0.18.2
|
112 |
-
jieba3k==0.35.1
|
113 |
-
jina
|
114 |
-
jina-hubble-sdk==0.15.5
|
115 |
Jinja2==3.1.2
|
116 |
-
jmespath==1.0.1
|
117 |
-
joblib==1.2.0
|
118 |
jsonschema==4.17.3
|
119 |
-
kaggle==1.5.13
|
120 |
-
kiwisolver==1.4.4
|
121 |
-
langcodes==3.3.0
|
122 |
-
langdetect==1.0.7
|
123 |
-
latex2mathml==3.75.2
|
124 |
-
linkify-it-py==2.0.0
|
125 |
-
lxml==4.9.1
|
126 |
-
lz4==4.0.2
|
127 |
-
Markdown==3.4.1
|
128 |
markdown-it-py==2.2.0
|
129 |
MarkupSafe==2.1.1
|
130 |
-
matplotlib==3.6.2
|
131 |
-
matplotlib-inline==0.1.6
|
132 |
-
mdit-py-plugins==0.3.3
|
133 |
-
mdtex2html==1.2.0
|
134 |
mdurl==0.1.2
|
135 |
-
mkl-fft==1.3.
|
136 |
mkl-random==1.2.2
|
137 |
mkl-service==2.4.0
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
networkx==2.8.8
|
144 |
-
newspaper3k==0.2.8
|
145 |
-
ninja==1.11.1
|
146 |
-
nltk==3.4
|
147 |
-
nodeenv==1.7.0
|
148 |
-
numexpr==2.8.4
|
149 |
-
numpy==1.22.3
|
150 |
-
nvidia-ml-py3==7.352.0
|
151 |
-
oauthlib==3.0.1
|
152 |
-
omegaconf==2.3.0
|
153 |
-
open-clip-torch==1.3.0
|
154 |
-
openai==0.27.0
|
155 |
-
opencv-python-headless==4.5.5.64
|
156 |
-
opendatasets==0.1.22
|
157 |
-
openprompt==1.0.1
|
158 |
-
opt-einsum==3.3.0
|
159 |
-
optax==0.1.4
|
160 |
-
orbax==0.1.3
|
161 |
-
orjson==3.8.10
|
162 |
-
packaging==21.3
|
163 |
-
pandas==1.5.2
|
164 |
-
parso==0.8.3
|
165 |
-
pathspec==0.10.1
|
166 |
-
pathtools==0.1.2
|
167 |
-
pathy==0.10.1
|
168 |
peft==0.3.0
|
169 |
-
pexpect==4.8.0
|
170 |
-
pickleshare==0.7.5
|
171 |
Pillow==9.4.0
|
172 |
-
pip==
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
portalocker==2.7.0
|
177 |
-
pre-commit==3.1.1
|
178 |
-
preshed==3.0.8
|
179 |
-
prometheus-client==0.14.1
|
180 |
-
promise==2.3
|
181 |
-
prompt-toolkit==3.0.38
|
182 |
-
protobuf
|
183 |
-
psutil==5.9.4
|
184 |
-
ptyprocess==0.7.0
|
185 |
-
pure-eval==0.2.2
|
186 |
-
py-cpuinfo==9.0.0
|
187 |
-
pyarrow==8.0.0
|
188 |
-
pyasn1==0.4.8
|
189 |
-
pyasn1-modules==0.2.8
|
190 |
-
pybase64==1.2.3
|
191 |
-
pycocoevalcap==1.2
|
192 |
-
pycocotools==2.0.6
|
193 |
pycparser==2.21
|
194 |
-
|
195 |
-
|
196 |
-
pydantic==1.10.2
|
197 |
-
pydeck==0.8.0
|
198 |
-
pydub==0.25.1
|
199 |
-
Pygments==2.13.0
|
200 |
Pympler==1.0.1
|
201 |
-
|
202 |
-
pyOpenSSL==22.0.0
|
203 |
-
pyparsing==3.0.9
|
204 |
pyrsistent==0.19.3
|
205 |
PySocks==1.7.1
|
206 |
-
pytest==7.2.0
|
207 |
python-dateutil==2.8.2
|
208 |
-
|
209 |
-
python-dotenv==0.18.0
|
210 |
-
python-magic==0.4.27
|
211 |
-
python-markdown-math==0.8
|
212 |
-
python-multipart==0.0.5
|
213 |
-
python-slugify==8.0.1
|
214 |
-
pytorch-pretrained-bert==0.6.2
|
215 |
-
pytorch-transformers==1.0.0
|
216 |
-
pytz==2022.1
|
217 |
-
pytz-deprecation-shim==0.1.0.post0
|
218 |
-
PyWavelets==1.4.1
|
219 |
-
pywebarchive==0.5.0
|
220 |
PyYAML==6.0
|
221 |
-
regex==
|
222 |
-
requests==2.
|
223 |
-
|
224 |
-
|
225 |
-
requests-toolbelt==0.10.1
|
226 |
-
responses==0.10.15
|
227 |
-
rich==12.5.1
|
228 |
-
rouge==1.0.0
|
229 |
-
rouge-score==0.1.2
|
230 |
-
rsa==4.9
|
231 |
-
s3transfer==0.6.0
|
232 |
-
salesforce-lavis==1.0.0
|
233 |
-
scikit-image==0.19.3
|
234 |
-
scikit-learn==1.1.2
|
235 |
-
scipy==1.9.1
|
236 |
-
seaborn==0.12.1
|
237 |
-
semantic-version==2.10.0
|
238 |
-
semver==2.13.0
|
239 |
-
sentencepiece==0.1.96
|
240 |
-
sentry-sdk==1.12.1
|
241 |
-
seqeval==1.2.2
|
242 |
-
setproctitle==1.3.2
|
243 |
-
setuptools==65.6.3
|
244 |
-
shortuuid==1.0.11
|
245 |
-
simpletransformers==0.63.9
|
246 |
-
singledispatch==3.4.0.3
|
247 |
six==1.16.0
|
248 |
-
skorch==0.12.1
|
249 |
-
smart-open==6.3.0
|
250 |
smmap==5.0.0
|
251 |
-
|
252 |
-
soupsieve==1.8
|
253 |
-
spacy==3.4.4
|
254 |
-
spacy-langdetect==0.1.2
|
255 |
-
spacy-legacy==3.0.11
|
256 |
-
spacy-loggers==1.0.4
|
257 |
-
srsly==2.4.5
|
258 |
-
stack-data==0.6.2
|
259 |
-
starlette==0.19.1
|
260 |
-
streamlit
|
261 |
streamlit-chat==0.0.2.2
|
262 |
-
|
263 |
tenacity==8.2.2
|
264 |
-
|
265 |
-
tensorboard-data-server==0.6.1
|
266 |
-
tensorboard-plugin-wit==1.8.1
|
267 |
-
tensorboardX==2.5.1
|
268 |
-
tensorstore==0.1.33
|
269 |
-
text-unidecode==1.3
|
270 |
-
thinc==8.1.6
|
271 |
-
threadpoolctl==3.1.0
|
272 |
-
tifffile==2022.10.10
|
273 |
-
tiktoken==0.4.0
|
274 |
-
timm==0.4.12
|
275 |
-
tinysegmenter==0.3
|
276 |
-
tldextract==2.2.1
|
277 |
-
tokenizers==0.12.1
|
278 |
toml==0.10.2
|
279 |
-
tomli==2.0.1
|
280 |
toolz==0.12.0
|
281 |
-
torch==
|
282 |
-
torchaudio==0.
|
283 |
-
torchvision==0.
|
284 |
-
tornado==6.2
|
285 |
-
tqdm==4.
|
286 |
-
traitlets==5.9.0
|
287 |
transformers==4.29.2
|
288 |
-
twython==3.7.0
|
289 |
-
typer==0.7.0
|
290 |
typing_extensions==4.5.0
|
291 |
-
tzdata==
|
292 |
-
tzlocal==
|
293 |
-
|
294 |
-
urllib3==1.26.13
|
295 |
-
uvicorn==0.18.3
|
296 |
-
uvloop==0.16.0
|
297 |
validators==0.20.0
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
watchdog==2.2.1
|
302 |
-
watchfiles==0.16.1
|
303 |
-
waybackpy==3.0.6
|
304 |
-
wcwidth==0.2.5
|
305 |
-
webdataset==0.2.35
|
306 |
-
websocket-client==1.4.1
|
307 |
-
websockets==10.3
|
308 |
-
Werkzeug==2.2.2
|
309 |
-
wheel==0.37.1
|
310 |
-
wrapt==1.15.0
|
311 |
-
wurlitzer==3.0.3
|
312 |
-
xmlx==2.0.0
|
313 |
-
xxhash==3.0.0
|
314 |
-
yacs==0.1.8
|
315 |
-
yarl==1.7.2
|
316 |
-
zipp==3.11.0
|
|
|
1 |
+
accelerate==0.19.0
|
2 |
+
altair==4.2.2
|
3 |
+
attrs==23.1.0
|
4 |
+
bitsandbytes==0.38.1
|
5 |
+
blinker==1.6.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
brotlipy==0.7.0
|
7 |
+
cachetools==5.3.0
|
8 |
+
certifi==2023.5.7
|
9 |
+
cffi==1.15.1
|
|
|
|
|
|
|
|
|
10 |
charset-normalizer==2.0.4
|
|
|
11 |
click==8.1.3
|
12 |
+
cryptography==39.0.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
decorator==5.1.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
entrypoints==0.4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
filelock==3.9.0
|
16 |
+
fsspec==2023.5.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
gitdb==4.0.10
|
18 |
+
GitPython==3.1.31
|
19 |
+
gmpy2==2.1.2
|
20 |
+
huggingface-hub==0.14.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
idna==3.4
|
22 |
+
importlib-metadata==6.6.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
Jinja2==3.1.2
|
|
|
|
|
24 |
jsonschema==4.17.3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
markdown-it-py==2.2.0
|
26 |
MarkupSafe==2.1.1
|
|
|
|
|
|
|
|
|
27 |
mdurl==0.1.2
|
28 |
+
mkl-fft==1.3.6
|
29 |
mkl-random==1.2.2
|
30 |
mkl-service==2.4.0
|
31 |
+
mpmath==1.2.1
|
32 |
+
networkx==2.8.4
|
33 |
+
numpy==1.24.3
|
34 |
+
packaging==23.1
|
35 |
+
pandas==2.0.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
peft==0.3.0
|
|
|
|
|
37 |
Pillow==9.4.0
|
38 |
+
pip==23.0.1
|
39 |
+
protobuf==3.20.3
|
40 |
+
psutil==5.9.5
|
41 |
+
pyarrow==12.0.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
pycparser==2.21
|
43 |
+
pydeck==0.8.1b0
|
44 |
+
Pygments==2.15.1
|
|
|
|
|
|
|
|
|
45 |
Pympler==1.0.1
|
46 |
+
pyOpenSSL==23.0.0
|
|
|
|
|
47 |
pyrsistent==0.19.3
|
48 |
PySocks==1.7.1
|
|
|
49 |
python-dateutil==2.8.2
|
50 |
+
pytz==2023.3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
PyYAML==6.0
|
52 |
+
regex==2023.5.5
|
53 |
+
requests==2.29.0
|
54 |
+
rich==13.3.5
|
55 |
+
setuptools==66.0.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
six==1.16.0
|
|
|
|
|
57 |
smmap==5.0.0
|
58 |
+
streamlit==1.22.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
streamlit-chat==0.0.2.2
|
60 |
+
sympy==1.11.1
|
61 |
tenacity==8.2.2
|
62 |
+
tokenizers==0.13.3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
toml==0.10.2
|
|
|
64 |
toolz==0.12.0
|
65 |
+
torch==2.0.1
|
66 |
+
torchaudio==2.0.2
|
67 |
+
torchvision==0.15.2
|
68 |
+
tornado==6.3.2
|
69 |
+
tqdm==4.65.0
|
|
|
70 |
transformers==4.29.2
|
|
|
|
|
71 |
typing_extensions==4.5.0
|
72 |
+
tzdata==2023.3
|
73 |
+
tzlocal==5.0.1
|
74 |
+
urllib3==1.26.15
|
|
|
|
|
|
|
75 |
validators==0.20.0
|
76 |
+
watchdog==3.0.0
|
77 |
+
wheel==0.38.4
|
78 |
+
zipp==3.15.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|