XaiJu
Shiroppo
Shiroppo

patreon


stable_cascade_easy

From my github: https://github.com/another-ai/stable_cascade_easy

Text to Img with Stable Cascade, required less vram than original example on official Hugginface(https://huggingface.co/stabilityai/stable-cascade):

Installation:

  1. Install Python 3.10.6, checking "Add Python to PATH".
  2. Install git.
  3. On terminal:
git clone https://github.com/shiroppo/stable_cascade_easy
cd stable_cascade_easy
py -m venv venv
.\venv\Scripts\activate
pip install -r requirements.txt
pip install git+https://github.com/kashif/diffusers.git@wuerstchen-v3

Run:

On terminal:

.\venv\Scripts\activate
py app.py

Code:

import torch
from diffusers import StableCascadeDecoderPipeline, StableCascadePriorPipeline
import gc

device = "cuda"
num_images_per_prompt = 1

prior = StableCascadePriorPipeline.from_pretrained("stabilityai/stable-cascade-prior", torch_dtype=torch.bfloat16).to(device)
prior.safety_checker = None
prior.requires_safety_checker = False

prompt = "a cat"
negative_prompt = ""

prior_output = prior(
   prompt=prompt,
   width=1280,
   height=1536,
   negative_prompt=negative_prompt,
   guidance_scale=4.0,
   num_images_per_prompt=num_images_per_prompt,
   num_inference_steps=20
)

del prior
gc.collect()
torch.cuda.empty_cache()

decoder = StableCascadeDecoderPipeline.from_pretrained("stabilityai/stable-cascade",  torch_dtype=torch.float16).to(device)
decoder.safety_checker = None
decoder.requires_safety_checker = False

decoder_output = decoder(
   image_embeddings=prior_output.image_embeddings.half(),
   prompt=prompt,
   negative_prompt=negative_prompt,
   guidance_scale=0.0,
   output_type="pil",
   num_inference_steps=12
).images[0].save("image.png")

# del decoder
# gc.collect()
# torch.cuda.empty_cache()

stable_cascade_easy

More Creators