ajsbsd commited on
Commit
4858646
·
verified ·
1 Parent(s): 5cbe56c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -31,13 +31,19 @@ def load_models():
31
  try:
32
  print("Loading CyberRealistic Pony models...")
33
 
34
- # Use Hugging Face Hub download with minimal local storage
35
- print(f"Accessing model from {MODEL_REPO}...")
 
 
 
 
 
 
36
 
37
  # Load Text2Img pipeline
38
  if txt2img_pipe is None:
39
  txt2img_pipe = StableDiffusionXLPipeline.from_single_file(
40
- f"https://huggingface.co/{MODEL_REPO}/resolve/main/{MODEL_FILENAME}",
41
  torch_dtype=torch.float16 if device == "cuda" else torch.float32,
42
  use_safetensors=True,
43
  variant="fp16" if device == "cuda" else None
 
31
  try:
32
  print("Loading CyberRealistic Pony models...")
33
 
34
+ # Download model file using huggingface_hub
35
+ print(f"Downloading model from {MODEL_REPO}...")
36
+ model_path = hf_hub_download(
37
+ repo_id=MODEL_REPO,
38
+ filename=MODEL_FILENAME,
39
+ cache_dir="/tmp/hf_cache" # Use tmp for Spaces
40
+ )
41
+ print(f"Model downloaded to: {model_path}")
42
 
43
  # Load Text2Img pipeline
44
  if txt2img_pipe is None:
45
  txt2img_pipe = StableDiffusionXLPipeline.from_single_file(
46
+ model_path,
47
  torch_dtype=torch.float16 if device == "cuda" else torch.float32,
48
  use_safetensors=True,
49
  variant="fp16" if device == "cuda" else None