huggingface / huggingface/diffusers

Expanded init fields in StableDiffusionPipeline cause incompatibilities with many/most inherited pipelines

Đang mở
#6,969 22 bình luận 0 reaction 1 người được giao Được @asomoza nhận Xem trên GitHub
bug contributions-welcome good first issue help wanted wip
Ngôn ngữ chính
Python
Star
34.5k
Fork
7.3k
Merge trung bình
3 ngày 3 giờ
Pull request đã merge (30 ngày)
91

Mô tả

### Describe the bug

class `StableDiffusionPipeline` has its init section as:
```py
def __init__(
self,
vae: AutoencoderKL,
text_encoder: CLIPTextModel,
tokenizer: CLIPTokenizer,
unet: UNet2DConditionModel,
scheduler: KarrasDiffusionSchedulers,
safety_checker: StableDiffusionSafetyChecker,
feature_extractor: CLIPImageProcessor,
image_encoder: CLIPVisionModelWithProjection = None,
requires_safety_checker: bool = True,
):
```

and here `image_encoder` was recently introduced thus changing the class signature
but most community pipelines do not include init field for recently included `image_encoder` and thus order or params is wrong

for example, `examples/community/regional_prompting_stable_diffusion.py` has this in its init:
```py
super().__init__(
vae,
text_encoder,
tokenizer,
unet,
scheduler,
safety_checker,
feature_extractor,
requires_safety_checker,
)
```
which means `bool` value from `requires_safety_checker` is going to be passed as `image_encoder` and pipeline will fail during initialization like this:

```log
> diffusers/pipelines/pipeline_utils.py:546 in _fetch_class_library_tuple
AttributeError: 'bool' object has no attribute '__module__'
```

this is a conceptual problem with changing master class signature while all inherited classes pass args list as simple list.
i don't see a simple solution as going back is bad and going forward requires updates to a lot of pipelines.

but at the very basic, at least add error handling to `_fetch_class_library_tuple` so invalid type does not cause entire solution to crash.

### Reproduction

load nearly any community pipeline or any pipeline inherited from StableDiffusionPipeline, but not updated to use new signature in its `super().__init__` call

### Logs

_No response_

### System Info

diffusers==0.26.3

### Who can help?

@yiyixuxu @DN6 @sayakpaul @patrickvonplaten

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.