radames commited on
Commit
b53d2ad
1 Parent(s): d2c46d0

better model loading

Browse files
Files changed (2) hide show
  1. README.md +0 -2
  2. app.py +15 -0
README.md CHANGED
@@ -7,8 +7,6 @@ sdk: gradio
7
  sdk_version: 4.21.0
8
  app_file: app.py
9
  pinned: false
10
- preload_from_hub:
11
- - lllyasviel/fav_models fav/juggernautXL_v8Rundiffusion.safetensors
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
7
  sdk_version: 4.21.0
8
  app_file: app.py
9
  pinned: false
 
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -1,6 +1,8 @@
1
  import sys
2
  import os
3
  import torch
 
 
4
  from PIL import Image, ImageSequence, ImageOps
5
  from typing import List
6
  import numpy as np
@@ -27,6 +29,19 @@ from ComfyUI.custom_nodes.layerdiffuse.layered_diffusion import (
27
  import gradio as gr
28
 
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  with torch.inference_mode():
31
  ckpt_load_checkpoint = CheckpointLoaderSimple().load_checkpoint
32
  ckpt = ckpt_load_checkpoint(ckpt_name="juggernautXL_v8Rundiffusion.safetensors")
 
1
  import sys
2
  import os
3
  import torch
4
+ from pathlib import Path
5
+ from huggingface_hub import hf_hub_download
6
  from PIL import Image, ImageSequence, ImageOps
7
  from typing import List
8
  import numpy as np
 
29
  import gradio as gr
30
 
31
 
32
+ MODEL_PATH = hf_hub_download(
33
+ repo_id="lllyasviel/fav_models",
34
+ subfolder="fav",
35
+ filename="juggernautXL_v8Rundiffusion.safetensors",
36
+ )
37
+ try:
38
+ os.symlink(
39
+ MODEL_PATH,
40
+ Path("./ComfyUI/models/checkpoints/juggernautXL_v8Rundiffusion.safetensors"),
41
+ )
42
+ except FileExistsError:
43
+ pass
44
+
45
  with torch.inference_mode():
46
  ckpt_load_checkpoint = CheckpointLoaderSimple().load_checkpoint
47
  ckpt = ckpt_load_checkpoint(ckpt_name="juggernautXL_v8Rundiffusion.safetensors")