harubaru / waifu-diffusion

stable diffusion finetuned on weeb stuff
GNU Affero General Public License v3.0
1.94k stars 174 forks source link

AttributeError: module transformers has no attribute FeatureExtractionMixin #15

Closed Zenahr closed 2 years ago

Zenahr commented 2 years ago

Trying to run the sample code as seen on huggingface:

import torch
from torch import autocast
from diffusers import StableDiffusionPipeline, DDIMScheduler

model_id = "hakurei/waifu-diffusion"
device = "cuda"

pipe = StableDiffusionPipeline.from_pretrained(
    model_id,
    torch_dtype=torch.float16,
    revision="fp16",
    scheduler=DDIMScheduler(
        beta_start=0.00085,
        beta_end=0.012,
        beta_schedule="scaled_linear",
        clip_sample=False,
        set_alpha_to_one=False,
    ),
)
pipe = pipe.to(device)

prompt = "touhou hakurei_reimu 1girl solo portrait"
with autocast("cuda"):
    image = pipe(prompt, guidance_scale=7.5)["sample"][0]  

image.save("reimu_hakurei.png")

Getting error:

Traceback (most recent call last):
  File "c:/SoftwareDevelopment/NLP/SentimentClassification/hehe.py", line 9, in <module>
    pipe = StableDiffusionPipeline.from_pretrained(
  File "C:\SoftwareDevelopment\NLP\SentimentClassification\env\lib\site-packages\diffusers\pipeline_utils.py", line 365, in from_pretrained
    class_candidates = {c: getattr(library, c) for c in importable_classes.keys()}
  File "C:\SoftwareDevelopment\NLP\SentimentClassification\env\lib\site-packages\diffusers\pipeline_utils.py", line 365, in <dictcomp>
    class_candidates = {c: getattr(library, c) for c in importable_classes.keys()}
  File "C:\SoftwareDevelopment\NLP\SentimentClassification\env\lib\site-packages\transformers\file_utils.py", line 2143, in __getattr__
    raise AttributeError(f"module {self.__name__} has no attribute {name}")
AttributeError: module transformers has no attribute FeatureExtractionMixin
ADOHI commented 2 years ago

upgrade transformers version :)