segmind / segmoe

Apache License 2.0
410 stars 25 forks source link

The same seed and prompt produces a completely black image #3

Closed edisonzf2020 closed 9 months ago

edisonzf2020 commented 9 months ago

I use the following code to test

from segmoe import SegMoEPipeline

pipeline = SegMoEPipeline("segmind/SegMoE-sd-4x2-v0", device = "cuda")

prompt = "a beautiful Asian girl, front view, full-length portrait, One hand is half-raised, as if waving hello."
negative_prompt = "ugly, deformed, badhandv4, ng_deepnegative_v1_75t, nsfw, bad quality, worse quality"
img = pipeline(
    prompt=prompt,
    negative_prompt=negative_prompt,
    height=768,
    width=512,
    num_inference_steps=30,
    guidance_scale=7.5,
    seed=1575769330,
    Sampler='DPM++ SDE Karras',
    low_cpu_mem_usage=True,
).images[0]
img.save("image1.png")

An error will occur if you repeat the execution 2-3 times. The error message is as follows:

Potential NSFW content was detected in one or more images. A black image will be returned instead. Try again with a different prompt and/or seed.

Warlord-K commented 9 months ago

Please try this,

from segmoe import SegMoEPipeline

pipeline = SegMoEPipeline("segmind/SegMoE-sd-4x2-v0", device = "cuda", safety_checker = None)

prompt = "a beautiful Asian girl, front view, full-length portrait, One hand is half-raised, as if waving hello."
negative_prompt = "ugly, deformed, badhandv4, ng_deepnegative_v1_75t, nsfw, bad quality, worse quality"
img = pipeline(
    prompt=prompt,
    negative_prompt=negative_prompt,
    height=768,
    width=512,
    num_inference_steps=30,
    guidance_scale=7.5,
    seed=1575769330,
    Sampler='DPM++ SDE Karras',
    low_cpu_mem_usage=True,
).images[0]
img.save("image1.png")
Vargol commented 9 months ago

HI, I tried this yesterday and double checked just now and it doesn't work. The SegMoEPipeline doesn't pass the kwargs into the DiffusionPipeline

Gothos commented 9 months ago

Hello, could you please elaborate on the issue? Any stacktraces would help, as would further details of where the kwargs are missed.

Vargol commented 9 months ago

https://github.com/segmind/segmoe/blob/main/segmoe/main.py

line 126, the call to DiffusionPipeline.from_pretrained doesn't pass the kwargs left after you've popped some off to use as class variables (fields whatever they are called in python)

            self.pipe = DiffusionPipeline.from_pretrained(
                cached_folder,
                unet=unet,
                torch_dtype=self.torch_dtype,
                use_safetensors=self.use_safetensors,
            )

could be

            self.pipe = DiffusionPipeline.from_pretrained(
                cached_folder,
                unet=unet,
                torch_dtype=self.torch_dtype,
                use_safetensors=self.use_safetensors,
                **kwargs
            )

Code typed edited in here, it needs testing, I don't think I've tried passing **kwargs after all the variables have been popped before.

Warlord-K commented 9 months ago

Fixed with PR #14, Thanks for raising the issue!