Spaces:
Runtime error
Runtime error
Fix: Requirements
Browse files- requirements.txt +5 -1
- utils.py +8 -4
requirements.txt
CHANGED
|
@@ -9,7 +9,11 @@ gradio>=3.20.0
|
|
| 9 |
numpy>=1.22.0
|
| 10 |
Pillow>=9.0.0
|
| 11 |
tqdm>=4.64.0
|
| 12 |
-
huggingface-hub>=0.12.0
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Optional dependencies for better performance
|
| 15 |
scipy>=1.9.0
|
|
|
|
| 9 |
numpy>=1.22.0
|
| 10 |
Pillow>=9.0.0
|
| 11 |
tqdm>=4.64.0
|
| 12 |
+
huggingface-hub>=0.12.0,<0.20.0
|
| 13 |
+
|
| 14 |
+
# HF Spaces specific
|
| 15 |
+
gradio-client>=0.2.5
|
| 16 |
+
spaces>=0.19.4
|
| 17 |
|
| 18 |
# Optional dependencies for better performance
|
| 19 |
scipy>=1.9.0
|
utils.py
CHANGED
|
@@ -7,10 +7,13 @@ Date: Feb 26, 2025
|
|
| 7 |
|
| 8 |
import torch
|
| 9 |
import gc
|
|
|
|
| 10 |
from PIL import Image, ImageDraw, ImageFont
|
| 11 |
from diffusers import StableDiffusionPipeline
|
| 12 |
from transformers import CLIPTokenizer, CLIPTextModel
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
|
| 15 |
def load_models(device="cuda"):
|
| 16 |
"""
|
|
@@ -33,14 +36,14 @@ def load_models(device="cuda"):
|
|
| 33 |
print(f"Loading models on {device}...")
|
| 34 |
|
| 35 |
# Load the autoencoder model which will be used to decode the latents into image space
|
| 36 |
-
vae = AutoencoderKL.from_pretrained("CompVis/stable-diffusion-v1-4", subfolder="vae")
|
| 37 |
|
| 38 |
# Load the tokenizer and text encoder to tokenize and encode the text
|
| 39 |
tokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-large-patch14")
|
| 40 |
text_encoder = CLIPTextModel.from_pretrained("openai/clip-vit-large-patch14")
|
| 41 |
|
| 42 |
# The UNet model for generating the latents
|
| 43 |
-
unet = UNet2DConditionModel.from_pretrained("CompVis/stable-diffusion-v1-4", subfolder="unet")
|
| 44 |
|
| 45 |
# The noise scheduler
|
| 46 |
scheduler = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000)
|
|
@@ -48,7 +51,8 @@ def load_models(device="cuda"):
|
|
| 48 |
# Load the full pipeline for concept loading
|
| 49 |
pipe = StableDiffusionPipeline.from_pretrained(
|
| 50 |
"runwayml/stable-diffusion-v1-5",
|
| 51 |
-
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32
|
|
|
|
| 52 |
)
|
| 53 |
|
| 54 |
# Move models to device
|
|
|
|
| 7 |
|
| 8 |
import torch
|
| 9 |
import gc
|
| 10 |
+
import os
|
| 11 |
from PIL import Image, ImageDraw, ImageFont
|
| 12 |
from diffusers import StableDiffusionPipeline
|
| 13 |
from transformers import CLIPTokenizer, CLIPTextModel
|
| 14 |
+
|
| 15 |
+
# Disable HF transfer to avoid download issues
|
| 16 |
+
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "0"
|
| 17 |
|
| 18 |
def load_models(device="cuda"):
|
| 19 |
"""
|
|
|
|
| 36 |
print(f"Loading models on {device}...")
|
| 37 |
|
| 38 |
# Load the autoencoder model which will be used to decode the latents into image space
|
| 39 |
+
vae = AutoencoderKL.from_pretrained("CompVis/stable-diffusion-v1-4", subfolder="vae", use_safetensors=False)
|
| 40 |
|
| 41 |
# Load the tokenizer and text encoder to tokenize and encode the text
|
| 42 |
tokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-large-patch14")
|
| 43 |
text_encoder = CLIPTextModel.from_pretrained("openai/clip-vit-large-patch14")
|
| 44 |
|
| 45 |
# The UNet model for generating the latents
|
| 46 |
+
unet = UNet2DConditionModel.from_pretrained("CompVis/stable-diffusion-v1-4", subfolder="unet", use_safetensors=False)
|
| 47 |
|
| 48 |
# The noise scheduler
|
| 49 |
scheduler = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000)
|
|
|
|
| 51 |
# Load the full pipeline for concept loading
|
| 52 |
pipe = StableDiffusionPipeline.from_pretrained(
|
| 53 |
"runwayml/stable-diffusion-v1-5",
|
| 54 |
+
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 55 |
+
use_safetensors=False
|
| 56 |
)
|
| 57 |
|
| 58 |
# Move models to device
|