Convert PyTorch Stable Diffusion models to ONNX format with flexible resolution.
redandr / sd_pytorch2onnx Goto Github PK
View Code? Open in Web Editor NEWConvert PyTorch Stable Diffusion models to ONNX format
License: Apache License 2.0
Convert PyTorch Stable Diffusion models to ONNX format
License: Apache License 2.0
I tried Convert_Civitai_OpenVINO.py and got many warnings and an error.
D:\Program Files\Python310\lib\site-packages\diffusers\models\unet_2d_condition.py:915: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if dim % default_overall_up_factor != 0:
D:\Program Files\Python310\lib\site-packages\diffusers\models\downsampling.py:135: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
assert hidden_states.shape[1] == self.channels
D:\Program Files\Python310\lib\site-packages\diffusers\models\downsampling.py:144: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
assert hidden_states.shape[1] == self.channels
D:\Program Files\Python310\lib\site-packages\diffusers\models\upsampling.py:149: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
assert hidden_states.shape[1] == self.channels
D:\Program Files\Python310\lib\site-packages\diffusers\models\upsampling.py:165: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if hidden_states.shape[0] >= 64:
D:\Program Files\Python310\lib\site-packages\diffusers\models\unet_2d_condition.py:1206: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if not return_dict:
Unet successfully converted to ONNX
Traceback (most recent call last):
File "D:\astable-diffusion\openvino_notebooks\notebooks\225-stable-diffusion-text-to-image\t5\civitai.py", line 87, in
model = mo.convert_model(UNET_ONNX_PATH, compress_to_fp16=True)
File "D:\Program Files\Python310\lib\site-packages\openvino\tools\mo\convert.py", line 364, in convert_model
ov_model, _ = _convert(cli_parser, framework, params, True)
File "D:\Program Files\Python310\lib\site-packages\openvino\tools\mo\convert_impl.py", line 957, in _convert
raise e.with_traceback(None)
RuntimeError: Check 'false' failed at src\frontends\common\src\frontend.cpp:54:
Converting input model
bad allocation
torch: 2.1.2+cpu
onnx: 1.15.0
onnxruntime: 1.16.3
tensorflow-intel: 2.14.0
Intel Core i5-6500 CPU
I found openvinotoolkit/openvino#12747 that tensorflow-intel >=2.8.0 will cause unexpected error.
I tried to downgrade tensorflow-intel to a version tensorflow-intel==2.8.0, but it asked me to downgrade other packages like
Other possible workarounds are:
Since you made it working, could you create virtualenv with needed packages?
error: torch.onnx.errors.UnsupportedOperatorError: Exporting the operator 'aten::scaled_dot_product_attention' to ONNX opset version 16 is not supported. Please feel free to request support or submit a pull request on PyTorch GitHub: https://github.com/pytorch/pytorch/issues.
torch:2.0.0
onnx:1.13.1
onnxruntime:1.14.1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.