import torch
from diffusers import FluxPipeline
model_id = "black-forest-labs/FLUX.1-schnell" #you can also use `black-forest-labs/FLUX.1-dev`
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16)
pipe.enable_sequential_cpu_offload() #save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power
prompt = "A cat holding a sign that says hello world"
seed = 42
image = pipe(
prompt,
output_type="pil",
num_inference_steps=4, #use a larger number if you are using [dev]
generator=torch.Generator("cuda").manual_seed(seed)
).images[0]
image.save("flux-schnell.png")
Ive installed diffusers using pip install --upgrade diffusers[torch], but Im getting type errors in two places. On “from diffusers import FluxPipeline” Im getting
"FluxPipeline" is not exported from module "diffusers"
Import from "diffusers.pipelines.flux.pipeline_flux"
and on image = pipe() Im getting
Object of type "DiffusionPipeline" is not callable
Attribute "__call__" is unknown
However, I can run the code and generate images just fine. I can suppress the warnings with “# type: ignore” but I havent seen anyone else mention these errors so Im wondering if something is wrong. I tried uninstalling diffusers library, purging cache in pip and reinstalling, but still seeing the same errors.