Reputation: 1800
I'm upgrading my stable diffusion from 2-1 to stable-diffusion-3-medium-diffusers
Here is my code which is working for version 2-1
# source venv/bin/activate
from diffusers import DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1")
pipe = pipe.to("mps")
pipe.enable_attention_slicing()
print("Starting Process")
steps = 200
query = "Stormy Weather in Monte Carlo"
image = pipe(query, num_inference_steps=steps).images[0]
image.save("oneOffImage.jpg")
print("Successfully Created Image as oneOffImage.jpg")
I upgraded diffusers
, signed up on hugging face for access to the gated repo, created and added the HF_TOKEN to my .env, and ran this code
# source venv/bin/activate
from diffusers import StableDiffusion3Pipeline
from dotenv import load_dotenv
import os
load_dotenv()
print("Starting Process")
pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers")
pipe = pipe.to("mps")
# pipe.set_progress_bar_config(disable=True)
pipe.enable_attention_slicing()
print("Starting Process")
steps = 200
query = "Stormy Weather in Monte Carlo"
image = pipe(query, num_inference_steps=steps).images[0]
image.save("oneOffImage.jpg")
print("Successfully Created Image as oneOffImage.jpg")
I was able to download the model, also I logged the token and confirmed it's in the env vars, I tried adding torch and setting , torch_dtype=torch.float16)
but that did nothing plus I think thats for cuda, I also tried adding an auth tag but that did nothing, I upgraded my transformers but I don't even thing that did anything. I'm running out of ideas.
Here is the current error
(venv) mikeland@mikes-mac-mini WeatherWindow % python3 oneOffGenStableDiffusion.py
/Users/mikeland/WeatherWindow/venv/lib/python3.9/site-packages/diffusers/models/transformers/transformer_2d.py:34: FutureWarning: `Transformer2DModelOutput` is deprecated and will be removed in version 1.0.0. Importing `Transformer2DModelOutput` from `diffusers.models.transformer_2d` is deprecated and this will be removed in a future version. Please use `from diffusers.models.modeling_outputs import Transformer2DModelOutput`, instead.
deprecate("Transformer2DModelOutput", "1.0.0", deprecation_message)
Starting Process
Loading pipeline components...: 0%| | 0/9 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/Users/mikeland/WeatherWindow/oneOffGenStableDiffusion.py", line 15, in <module>
pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers")
File "/Users/mikeland/WeatherWindow/venv/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
File "/Users/mikeland/WeatherWindow/venv/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py", line 881, in from_pretrained
loaded_sub_model = load_sub_model(
File "/Users/mikeland/WeatherWindow/venv/lib/python3.9/site-packages/diffusers/pipelines/pipeline_loading_utils.py", line 703, in load_sub_model
loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs)
File "/Users/mikeland/WeatherWindow/venv/lib/python3.9/site-packages/transformers/modeling_utils.py", line 3122, in from_pretrained
raise ImportError(
ImportError: Using `low_cpu_mem_usage=True` or a `device_map` requires Accelerate: `pip install accelerate`
I'm just looking for ANY example I can get to work on Mac at this point.
Upvotes: 0
Views: 358
Reputation: 1800
Here is what ended up working for me
# source venv/bin/activate
from diffusers import StableDiffusion3Pipeline
import torch
from dotenv import load_dotenv
import os
load_dotenv()
os.environ["PYTORCH_MPS_HIGH_WATERMARK_RATIO"] = "0.0"
print("Starting Process")
pipe = StableDiffusion3Pipeline.from_pretrained(
"stabilityai/stable-diffusion-3-medium-diffusers",
low_cpu_mem_usage=False,
torch_dtype=torch.float16,
variant="fp16",
use_safttensors=True
).to("mps")
pipe.enable_attention_slicing()
print("Starting Process")
steps = 40
query = "Rain Weather in New York City, New York"
image = pipe(query, num_inference_steps=steps).images[0]
image.save("oneOffImage.jpg")
print("Successfully Created Image as oneOffImage.jpg")
Upvotes: 0