diffusers
diffusers copied to clipboard
How can i change generate image size?
I am using Stable Diffusion in this branch to generate images, but I get an error when I try to generate a 768x512 size image.
The code to generate the image is as follows
prompt = "1girl, \
blue eyes, \
cat ears, \
full body, \
looking at viewer, \
school uniform, \
simple background, \
silver long hair, \
under rim eyewear, \
white background"
image = pipe(prompt, height=768, width=512, num_inference_steps=50, guidance_scale=7.5, eta=0.0, execution_provider="DmlExecutionProvider")["sample"][0]
Running this code returns the following error
Traceback (most recent call last):
File "C:\Users\hoge\stable-diffusion-dml-branch\dml_onnx.py", line 261, in <module>
image = pipe(prompt, height=768, width=512, num_inference_steps=50, guidance_scale=7.5, eta=0.0, execution_provider="DmlExecutionProvider")["sample"][0]
File "C:\Users\hoge\AppData\Roaming\Python\Python39\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "C:\Users\hoge\stable-diffusion-dml-branch\dml_onnx.py", line 171, in __call__
noise_pred = unet_sess.run(None, inp)[0]
File "C:\Users\hoge\AppData\Roaming\Python\Python39\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 200, in run
return self._sess.run(output_names, input_feed, run_options)
onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: latent_model_input for the following indices
index: 2 Got: 96 Expected: 64
Please fix either the inputs or the model.
I think it conflicts with the setting of the example code in examples/inference/dml_onnx.py
, but due to my lack of knowledge I cannot determine the cause.
Please let me know how to generate a 768x512 sized image with Stable Diffusion in this branch.
https://www.youtube.com/watch?v=Z9PFh2Us3vk
This might help you.
You need to rebuild the data base to the proportion you want, but at more resolution you need more VRAM, see the steps to do it here #10 (works to higher sizes too)
PD: You need to calculate based in any divible number by 64, not by 8 as the comments in the source code.