Skip to content

Commit 66fb179

Browse files
authored
Feat/download quantized model (#242)
After this PR is merged two main changes will be done: * `onnxruntime` will be pinned to be <1.16 due some changes in quantization recently introduced not being compatible for the moment with the library and model. * yolox_quantized will be downloaded from HF instead being generated at runtime. In order to test you can execute: ``` from unstructured_inference.inference import layout from unstructured_inference.models.base import get_model file = "sample-docs/example_table.jpg" model = get_model("yolox_quantized") doc = layout.DocumentLayout.from_image_file( file, model, supplement_with_ocr_elements=True, ocr_strategy="never", ) ``` And should show a download from HF downloading a file called `yolox_l0.05_quantized.onnx`
1 parent ffb1f0b commit 66fb179

File tree

7 files changed

+65
-67
lines changed

7 files changed

+65
-67
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.7.1
2+
3+
* Download yolox_quantized from HF
4+
15
## 0.7.0
26

37
* Remove all OCR related code expect the table OCR code

requirements/base.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ python-multipart
33
huggingface-hub
44
opencv-python!=4.7.0.68
55
onnx==1.14.1
6-
onnxruntime
6+
# NOTE(benjamin): Pinned because onnxruntime changed the way quantization is done, and we need to update our code to support it
7+
onnxruntime<1.16
78
# NOTE(alan): Pinned because this is when the most recent module we import appeared
89
transformers>=4.25.1
910
rapidfuzz

requirements/base.txt

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ antlr4-python3-runtime==4.9.3
88
# via omegaconf
99
certifi==2023.7.22
1010
# via requests
11-
cffi==1.15.1
11+
cffi==1.16.0
1212
# via cryptography
13-
charset-normalizer==3.2.0
13+
charset-normalizer==3.3.0
1414
# via
1515
# pdfminer-six
1616
# requests
@@ -20,7 +20,7 @@ contourpy==1.1.1
2020
# via matplotlib
2121
cryptography==41.0.4
2222
# via pdfminer-six
23-
cycler==0.11.0
23+
cycler==0.12.0
2424
# via matplotlib
2525
effdet==0.4.1
2626
# via layoutparser
@@ -31,14 +31,17 @@ filelock==3.12.4
3131
# transformers
3232
flatbuffers==23.5.26
3333
# via onnxruntime
34-
fonttools==4.42.1
34+
fonttools==4.43.0
3535
# via matplotlib
36-
fsspec==2023.9.1
37-
# via huggingface-hub
38-
huggingface-hub==0.17.2
36+
fsspec==2023.9.2
37+
# via
38+
# huggingface-hub
39+
# torch
40+
huggingface-hub==0.16.4
3941
# via
4042
# -r requirements/base.in
4143
# timm
44+
# tokenizers
4245
# transformers
4346
humanfriendly==10.0
4447
# via coloredlogs
@@ -79,13 +82,13 @@ omegaconf==2.3.0
7982
# via effdet
8083
onnx==1.14.1
8184
# via -r requirements/base.in
82-
onnxruntime==1.16.0
85+
onnxruntime==1.15.1
8386
# via -r requirements/base.in
84-
opencv-python==4.8.0.76
87+
opencv-python==4.8.1.78
8588
# via
8689
# -r requirements/base.in
8790
# layoutparser
88-
packaging==23.1
91+
packaging==23.2
8992
# via
9093
# huggingface-hub
9194
# matplotlib
@@ -110,7 +113,7 @@ pillow==10.0.1
110113
# torchvision
111114
portalocker==2.8.2
112115
# via iopath
113-
protobuf==4.24.3
116+
protobuf==4.24.4
114117
# via
115118
# onnx
116119
# onnxruntime
@@ -139,9 +142,9 @@ pyyaml==6.0.1
139142
# omegaconf
140143
# timm
141144
# transformers
142-
rapidfuzz==3.3.0
145+
rapidfuzz==3.3.1
143146
# via -r requirements/base.in
144-
regex==2023.8.8
147+
regex==2023.10.3
145148
# via transformers
146149
requests==2.31.0
147150
# via
@@ -162,15 +165,15 @@ sympy==1.12
162165
# torch
163166
timm==0.9.7
164167
# via effdet
165-
tokenizers==0.13.3
168+
tokenizers==0.14.0
166169
# via transformers
167-
torch==2.0.1
170+
torch==2.1.0
168171
# via
169172
# effdet
170173
# layoutparser
171174
# timm
172175
# torchvision
173-
torchvision==0.15.2
176+
torchvision==0.16.0
174177
# via
175178
# effdet
176179
# layoutparser
@@ -180,7 +183,7 @@ tqdm==4.66.1
180183
# huggingface-hub
181184
# iopath
182185
# transformers
183-
transformers==4.33.2
186+
transformers==4.34.0
184187
# via -r requirements/base.in
185188
typing-extensions==4.8.0
186189
# via
@@ -190,7 +193,7 @@ typing-extensions==4.8.0
190193
# torch
191194
tzdata==2023.3
192195
# via pandas
193-
urllib3==2.0.5
196+
urllib3==2.0.6
194197
# via requests
195198
zipp==3.17.0
196199
# via importlib-resources

requirements/dev.txt

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ argon2-cffi==23.1.0
1616
# via jupyter-server
1717
argon2-cffi-bindings==21.2.0
1818
# via argon2-cffi
19-
arrow==1.2.3
19+
arrow==1.3.0
2020
# via isoduration
2121
asttokens==2.4.0
2222
# via stack-data
@@ -26,7 +26,7 @@ attrs==23.1.0
2626
# via
2727
# jsonschema
2828
# referencing
29-
babel==2.12.1
29+
babel==2.13.0
3030
# via jupyterlab-server
3131
backcall==0.2.0
3232
# via ipython
@@ -41,11 +41,11 @@ certifi==2023.7.22
4141
# -c requirements/base.txt
4242
# -c requirements/test.txt
4343
# requests
44-
cffi==1.15.1
44+
cffi==1.16.0
4545
# via
4646
# -c requirements/base.txt
4747
# argon2-cffi-bindings
48-
charset-normalizer==3.2.0
48+
charset-normalizer==3.3.0
4949
# via
5050
# -c requirements/base.txt
5151
# -c requirements/test.txt
@@ -62,7 +62,7 @@ contourpy==1.1.1
6262
# via
6363
# -c requirements/base.txt
6464
# matplotlib
65-
cycler==0.11.0
65+
cycler==0.12.0
6666
# via
6767
# -c requirements/base.txt
6868
# matplotlib
@@ -76,11 +76,11 @@ exceptiongroup==1.1.3
7676
# via
7777
# -c requirements/test.txt
7878
# anyio
79-
executing==1.2.0
79+
executing==2.0.0
8080
# via stack-data
81-
fastjsonschema==2.18.0
81+
fastjsonschema==2.18.1
8282
# via nbformat
83-
fonttools==4.42.1
83+
fonttools==4.43.0
8484
# via
8585
# -c requirements/base.txt
8686
# matplotlib
@@ -114,7 +114,7 @@ ipykernel==6.25.2
114114
# jupyter-console
115115
# jupyterlab
116116
# qtconsole
117-
ipython==8.12.2
117+
ipython==8.12.3
118118
# via
119119
# -r requirements/dev.in
120120
# ipykernel
@@ -126,7 +126,7 @@ ipywidgets==8.1.1
126126
# via jupyter
127127
isoduration==20.11.0
128128
# via jsonschema
129-
jedi==0.19.0
129+
jedi==0.19.1
130130
# via ipython
131131
jinja2==3.1.2
132132
# via
@@ -157,7 +157,7 @@ jupyter-client==8.3.1
157157
# qtconsole
158158
jupyter-console==6.6.3
159159
# via jupyter
160-
jupyter-core==5.3.1
160+
jupyter-core==5.3.2
161161
# via
162162
# ipykernel
163163
# jupyter-client
@@ -208,11 +208,11 @@ matplotlib-inline==0.1.6
208208
# via
209209
# ipykernel
210210
# ipython
211-
mistune==3.0.1
211+
mistune==3.0.2
212212
# via nbconvert
213213
nbclient==0.8.0
214214
# via nbconvert
215-
nbconvert==7.8.0
215+
nbconvert==7.9.2
216216
# via
217217
# jupyter
218218
# jupyter-server
@@ -236,7 +236,7 @@ numpy==1.24.4
236236
# matplotlib
237237
overrides==7.4.0
238238
# via jupyter-server
239-
packaging==23.1
239+
packaging==23.2
240240
# via
241241
# -c requirements/base.txt
242242
# -c requirements/test.txt
@@ -266,7 +266,7 @@ pip-tools==7.3.0
266266
# via -r requirements/dev.in
267267
pkgutil-resolve-name==1.3.10
268268
# via jsonschema
269-
platformdirs==3.10.0
269+
platformdirs==3.11.0
270270
# via
271271
# -c requirements/test.txt
272272
# jupyter-core
@@ -346,7 +346,7 @@ rfc3986-validator==0.1.1
346346
# via
347347
# jsonschema
348348
# jupyter-events
349-
rpds-py==0.10.3
349+
rpds-py==0.10.4
350350
# via
351351
# jsonschema
352352
# referencing
@@ -365,7 +365,7 @@ sniffio==1.3.0
365365
# anyio
366366
soupsieve==2.5
367367
# via beautifulsoup4
368-
stack-data==0.6.2
368+
stack-data==0.6.3
369369
# via ipython
370370
terminado==0.17.1
371371
# via
@@ -388,7 +388,7 @@ tornado==6.3.3
388388
# jupyterlab
389389
# notebook
390390
# terminado
391-
traitlets==5.10.0
391+
traitlets==5.11.2
392392
# via
393393
# comm
394394
# ipykernel
@@ -405,6 +405,8 @@ traitlets==5.10.0
405405
# nbconvert
406406
# nbformat
407407
# qtconsole
408+
types-python-dateutil==2.8.19.14
409+
# via arrow
408410
typing-extensions==4.8.0
409411
# via
410412
# -c requirements/base.txt
@@ -413,12 +415,12 @@ typing-extensions==4.8.0
413415
# ipython
414416
uri-template==1.3.0
415417
# via jsonschema
416-
urllib3==2.0.5
418+
urllib3==2.0.6
417419
# via
418420
# -c requirements/base.txt
419421
# -c requirements/test.txt
420422
# requests
421-
wcwidth==0.2.6
423+
wcwidth==0.2.8
422424
# via prompt-toolkit
423425
webcolors==1.13
424426
# via jsonschema

requirements/test.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ certifi==2023.7.22
1414
# httpcore
1515
# httpx
1616
# requests
17-
charset-normalizer==3.2.0
17+
charset-normalizer==3.3.0
1818
# via
1919
# -c requirements/base.txt
2020
# requests
2121
click==8.1.7
2222
# via
2323
# -r requirements/test.in
2424
# black
25-
coverage[toml]==7.3.1
25+
coverage[toml]==7.3.2
2626
# via
2727
# -r requirements/test.in
2828
# pytest-cov
@@ -40,7 +40,7 @@ flake8==6.1.0
4040
# flake8-docstrings
4141
flake8-docstrings==1.7.0
4242
# via -r requirements/test.in
43-
fsspec==2023.9.1
43+
fsspec==2023.9.2
4444
# via
4545
# -c requirements/base.txt
4646
# huggingface-hub
@@ -50,7 +50,7 @@ httpcore==0.18.0
5050
# via httpx
5151
httpx==0.25.0
5252
# via -r requirements/test.in
53-
huggingface-hub==0.17.2
53+
huggingface-hub==0.16.4
5454
# via
5555
# -c requirements/base.txt
5656
# -r requirements/test.in
@@ -70,7 +70,7 @@ mypy-extensions==1.0.0
7070
# via
7171
# black
7272
# mypy
73-
packaging==23.1
73+
packaging==23.2
7474
# via
7575
# -c requirements/base.txt
7676
# black
@@ -86,7 +86,7 @@ pillow==10.0.1
8686
# via
8787
# -c requirements/base.txt
8888
# pdf2image
89-
platformdirs==3.10.0
89+
platformdirs==3.11.0
9090
# via black
9191
pluggy==1.3.0
9292
# via pytest
@@ -112,7 +112,7 @@ requests==2.31.0
112112
# via
113113
# -c requirements/base.txt
114114
# huggingface-hub
115-
ruff==0.0.290
115+
ruff==0.0.292
116116
# via -r requirements/test.in
117117
sniffio==1.3.0
118118
# via
@@ -137,7 +137,7 @@ typing-extensions==4.8.0
137137
# black
138138
# huggingface-hub
139139
# mypy
140-
urllib3==2.0.5
140+
urllib3==2.0.6
141141
# via
142142
# -c requirements/base.txt
143143
# requests
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.7.0" # pragma: no cover
1+
__version__ = "0.7.1" # pragma: no cover

0 commit comments

Comments
 (0)