Add shape inference for textual models
Browse files- .gitignore +1 -0
- README.md +98 -98
- convert.py +1 -1
- poetry.lock +51 -45
- pyproject.toml +1 -0
- variants.py +28 -24
.gitignore
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
__pycache__
|
2 |
.venv
|
|
|
|
1 |
__pycache__
|
2 |
.venv
|
3 |
+
converted
|
README.md
CHANGED
@@ -121,104 +121,104 @@ The models were converted into multiple data types as well.
|
|
121 |
|
122 |
## Variants
|
123 |
|
124 |
-
| Path | Model ID | Mode | Data Type
|
125 |
-
|
126 |
-
| models/clip-resnet-50-visual.onnx
|
127 |
-
| models/clip-resnet-50-visual-float16.onnx | resnet-50 | visual | float16
|
128 |
-
| models/clip-resnet-50-visual-qint8.onnx | resnet-50 | visual | qint8
|
129 |
-
| models/clip-resnet-50-visual-quint8.onnx | resnet-50 | visual | quint8
|
130 |
-
| models/clip-resnet-50-textual.onnx
|
131 |
-
| models/clip-resnet-50-textual-float16.onnx | resnet-50 | textual | float16
|
132 |
-
| models/clip-resnet-50-textual-qint8.onnx | resnet-50 | textual | qint8
|
133 |
-
| models/clip-resnet-50-textual-quint8.onnx | resnet-50 | textual | quint8
|
134 |
-
| models/clip-resnet-101-visual.onnx
|
135 |
-
| models/clip-resnet-101-visual-float16.onnx | resnet-101 | visual | float16
|
136 |
-
| models/clip-resnet-101-visual-qint8.onnx | resnet-101 | visual | qint8
|
137 |
-
| models/clip-resnet-101-visual-quint8.onnx | resnet-101 | visual | quint8
|
138 |
-
| models/clip-resnet-101-textual.onnx
|
139 |
-
| models/clip-resnet-101-textual-float16.onnx | resnet-101 | textual | float16
|
140 |
-
| models/clip-resnet-101-textual-qint8.onnx | resnet-101 | textual | qint8
|
141 |
-
| models/clip-resnet-101-textual-quint8.onnx | resnet-101 | textual | quint8
|
142 |
-
| models/clip-resnet-50x4-visual.onnx
|
143 |
-
| models/clip-resnet-50x4-visual-float16.onnx | resnet-50x4 | visual | float16
|
144 |
-
| models/clip-resnet-50x4-visual-qint8.onnx | resnet-50x4 | visual | qint8
|
145 |
-
| models/clip-resnet-50x4-visual-quint8.onnx | resnet-50x4 | visual | quint8
|
146 |
-
| models/clip-resnet-50x4-textual.onnx
|
147 |
-
| models/clip-resnet-50x4-textual-float16.onnx | resnet-50x4 | textual | float16
|
148 |
-
| models/clip-resnet-50x4-textual-qint8.onnx | resnet-50x4 | textual | qint8
|
149 |
-
| models/clip-resnet-50x4-textual-quint8.onnx | resnet-50x4 | textual | quint8
|
150 |
-
| models/clip-resnet-50x16-visual.onnx
|
151 |
-
| models/clip-resnet-50x16-visual-float16.onnx | resnet-50x16 | visual | float16
|
152 |
-
| models/clip-resnet-50x16-visual-qint8.onnx | resnet-50x16 | visual | qint8
|
153 |
-
| models/clip-resnet-50x16-visual-quint8.onnx | resnet-50x16 | visual | quint8
|
154 |
-
| models/clip-resnet-50x16-textual.onnx
|
155 |
-
| models/clip-resnet-50x16-textual-float16.onnx | resnet-50x16 | textual | float16
|
156 |
-
| models/clip-resnet-50x16-textual-qint8.onnx | resnet-50x16 | textual | qint8
|
157 |
-
| models/clip-resnet-50x16-textual-quint8.onnx | resnet-50x16 | textual | quint8
|
158 |
-
| models/clip-resnet-50x64-visual.onnx
|
159 |
-
| models/clip-resnet-50x64-visual-float16.onnx | resnet-50x64 | visual | float16
|
160 |
-
| models/clip-resnet-50x64-visual-qint8.onnx | resnet-50x64 | visual | qint8
|
161 |
-
| models/clip-resnet-50x64-visual-quint8.onnx | resnet-50x64 | visual | quint8
|
162 |
-
| models/clip-resnet-50x64-textual.onnx
|
163 |
-
| models/clip-resnet-50x64-textual-float16.onnx | resnet-50x64 | textual | float16
|
164 |
-
| models/clip-resnet-50x64-textual-qint8.onnx | resnet-50x64 | textual | qint8
|
165 |
-
| models/clip-resnet-50x64-textual-quint8.onnx | resnet-50x64 | textual | quint8
|
166 |
-
| models/clip-resnet-50-visual.onnx
|
167 |
-
| models/clip-resnet-50-visual-float16.onnx | resnet-50 | visual | float16
|
168 |
-
| models/clip-resnet-50-visual-qint8.onnx | resnet-50 | visual | qint8
|
169 |
-
| models/clip-resnet-50-visual-quint8.onnx | resnet-50 | visual | quint8
|
170 |
-
| models/clip-resnet-50-textual.onnx
|
171 |
-
| models/clip-resnet-50-textual-float16.onnx | resnet-50 | textual | float16
|
172 |
-
| models/clip-resnet-50-textual-qint8.onnx | resnet-50 | textual | qint8
|
173 |
-
| models/clip-resnet-50-textual-quint8.onnx | resnet-50 | textual | quint8
|
174 |
-
| models/clip-resnet-50-visual.onnx
|
175 |
-
| models/clip-resnet-50-visual-float16.onnx | resnet-50 | visual | float16
|
176 |
-
| models/clip-resnet-50-visual-qint8.onnx | resnet-50 | visual | qint8
|
177 |
-
| models/clip-resnet-50-visual-quint8.onnx | resnet-50 | visual | quint8
|
178 |
-
| models/clip-resnet-50-textual.onnx
|
179 |
-
| models/clip-resnet-50-textual-float16.onnx | resnet-50 | textual | float16
|
180 |
-
| models/clip-resnet-50-textual-qint8.onnx | resnet-50 | textual | qint8
|
181 |
-
| models/clip-resnet-50-textual-quint8.onnx | resnet-50 | textual | quint8
|
182 |
-
| models/clip-resnet-50-visual.onnx
|
183 |
-
| models/clip-resnet-50-visual-float16.onnx | resnet-50 | visual | float16
|
184 |
-
| models/clip-resnet-50-visual-qint8.onnx | resnet-50 | visual | qint8
|
185 |
-
| models/clip-resnet-50-visual-quint8.onnx | resnet-50 | visual | quint8
|
186 |
-
| models/clip-resnet-50-textual.onnx
|
187 |
-
| models/clip-resnet-50-textual-float16.onnx | resnet-50 | textual | float16
|
188 |
-
| models/clip-resnet-50-textual-qint8.onnx | resnet-50 | textual | qint8
|
189 |
-
| models/clip-resnet-50-textual-quint8.onnx | resnet-50 | textual | quint8
|
190 |
-
| models/clip-vit-base-patch16-visual.onnx
|
191 |
-
| models/clip-vit-base-patch16-visual-float16.onnx | vit-base-patch16 | visual | float16
|
192 |
-
| models/clip-vit-base-patch16-visual-qint8.onnx | vit-base-patch16 | visual | qint8
|
193 |
-
| models/clip-vit-base-patch16-visual-quint8.onnx | vit-base-patch16 | visual | quint8
|
194 |
-
| models/clip-vit-base-patch16-textual.onnx
|
195 |
-
| models/clip-vit-base-patch16-textual-float16.onnx | vit-base-patch16 | textual | float16
|
196 |
-
| models/clip-vit-base-patch16-textual-qint8.onnx | vit-base-patch16 | textual | qint8
|
197 |
-
| models/clip-vit-base-patch16-textual-quint8.onnx | vit-base-patch16 | textual | quint8
|
198 |
-
| models/clip-vit-base-patch32-visual.onnx
|
199 |
-
| models/clip-vit-base-patch32-visual-float16.onnx | vit-base-patch32 | visual | float16
|
200 |
-
| models/clip-vit-base-patch32-visual-qint8.onnx | vit-base-patch32 | visual | qint8
|
201 |
-
| models/clip-vit-base-patch32-visual-quint8.onnx | vit-base-patch32 | visual | quint8
|
202 |
-
| models/clip-vit-base-patch32-textual.onnx
|
203 |
-
| models/clip-vit-base-patch32-textual-float16.onnx | vit-base-patch32 | textual | float16
|
204 |
-
| models/clip-vit-base-patch32-textual-qint8.onnx | vit-base-patch32 | textual | qint8
|
205 |
-
| models/clip-vit-base-patch32-textual-quint8.onnx | vit-base-patch32 | textual | quint8
|
206 |
-
| models/clip-vit-large-patch14-visual.onnx
|
207 |
-
| models/clip-vit-large-patch14-visual-float16.onnx | vit-large-patch14 | visual | float16
|
208 |
-
| models/clip-vit-large-patch14-visual-qint8.onnx | vit-large-patch14 | visual | qint8
|
209 |
-
| models/clip-vit-large-patch14-visual-quint8.onnx | vit-large-patch14 | visual | quint8
|
210 |
-
| models/clip-vit-large-patch14-textual.onnx
|
211 |
-
| models/clip-vit-large-patch14-textual-float16.onnx | vit-large-patch14 | textual | float16
|
212 |
-
| models/clip-vit-large-patch14-textual-qint8.onnx | vit-large-patch14 | textual | qint8
|
213 |
-
| models/clip-vit-large-patch14-textual-quint8.onnx | vit-large-patch14 | textual | quint8
|
214 |
-
| models/clip-vit-large-patch14-336-visual.onnx
|
215 |
-
| models/clip-vit-large-patch14-336-visual-float16.onnx | vit-large-patch14-336 | visual | float16
|
216 |
-
| models/clip-vit-large-patch14-336-visual-qint8.onnx | vit-large-patch14-336 | visual | qint8
|
217 |
-
| models/clip-vit-large-patch14-336-visual-quint8.onnx | vit-large-patch14-336 | visual | quint8
|
218 |
-
| models/clip-vit-large-patch14-336-textual.onnx
|
219 |
-
| models/clip-vit-large-patch14-336-textual-float16.onnx | vit-large-patch14-336 | textual | float16
|
220 |
-
| models/clip-vit-large-patch14-336-textual-qint8.onnx | vit-large-patch14-336 | textual | qint8
|
221 |
-
| models/clip-vit-large-patch14-336-textual-quint8.onnx | vit-large-patch14-336 | textual | quint8
|
222 |
|
223 |
[onnx]: https://onnx.ai/
|
224 |
[clip]: https://github.com/openai/CLIP
|
|
|
121 |
|
122 |
## Variants
|
123 |
|
124 |
+
| Path | Model ID | Mode | Data Type | Available | Size (MB) |
|
125 |
+
|--------------------------------------------------------|-----------------------|---------|-------------|-------------|-------------|
|
126 |
+
| models/clip-resnet-50-visual-float32.onnx | resnet-50 | visual | float32 | β
| 153 |
|
127 |
+
| models/clip-resnet-50-visual-float16.onnx | resnet-50 | visual | float16 | β
| 77 |
|
128 |
+
| models/clip-resnet-50-visual-qint8.onnx | resnet-50 | visual | qint8 | β
| 39 |
|
129 |
+
| models/clip-resnet-50-visual-quint8.onnx | resnet-50 | visual | quint8 | β
| 39 |
|
130 |
+
| models/clip-resnet-50-textual-float32.onnx | resnet-50 | textual | float32 | β
| 255 |
|
131 |
+
| models/clip-resnet-50-textual-float16.onnx | resnet-50 | textual | float16 | β
| 128 |
|
132 |
+
| models/clip-resnet-50-textual-qint8.onnx | resnet-50 | textual | qint8 | β
| 64 |
|
133 |
+
| models/clip-resnet-50-textual-quint8.onnx | resnet-50 | textual | quint8 | β
| 64 |
|
134 |
+
| models/clip-resnet-101-visual-float32.onnx | resnet-101 | visual | float32 | β
| 225 |
|
135 |
+
| models/clip-resnet-101-visual-float16.onnx | resnet-101 | visual | float16 | β
| 112 |
|
136 |
+
| models/clip-resnet-101-visual-qint8.onnx | resnet-101 | visual | qint8 | β
| 57 |
|
137 |
+
| models/clip-resnet-101-visual-quint8.onnx | resnet-101 | visual | quint8 | β
| 57 |
|
138 |
+
| models/clip-resnet-101-textual-float32.onnx | resnet-101 | textual | float32 | β
| 254 |
|
139 |
+
| models/clip-resnet-101-textual-float16.onnx | resnet-101 | textual | float16 | β
| 127 |
|
140 |
+
| models/clip-resnet-101-textual-qint8.onnx | resnet-101 | textual | qint8 | β
| 64 |
|
141 |
+
| models/clip-resnet-101-textual-quint8.onnx | resnet-101 | textual | quint8 | β
| 64 |
|
142 |
+
| models/clip-resnet-50x4-visual-float32.onnx | resnet-50x4 | visual | float32 | β
| 348 |
|
143 |
+
| models/clip-resnet-50x4-visual-float16.onnx | resnet-50x4 | visual | float16 | β
| 174 |
|
144 |
+
| models/clip-resnet-50x4-visual-qint8.onnx | resnet-50x4 | visual | qint8 | β
| 88 |
|
145 |
+
| models/clip-resnet-50x4-visual-quint8.onnx | resnet-50x4 | visual | quint8 | β
| 88 |
|
146 |
+
| models/clip-resnet-50x4-textual-float32.onnx | resnet-50x4 | textual | float32 | β
| 365 |
|
147 |
+
| models/clip-resnet-50x4-textual-float16.onnx | resnet-50x4 | textual | float16 | β
| 183 |
|
148 |
+
| models/clip-resnet-50x4-textual-qint8.onnx | resnet-50x4 | textual | qint8 | β
| 92 |
|
149 |
+
| models/clip-resnet-50x4-textual-quint8.onnx | resnet-50x4 | textual | quint8 | β
| 92 |
|
150 |
+
| models/clip-resnet-50x16-visual-float32.onnx | resnet-50x16 | visual | float32 | β
| 669 |
|
151 |
+
| models/clip-resnet-50x16-visual-float16.onnx | resnet-50x16 | visual | float16 | β
| 335 |
|
152 |
+
| models/clip-resnet-50x16-visual-qint8.onnx | resnet-50x16 | visual | qint8 | β
| 169 |
|
153 |
+
| models/clip-resnet-50x16-visual-quint8.onnx | resnet-50x16 | visual | quint8 | β
| 169 |
|
154 |
+
| models/clip-resnet-50x16-textual-float32.onnx | resnet-50x16 | textual | float32 | β
| 495 |
|
155 |
+
| models/clip-resnet-50x16-textual-float16.onnx | resnet-50x16 | textual | float16 | β
| 248 |
|
156 |
+
| models/clip-resnet-50x16-textual-qint8.onnx | resnet-50x16 | textual | qint8 | β
| 124 |
|
157 |
+
| models/clip-resnet-50x16-textual-quint8.onnx | resnet-50x16 | textual | quint8 | β
| 124 |
|
158 |
+
| models/clip-resnet-50x64-visual-float32.onnx | resnet-50x64 | visual | float32 | β
| 1681 |
|
159 |
+
| models/clip-resnet-50x64-visual-float16.onnx | resnet-50x64 | visual | float16 | β
| 840 |
|
160 |
+
| models/clip-resnet-50x64-visual-qint8.onnx | resnet-50x64 | visual | qint8 | β
| 424 |
|
161 |
+
| models/clip-resnet-50x64-visual-quint8.onnx | resnet-50x64 | visual | quint8 | β
| 424 |
|
162 |
+
| models/clip-resnet-50x64-textual-float32.onnx | resnet-50x64 | textual | float32 | β
| 812 |
|
163 |
+
| models/clip-resnet-50x64-textual-float16.onnx | resnet-50x64 | textual | float16 | β
| 406 |
|
164 |
+
| models/clip-resnet-50x64-textual-qint8.onnx | resnet-50x64 | textual | qint8 | β
| 204 |
|
165 |
+
| models/clip-resnet-50x64-textual-quint8.onnx | resnet-50x64 | textual | quint8 | β
| 204 |
|
166 |
+
| models/clip-resnet-50-visual-float32.onnx | resnet-50 | visual | float32 | β
| 153 |
|
167 |
+
| models/clip-resnet-50-visual-float16.onnx | resnet-50 | visual | float16 | β
| 77 |
|
168 |
+
| models/clip-resnet-50-visual-qint8.onnx | resnet-50 | visual | qint8 | β
| 39 |
|
169 |
+
| models/clip-resnet-50-visual-quint8.onnx | resnet-50 | visual | quint8 | β
| 39 |
|
170 |
+
| models/clip-resnet-50-textual-float32.onnx | resnet-50 | textual | float32 | β
| 255 |
|
171 |
+
| models/clip-resnet-50-textual-float16.onnx | resnet-50 | textual | float16 | β
| 128 |
|
172 |
+
| models/clip-resnet-50-textual-qint8.onnx | resnet-50 | textual | qint8 | β
| 64 |
|
173 |
+
| models/clip-resnet-50-textual-quint8.onnx | resnet-50 | textual | quint8 | β
| 64 |
|
174 |
+
| models/clip-resnet-50-visual-float32.onnx | resnet-50 | visual | float32 | β
| 153 |
|
175 |
+
| models/clip-resnet-50-visual-float16.onnx | resnet-50 | visual | float16 | β
| 77 |
|
176 |
+
| models/clip-resnet-50-visual-qint8.onnx | resnet-50 | visual | qint8 | β
| 39 |
|
177 |
+
| models/clip-resnet-50-visual-quint8.onnx | resnet-50 | visual | quint8 | β
| 39 |
|
178 |
+
| models/clip-resnet-50-textual-float32.onnx | resnet-50 | textual | float32 | β
| 255 |
|
179 |
+
| models/clip-resnet-50-textual-float16.onnx | resnet-50 | textual | float16 | β
| 128 |
|
180 |
+
| models/clip-resnet-50-textual-qint8.onnx | resnet-50 | textual | qint8 | β
| 64 |
|
181 |
+
| models/clip-resnet-50-textual-quint8.onnx | resnet-50 | textual | quint8 | β
| 64 |
|
182 |
+
| models/clip-resnet-50-visual-float32.onnx | resnet-50 | visual | float32 | β
| 153 |
|
183 |
+
| models/clip-resnet-50-visual-float16.onnx | resnet-50 | visual | float16 | β
| 77 |
|
184 |
+
| models/clip-resnet-50-visual-qint8.onnx | resnet-50 | visual | qint8 | β
| 39 |
|
185 |
+
| models/clip-resnet-50-visual-quint8.onnx | resnet-50 | visual | quint8 | β
| 39 |
|
186 |
+
| models/clip-resnet-50-textual-float32.onnx | resnet-50 | textual | float32 | β
| 255 |
|
187 |
+
| models/clip-resnet-50-textual-float16.onnx | resnet-50 | textual | float16 | β
| 128 |
|
188 |
+
| models/clip-resnet-50-textual-qint8.onnx | resnet-50 | textual | qint8 | β
| 64 |
|
189 |
+
| models/clip-resnet-50-textual-quint8.onnx | resnet-50 | textual | quint8 | β
| 64 |
|
190 |
+
| models/clip-vit-base-patch16-visual-float32.onnx | vit-base-patch16 | visual | float32 | β
| 345 |
|
191 |
+
| models/clip-vit-base-patch16-visual-float16.onnx | vit-base-patch16 | visual | float16 | β
| 173 |
|
192 |
+
| models/clip-vit-base-patch16-visual-qint8.onnx | vit-base-patch16 | visual | qint8 | β
| 87 |
|
193 |
+
| models/clip-vit-base-patch16-visual-quint8.onnx | vit-base-patch16 | visual | quint8 | β
| 87 |
|
194 |
+
| models/clip-vit-base-patch16-textual-float32.onnx | vit-base-patch16 | textual | float32 | β
| 254 |
|
195 |
+
| models/clip-vit-base-patch16-textual-float16.onnx | vit-base-patch16 | textual | float16 | β
| 127 |
|
196 |
+
| models/clip-vit-base-patch16-textual-qint8.onnx | vit-base-patch16 | textual | qint8 | β
| 64 |
|
197 |
+
| models/clip-vit-base-patch16-textual-quint8.onnx | vit-base-patch16 | textual | quint8 | β
| 64 |
|
198 |
+
| models/clip-vit-base-patch32-visual-float32.onnx | vit-base-patch32 | visual | float32 | β
| 352 |
|
199 |
+
| models/clip-vit-base-patch32-visual-float16.onnx | vit-base-patch32 | visual | float16 | β
| 176 |
|
200 |
+
| models/clip-vit-base-patch32-visual-qint8.onnx | vit-base-patch32 | visual | qint8 | β
| 89 |
|
201 |
+
| models/clip-vit-base-patch32-visual-quint8.onnx | vit-base-patch32 | visual | quint8 | β
| 89 |
|
202 |
+
| models/clip-vit-base-patch32-textual-float32.onnx | vit-base-patch32 | textual | float32 | β
| 254 |
|
203 |
+
| models/clip-vit-base-patch32-textual-float16.onnx | vit-base-patch32 | textual | float16 | β
| 127 |
|
204 |
+
| models/clip-vit-base-patch32-textual-qint8.onnx | vit-base-patch32 | textual | qint8 | β
| 64 |
|
205 |
+
| models/clip-vit-base-patch32-textual-quint8.onnx | vit-base-patch32 | textual | quint8 | β
| 64 |
|
206 |
+
| models/clip-vit-large-patch14-visual-float32.onnx | vit-large-patch14 | visual | float32 | β
| 1216 |
|
207 |
+
| models/clip-vit-large-patch14-visual-float16.onnx | vit-large-patch14 | visual | float16 | β
| 608 |
|
208 |
+
| models/clip-vit-large-patch14-visual-qint8.onnx | vit-large-patch14 | visual | qint8 | β
| 306 |
|
209 |
+
| models/clip-vit-large-patch14-visual-quint8.onnx | vit-large-patch14 | visual | quint8 | β
| 306 |
|
210 |
+
| models/clip-vit-large-patch14-textual-float32.onnx | vit-large-patch14 | textual | float32 | β
| 495 |
|
211 |
+
| models/clip-vit-large-patch14-textual-float16.onnx | vit-large-patch14 | textual | float16 | β
| 248 |
|
212 |
+
| models/clip-vit-large-patch14-textual-qint8.onnx | vit-large-patch14 | textual | qint8 | β
| 124 |
|
213 |
+
| models/clip-vit-large-patch14-textual-quint8.onnx | vit-large-patch14 | textual | quint8 | β
| 124 |
|
214 |
+
| models/clip-vit-large-patch14-336-visual-float32.onnx | vit-large-patch14-336 | visual | float32 | β
| 1217 |
|
215 |
+
| models/clip-vit-large-patch14-336-visual-float16.onnx | vit-large-patch14-336 | visual | float16 | β
| 609 |
|
216 |
+
| models/clip-vit-large-patch14-336-visual-qint8.onnx | vit-large-patch14-336 | visual | qint8 | β
| 307 |
|
217 |
+
| models/clip-vit-large-patch14-336-visual-quint8.onnx | vit-large-patch14-336 | visual | quint8 | β
| 307 |
|
218 |
+
| models/clip-vit-large-patch14-336-textual-float32.onnx | vit-large-patch14-336 | textual | float32 | β
| 495 |
|
219 |
+
| models/clip-vit-large-patch14-336-textual-float16.onnx | vit-large-patch14-336 | textual | float16 | β
| 248 |
|
220 |
+
| models/clip-vit-large-patch14-336-textual-qint8.onnx | vit-large-patch14-336 | textual | qint8 | β
| 124 |
|
221 |
+
| models/clip-vit-large-patch14-336-textual-quint8.onnx | vit-large-patch14-336 | textual | quint8 | β
| 124 |
|
222 |
|
223 |
[onnx]: https://onnx.ai/
|
224 |
[clip]: https://github.com/openai/CLIP
|
convert.py
CHANGED
@@ -70,7 +70,7 @@ def convert(model_name, dashed_name):
|
|
70 |
|
71 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
72 |
device = "cpu"
|
73 |
-
output_dir = "
|
74 |
if __name__ == "__main__":
|
75 |
print(f"Torch device: {device}")
|
76 |
|
|
|
70 |
|
71 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
72 |
device = "cpu"
|
73 |
+
output_dir = "converted"
|
74 |
if __name__ == "__main__":
|
75 |
print(f"Torch device: {device}")
|
76 |
|
poetry.lock
CHANGED
@@ -132,7 +132,7 @@ python-versions = ">=3.8"
|
|
132 |
|
133 |
[[package]]
|
134 |
name = "onnx"
|
135 |
-
version = "1.
|
136 |
description = "Open Neural Network Exchange"
|
137 |
category = "main"
|
138 |
optional = false
|
@@ -140,11 +140,11 @@ python-versions = "*"
|
|
140 |
|
141 |
[package.dependencies]
|
142 |
numpy = ">=1.16.6"
|
143 |
-
protobuf = ">=3.12.2"
|
144 |
typing-extensions = ">=3.6.2.1"
|
145 |
|
146 |
[package.extras]
|
147 |
-
|
148 |
|
149 |
[[package]]
|
150 |
name = "onnxconverter-common"
|
@@ -213,8 +213,8 @@ tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "pa
|
|
213 |
|
214 |
[[package]]
|
215 |
name = "protobuf"
|
216 |
-
version = "
|
217 |
-
description = ""
|
218 |
category = "main"
|
219 |
optional = false
|
220 |
python-versions = ">=3.7"
|
@@ -429,7 +429,7 @@ python-versions = "*"
|
|
429 |
[metadata]
|
430 |
lock-version = "1.1"
|
431 |
python-versions = "^3.9"
|
432 |
-
content-hash = "
|
433 |
|
434 |
[metadata.files]
|
435 |
certifi = [
|
@@ -503,31 +503,27 @@ numpy = [
|
|
503 |
{file = "numpy-1.23.3.tar.gz", hash = "sha256:51bf49c0cd1d52be0a240aa66f3458afc4b95d8993d2d04f0d91fa60c10af6cd"},
|
504 |
]
|
505 |
onnx = [
|
506 |
-
{file = "onnx-1.
|
507 |
-
{file = "onnx-1.
|
508 |
-
{file = "onnx-1.
|
509 |
-
{file = "onnx-1.
|
510 |
-
{file = "onnx-1.
|
511 |
-
{file = "onnx-1.
|
512 |
-
{file = "onnx-1.
|
513 |
-
{file = "onnx-1.
|
514 |
-
{file = "onnx-1.
|
515 |
-
{file = "onnx-1.
|
516 |
-
{file = "onnx-1.
|
517 |
-
{file = "onnx-1.
|
518 |
-
{file = "onnx-1.
|
519 |
-
{file = "onnx-1.
|
520 |
-
{file = "onnx-1.
|
521 |
-
{file = "onnx-1.
|
522 |
-
{file = "onnx-1.
|
523 |
-
{file = "onnx-1.
|
524 |
-
{file = "onnx-1.
|
525 |
-
{file = "onnx-1.
|
526 |
-
{file = "onnx-1.
|
527 |
-
{file = "onnx-1.11.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:43b32a2f20c94aa98866deae9e4218faf0495144ad05402e918fa279674b6df9"},
|
528 |
-
{file = "onnx-1.11.0-cp39-cp39-win32.whl", hash = "sha256:7924d9baa13dbbf335737229f6d068f380d153679f357e495da60007b61cf56d"},
|
529 |
-
{file = "onnx-1.11.0-cp39-cp39-win_amd64.whl", hash = "sha256:3403884c482859f8cf2e0c276da84bd9ac2235d266726f4ddc9625d3fd263218"},
|
530 |
-
{file = "onnx-1.11.0.tar.gz", hash = "sha256:eca224c7c2c8ee4072a0743e4898a84a9bdf8297b5e5910a2632e4c4182ffb2a"},
|
531 |
]
|
532 |
onnxconverter-common = [
|
533 |
{file = "onnxconverter_common-1.12.2-py2.py3-none-any.whl", hash = "sha256:29b7caade27aeda1b827232554cec352db8afc6e16c3e3ea8c4264449f9ff3a6"},
|
@@ -629,20 +625,30 @@ Pillow = [
|
|
629 |
{file = "Pillow-9.2.0.tar.gz", hash = "sha256:75e636fd3e0fb872693f23ccb8a5ff2cd578801251f3a4f6854c6a5d437d3c04"},
|
630 |
]
|
631 |
protobuf = [
|
632 |
-
{file = "protobuf-
|
633 |
-
{file = "protobuf-
|
634 |
-
{file = "protobuf-
|
635 |
-
{file = "protobuf-
|
636 |
-
{file = "protobuf-
|
637 |
-
{file = "protobuf-
|
638 |
-
{file = "protobuf-
|
639 |
-
{file = "protobuf-
|
640 |
-
{file = "protobuf-
|
641 |
-
{file = "protobuf-
|
642 |
-
{file = "protobuf-
|
643 |
-
{file = "protobuf-
|
644 |
-
{file = "protobuf-
|
645 |
-
{file = "protobuf-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
646 |
]
|
647 |
pyparsing = [
|
648 |
{file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"},
|
|
|
132 |
|
133 |
[[package]]
|
134 |
name = "onnx"
|
135 |
+
version = "1.12.0"
|
136 |
description = "Open Neural Network Exchange"
|
137 |
category = "main"
|
138 |
optional = false
|
|
|
140 |
|
141 |
[package.dependencies]
|
142 |
numpy = ">=1.16.6"
|
143 |
+
protobuf = ">=3.12.2,<=3.20.1"
|
144 |
typing-extensions = ">=3.6.2.1"
|
145 |
|
146 |
[package.extras]
|
147 |
+
lint = ["clang-format (==13.0.0)", "flake8", "mypy (==0.782)", "types-protobuf (==3.18.4)"]
|
148 |
|
149 |
[[package]]
|
150 |
name = "onnxconverter-common"
|
|
|
213 |
|
214 |
[[package]]
|
215 |
name = "protobuf"
|
216 |
+
version = "3.20.1"
|
217 |
+
description = "Protocol Buffers"
|
218 |
category = "main"
|
219 |
optional = false
|
220 |
python-versions = ">=3.7"
|
|
|
429 |
[metadata]
|
430 |
lock-version = "1.1"
|
431 |
python-versions = "^3.9"
|
432 |
+
content-hash = "52a34bba9b18b5fe6103778b608b973043ecb22db0162a3e721ee41229962029"
|
433 |
|
434 |
[metadata.files]
|
435 |
certifi = [
|
|
|
503 |
{file = "numpy-1.23.3.tar.gz", hash = "sha256:51bf49c0cd1d52be0a240aa66f3458afc4b95d8993d2d04f0d91fa60c10af6cd"},
|
504 |
]
|
505 |
onnx = [
|
506 |
+
{file = "onnx-1.12.0-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:bdbd2578424c70836f4d0f9dda16c21868ddb07cc8192f9e8a176908b43d694b"},
|
507 |
+
{file = "onnx-1.12.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:213e73610173f6b2e99f99a4b0636f80b379c417312079d603806e48ada4ca8b"},
|
508 |
+
{file = "onnx-1.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9fd2f4e23078df197bb76a59b9cd8f5a43a6ad2edc035edb3ecfb9042093e05a"},
|
509 |
+
{file = "onnx-1.12.0-cp310-cp310-win32.whl", hash = "sha256:23781594bb8b7ee985de1005b3c601648d5b0568a81e01365c48f91d1f5648e4"},
|
510 |
+
{file = "onnx-1.12.0-cp310-cp310-win_amd64.whl", hash = "sha256:81a3555fd67be2518bf86096299b48fb9154652596219890abfe90bd43a9ec13"},
|
511 |
+
{file = "onnx-1.12.0-cp37-cp37m-macosx_10_12_x86_64.whl", hash = "sha256:5578b93dc6c918cec4dee7fb7d9dd3b09d338301ee64ca8b4f28bc217ed42dca"},
|
512 |
+
{file = "onnx-1.12.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c11162ffc487167da140f1112f49c4f82d815824f06e58bc3095407699f05863"},
|
513 |
+
{file = "onnx-1.12.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:341c7016e23273e9ffa9b6e301eee95b8c37d0f04df7cedbdb169d2c39524c96"},
|
514 |
+
{file = "onnx-1.12.0-cp37-cp37m-win32.whl", hash = "sha256:3c6e6bcffc3f5c1e148df3837dc667fa4c51999788c1b76b0b8fbba607e02da8"},
|
515 |
+
{file = "onnx-1.12.0-cp37-cp37m-win_amd64.whl", hash = "sha256:8a7aa61aea339bd28f310f4af4f52ce6c4b876386228760b16308efd58f95059"},
|
516 |
+
{file = "onnx-1.12.0-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:56ceb7e094c43882b723cfaa107d85ad673cfdf91faeb28d7dcadacca4f43a07"},
|
517 |
+
{file = "onnx-1.12.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b3629e8258db15d4e2c9b7f1be91a3186719dd94661c218c6f5fde3cc7de3d4d"},
|
518 |
+
{file = "onnx-1.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2d9a7db54e75529160337232282a4816cc50667dc7dc34be178fd6f6b79d4705"},
|
519 |
+
{file = "onnx-1.12.0-cp38-cp38-win32.whl", hash = "sha256:fea5156a03398fe0e23248042d8651c1eaac5f6637d4dd683b4c1f1320b9f7b4"},
|
520 |
+
{file = "onnx-1.12.0-cp38-cp38-win_amd64.whl", hash = "sha256:f66d2996e65f490a57b3ae952e4e9189b53cc9fe3f75e601d50d4db2dc1b1cd9"},
|
521 |
+
{file = "onnx-1.12.0-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:c39a7a0352c856f1df30dccf527eb6cb4909052e5eaf6fa2772a637324c526aa"},
|
522 |
+
{file = "onnx-1.12.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fab13feb4d94342aae6d357d480f2e47d41b9f4e584367542b21ca6defda9e0a"},
|
523 |
+
{file = "onnx-1.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c7a9b3ea02c30efc1d2662337e280266aca491a8e86be0d8a657f874b7cccd1e"},
|
524 |
+
{file = "onnx-1.12.0-cp39-cp39-win32.whl", hash = "sha256:f8800f28c746ab06e51ef8449fd1215621f4ddba91be3ffc264658937d38a2af"},
|
525 |
+
{file = "onnx-1.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:af90427ca04c6b7b8107c2021e1273227a3ef1a7a01f3073039cae7855a59833"},
|
526 |
+
{file = "onnx-1.12.0.tar.gz", hash = "sha256:13b3e77d27523b9dbf4f30dfc9c959455859d5e34e921c44f712d69b8369eff9"},
|
|
|
|
|
|
|
|
|
527 |
]
|
528 |
onnxconverter-common = [
|
529 |
{file = "onnxconverter_common-1.12.2-py2.py3-none-any.whl", hash = "sha256:29b7caade27aeda1b827232554cec352db8afc6e16c3e3ea8c4264449f9ff3a6"},
|
|
|
625 |
{file = "Pillow-9.2.0.tar.gz", hash = "sha256:75e636fd3e0fb872693f23ccb8a5ff2cd578801251f3a4f6854c6a5d437d3c04"},
|
626 |
]
|
627 |
protobuf = [
|
628 |
+
{file = "protobuf-3.20.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3cc797c9d15d7689ed507b165cd05913acb992d78b379f6014e013f9ecb20996"},
|
629 |
+
{file = "protobuf-3.20.1-cp310-cp310-manylinux2014_aarch64.whl", hash = "sha256:ff8d8fa42675249bb456f5db06c00de6c2f4c27a065955917b28c4f15978b9c3"},
|
630 |
+
{file = "protobuf-3.20.1-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:cd68be2559e2a3b84f517fb029ee611546f7812b1fdd0aa2ecc9bc6ec0e4fdde"},
|
631 |
+
{file = "protobuf-3.20.1-cp310-cp310-win32.whl", hash = "sha256:9016d01c91e8e625141d24ec1b20fed584703e527d28512aa8c8707f105a683c"},
|
632 |
+
{file = "protobuf-3.20.1-cp310-cp310-win_amd64.whl", hash = "sha256:32ca378605b41fd180dfe4e14d3226386d8d1b002ab31c969c366549e66a2bb7"},
|
633 |
+
{file = "protobuf-3.20.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:9be73ad47579abc26c12024239d3540e6b765182a91dbc88e23658ab71767153"},
|
634 |
+
{file = "protobuf-3.20.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:097c5d8a9808302fb0da7e20edf0b8d4703274d140fd25c5edabddcde43e081f"},
|
635 |
+
{file = "protobuf-3.20.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:e250a42f15bf9d5b09fe1b293bdba2801cd520a9f5ea2d7fb7536d4441811d20"},
|
636 |
+
{file = "protobuf-3.20.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:cdee09140e1cd184ba9324ec1df410e7147242b94b5f8b0c64fc89e38a8ba531"},
|
637 |
+
{file = "protobuf-3.20.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:af0ebadc74e281a517141daad9d0f2c5d93ab78e9d455113719a45a49da9db4e"},
|
638 |
+
{file = "protobuf-3.20.1-cp37-cp37m-win32.whl", hash = "sha256:755f3aee41354ae395e104d62119cb223339a8f3276a0cd009ffabfcdd46bb0c"},
|
639 |
+
{file = "protobuf-3.20.1-cp37-cp37m-win_amd64.whl", hash = "sha256:62f1b5c4cd6c5402b4e2d63804ba49a327e0c386c99b1675c8a0fefda23b2067"},
|
640 |
+
{file = "protobuf-3.20.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:06059eb6953ff01e56a25cd02cca1a9649a75a7e65397b5b9b4e929ed71d10cf"},
|
641 |
+
{file = "protobuf-3.20.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:cb29edb9eab15742d791e1025dd7b6a8f6fcb53802ad2f6e3adcb102051063ab"},
|
642 |
+
{file = "protobuf-3.20.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:69ccfdf3657ba59569c64295b7d51325f91af586f8d5793b734260dfe2e94e2c"},
|
643 |
+
{file = "protobuf-3.20.1-cp38-cp38-win32.whl", hash = "sha256:dd5789b2948ca702c17027c84c2accb552fc30f4622a98ab5c51fcfe8c50d3e7"},
|
644 |
+
{file = "protobuf-3.20.1-cp38-cp38-win_amd64.whl", hash = "sha256:77053d28427a29987ca9caf7b72ccafee011257561259faba8dd308fda9a8739"},
|
645 |
+
{file = "protobuf-3.20.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6f50601512a3d23625d8a85b1638d914a0970f17920ff39cec63aaef80a93fb7"},
|
646 |
+
{file = "protobuf-3.20.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:284f86a6207c897542d7e956eb243a36bb8f9564c1742b253462386e96c6b78f"},
|
647 |
+
{file = "protobuf-3.20.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:7403941f6d0992d40161aa8bb23e12575637008a5a02283a930addc0508982f9"},
|
648 |
+
{file = "protobuf-3.20.1-cp39-cp39-win32.whl", hash = "sha256:db977c4ca738dd9ce508557d4fce0f5aebd105e158c725beec86feb1f6bc20d8"},
|
649 |
+
{file = "protobuf-3.20.1-cp39-cp39-win_amd64.whl", hash = "sha256:7e371f10abe57cee5021797126c93479f59fccc9693dafd6bd5633ab67808a91"},
|
650 |
+
{file = "protobuf-3.20.1-py2.py3-none-any.whl", hash = "sha256:adfc6cf69c7f8c50fd24c793964eef18f0ac321315439d94945820612849c388"},
|
651 |
+
{file = "protobuf-3.20.1.tar.gz", hash = "sha256:adc31566d027f45efe3f44eeb5b1f329da43891634d61c75a5944e9be6dd42c9"},
|
652 |
]
|
653 |
pyparsing = [
|
654 |
{file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"},
|
pyproject.toml
CHANGED
@@ -21,6 +21,7 @@ onnxconverter-common = "^1.12.2"
|
|
21 |
tabulate = "^0.8.10"
|
22 |
numpy = "^1.23.3"
|
23 |
Pillow = "^9.2.0"
|
|
|
24 |
|
25 |
[build-system]
|
26 |
requires = ["poetry-core"]
|
|
|
21 |
tabulate = "^0.8.10"
|
22 |
numpy = "^1.23.3"
|
23 |
Pillow = "^9.2.0"
|
24 |
+
onnx = "^1.12.0"
|
25 |
|
26 |
[build-system]
|
27 |
requires = ["poetry-core"]
|
variants.py
CHANGED
@@ -2,11 +2,16 @@ import onnx
|
|
2 |
import os
|
3 |
import itertools
|
4 |
import argparse
|
|
|
5 |
from onnxconverter_common.float16 import convert_float_to_float16
|
6 |
from onnxruntime.quantization import quantize_dynamic, QuantType
|
|
|
7 |
from multiprocessing import Pool
|
8 |
from tabulate import tabulate
|
9 |
|
|
|
|
|
|
|
10 |
def float16(input, output):
|
11 |
model = onnx.load(input)
|
12 |
model_f16 = convert_float_to_float16(model)
|
@@ -18,6 +23,10 @@ def qint8(input, output):
|
|
18 |
def quint8(input, output):
|
19 |
quantize_dynamic(input, output, weight_type=QuantType.QUInt8)
|
20 |
|
|
|
|
|
|
|
|
|
21 |
def print_table(table):
|
22 |
print(tabulate(table, headers="keys", tablefmt="github"), "\n")
|
23 |
|
@@ -31,19 +40,25 @@ def get_file_mb(path):
|
|
31 |
|
32 |
def convert(name, mode, f, markdown):
|
33 |
fname = f.__name__
|
34 |
-
input = f"
|
35 |
output = f"models/clip-{name}-{mode}-{fname}.onnx"
|
36 |
exists = os.path.exists(output)
|
|
|
|
|
37 |
if exists:
|
38 |
-
|
39 |
-
print(f"{output} exists")
|
40 |
else:
|
41 |
-
if
|
|
|
42 |
print(f"{output} converting")
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
47 |
|
48 |
if __name__ == '__main__':
|
49 |
parser = argparse.ArgumentParser(description='Create variants of converted models')
|
@@ -72,6 +87,7 @@ if __name__ == '__main__':
|
|
72 |
"textual"
|
73 |
]
|
74 |
funcs = [
|
|
|
75 |
float16,
|
76 |
qint8,
|
77 |
quint8,
|
@@ -82,27 +98,15 @@ if __name__ == '__main__':
|
|
82 |
print_table({ "Mode": modes })
|
83 |
print_table({ "Data Type": [f.__name__ for f in funcs] })
|
84 |
variants = itertools.product(names, modes, funcs, [markdown])
|
85 |
-
|
86 |
with Pool(8 if not markdown else 1) as p:
|
87 |
variants_table = p.starmap(convert, variants)
|
88 |
if markdown:
|
89 |
-
# Insert rows for the original models
|
90 |
-
prev_input = ""
|
91 |
-
variants_table_with_originals = []
|
92 |
for row in variants_table:
|
93 |
-
|
94 |
-
output = row[1]
|
95 |
-
if input != prev_input:
|
96 |
-
prev_input = input
|
97 |
-
variants_table_with_originals.append(
|
98 |
-
row[0:1] + row[2:4] + ["float32 (original)", "β
", get_file_mb(input)]
|
99 |
-
)
|
100 |
file_size = get_file_mb(output)
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
# Print
|
105 |
-
print(tabulate(variants_table_with_originals, headers="firstrow", tablefmt="github"))
|
106 |
else:
|
107 |
print("done")
|
108 |
|
|
|
2 |
import os
|
3 |
import itertools
|
4 |
import argparse
|
5 |
+
import shutil
|
6 |
from onnxconverter_common.float16 import convert_float_to_float16
|
7 |
from onnxruntime.quantization import quantize_dynamic, QuantType
|
8 |
+
from onnxruntime.tools.symbolic_shape_infer import SymbolicShapeInference
|
9 |
from multiprocessing import Pool
|
10 |
from tabulate import tabulate
|
11 |
|
12 |
+
def float32(input, output):
|
13 |
+
shutil.copy2(input, output)
|
14 |
+
|
15 |
def float16(input, output):
|
16 |
model = onnx.load(input)
|
17 |
model_f16 = convert_float_to_float16(model)
|
|
|
23 |
def quint8(input, output):
|
24 |
quantize_dynamic(input, output, weight_type=QuantType.QUInt8)
|
25 |
|
26 |
+
def infer_shapes(input, output):
|
27 |
+
out_mp = SymbolicShapeInference.infer_shapes(onnx.load(input))
|
28 |
+
onnx.save(out_mp, output)
|
29 |
+
|
30 |
def print_table(table):
|
31 |
print(tabulate(table, headers="keys", tablefmt="github"), "\n")
|
32 |
|
|
|
40 |
|
41 |
def convert(name, mode, f, markdown):
|
42 |
fname = f.__name__
|
43 |
+
input = f"converted/clip-{name}-{mode}.onnx"
|
44 |
output = f"models/clip-{name}-{mode}-{fname}.onnx"
|
45 |
exists = os.path.exists(output)
|
46 |
+
if markdown:
|
47 |
+
return [output, name, mode, fname, "β
" if exists else "β"]
|
48 |
if exists:
|
49 |
+
print(f"{output} exists")
|
|
|
50 |
else:
|
51 |
+
if mode == "textual":
|
52 |
+
output_temp = f"{output}.temp"
|
53 |
print(f"{output} converting")
|
54 |
+
f(input, output_temp)
|
55 |
+
print(f"{output} running shape inference for TensorRT support")
|
56 |
+
infer_shapes(output_temp, output)
|
57 |
+
os.remove(output_temp)
|
58 |
+
else:
|
59 |
+
print(f"{output} converting")
|
60 |
+
f(input, output)
|
61 |
+
print(f"{output} done")
|
62 |
|
63 |
if __name__ == '__main__':
|
64 |
parser = argparse.ArgumentParser(description='Create variants of converted models')
|
|
|
87 |
"textual"
|
88 |
]
|
89 |
funcs = [
|
90 |
+
float32,
|
91 |
float16,
|
92 |
qint8,
|
93 |
quint8,
|
|
|
98 |
print_table({ "Mode": modes })
|
99 |
print_table({ "Data Type": [f.__name__ for f in funcs] })
|
100 |
variants = itertools.product(names, modes, funcs, [markdown])
|
|
|
101 |
with Pool(8 if not markdown else 1) as p:
|
102 |
variants_table = p.starmap(convert, variants)
|
103 |
if markdown:
|
|
|
|
|
|
|
104 |
for row in variants_table:
|
105 |
+
output = row[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
file_size = get_file_mb(output)
|
107 |
+
row.append(file_size)
|
108 |
+
variants_table.insert(0, ["Path", "Model ID", "Mode", "Data Type", "Available", "Size (MB)"])
|
109 |
+
print(tabulate(variants_table, headers="firstrow", tablefmt="github"))
|
|
|
|
|
110 |
else:
|
111 |
print("done")
|
112 |
|