ostris / ai-toolkit

Various AI scripts. Mostly Stable Diffusion stuff.
MIT License
220 stars 25 forks source link

Bug/Safety checker to None #12

Closed bendeguzvaradi closed 10 months ago

bendeguzvaradi commented 10 months ago

Hi I am not sure what your branching conventions are, but the current version on main gives me an error, Here is my fix.

Fix AttributeError by Changing safety_checker to None

Description

I encountered an AttributeError while using the code from the main branch. The error message indicated that the issue was related to the safety_checker parameter being set to False. It appears that the code expects this parameter to be None rather than a boolean value.

Change safety_checker=False to safety_checker=None in toolkit/stable_diffusion_model.py line 215

pipe = pipln.from_pretrained(
    model_path,
    dtype=dtype,
    scheduler_type='dpm',
    device=self.device_torch,
    load_safety_checker=False,
    requires_safety_checker=False,
    safety_checker=False
).to(self.device_torch)

Here, if safety_checker is False, it gives me the error: 'bool' object has no attribute '__module__'. Did you mean: '__mod__'? in site-packages/diffusers/pipelines/pipeline_utils.py line 513, since it checks for None value instead of bool in line 504.

Fixes # (issue)

Change safety_checker=False to safety_checker=None and it works for me.

jaretburkett commented 10 months ago

Thank you . It is odd It never threw a bug for me, but you are right. Out of curiosity, what version of diffusers do you have installed?

bendeguzvaradi commented 9 months ago

I was using 0.20.2, but I have also tried it with the newest 0.21.1 version and would throw the same error.