question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: OnnxStableDiffusionPipeline.__init__() missing 1 required positional argument: 'vae_encoder'

See original GitHub issue

Describe the bug

Hi, I tried ONNX Runtime for inference. The code is, from diffusers import StableDiffusionOnnxPipeline pipe = StableDiffusionOnnxPipeline.from_pretrained( "CompVis/stable-diffusion-v1-4", revision="onnx", provider="CPUExecutionProvider", use_auth_token=True, ) prompt = "a photo of an astronaut riding a horse on mars" image = pipe(prompt).images[0]

**Error is, Traceback (most recent call last): File “Python-work\stable_diffuser_onnx_compvix.py”, line 3, in <module> pipe = StableDiffusionOnnxPipeline.from_pretrained( File “onnx-virtual\lib\site-packages\diffusers\pipeline_utils.py”, line 647, in from_pretrained model = pipeline_class(init_kwargs) File “onnx-virtual\lib\site-packages\diffusers\pipelines\stable_diffusion\pipeline_onnx_stable_diffusion.py”, line 272, in init super().init( TypeError: OnnxStableDiffusionPipeline.init() missing 1 required positional argument: ‘vae_encoder’

Kindly help me to fix this error

Reproduction

I tried this with virtual environment and python 3.10

Logs

No response

System Info

Environment is windows, python 3.10

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
anton-lcommented, Nov 28, 2022

@kamalasubha this issue should be fixed in diffusers>=0.8. Try installing the latest version, then this will work:

from diffusers import StableDiffusionOnnxPipeline 

pipe = StableDiffusionOnnxPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", revision="onnx", provider="CPUExecutionProvider")
0reactions
GreenLandisaLiecommented, Nov 24, 2022

@kamalasubha Don’t use revision=“onnx” - you are already calling from an onnx pipeline! And also you might want to install ort nightly directml and use DmlExecutionProvider instead of CPUExecutionProvider - it works on my RX 560 4G although it uses RAM as shared memory (which slows things quite a bit) to compensate the lack of VRAM - still 5 times faster than my CPU. If your GPU has 4G or more then you def should use DmlExecutionProvider. Take a look at this issue I opened as it contains the link for it as well as a fix to a possible problem you might encounter (so far I seem to be the only one though) - don’t forget you must grab the version specific for your python version.

EDIT: Forgot to ask - what scheduler are you using? I find that the default one doesn’t work well for custom models. DDIM works great for them. For reference here is how I’m doing:

from diffusers import DDIMScheduler, LMSDiscreteScheduler, EulerAncestralDiscreteScheduler

DDIM = DDIMScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000, clip_sample=False, set_alpha_to_one=False)
LMSD = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000)
EULER_A = EulerAncestralDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000)

Then you assign them like so: pipe.scheduler = DDIM

EDIT2: Somehow noticed this right before I was about to leave: you are trying to load the model ‘model_onnx’ even though when you converted it was ‘eldenring_v2_pruned_onnx’ - is that a mistake ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - __init__() missing 1 required positional argument
You're receiving this error because you did not pass a data variable to the DHT constructor. aIKid and Alexander's answers are nice but...
Read more >
StableDiffusionImg2ImgPipeline can't load by onnx revision
TypeError Traceback (most recent call last) Cell In [9], ... model TypeError: __init__() missing 1 required positional argument: 'vae' ...
Read more >
nvidia Jetson 2GB training fails - TypeError: __init__() missing ...
After training for 10 hours in epoch 1, it fails. I am stuck. ... TypeError: init() missing 1 required positional argument: 'dtype'.
Read more >
TypeError: __init__() missing 1 required positional argument
TypeError : __init__() missing 1 required positional argument: 'model'. Means the argument model is missing from the ForeignKey() call.
Read more >
How to solve : "TypeError: __init__() missing 1 required ...
How to solve : "TypeError: __init__() missing 1 required positional argument". class Employee: def __init__(self, name): self.name = name ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found