GreenGoat commited on
Commit
8daf258
·
verified ·
1 Parent(s): ff22088

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -28,7 +28,6 @@ except ImportError:
28
  AttnProcessor2_0 = None
29
  from transformers import CLIPTextModel, CLIPTokenizer
30
  from enum import Enum
31
- from torch.hub import download_url_to_file
32
  import torch.nn as nn
33
  import torch.nn.functional as F
34
  from huggingface_hub import PyTorchModelHubMixin
@@ -134,7 +133,19 @@ unet.forward = hooked_unet_forward
134
  model_path = './iclight_sd15_fbc.safetensors'
135
  if not os.path.exists(model_path):
136
  print("Downloading IC-Light model...")
137
- download_url_to_file(url='https://huggingface.co/lllyasviel/ic-light/resolve/main/iclight_sd15_fbc.safetensors', dst=model_path)
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
  sd_offset = sf.load_file(model_path)
140
  sd_origin = unet.state_dict()
 
28
  AttnProcessor2_0 = None
29
  from transformers import CLIPTextModel, CLIPTokenizer
30
  from enum import Enum
 
31
  import torch.nn as nn
32
  import torch.nn.functional as F
33
  from huggingface_hub import PyTorchModelHubMixin
 
133
  model_path = './iclight_sd15_fbc.safetensors'
134
  if not os.path.exists(model_path):
135
  print("Downloading IC-Light model...")
136
+ try:
137
+ from huggingface_hub import hf_hub_download
138
+ model_path = hf_hub_download(
139
+ repo_id="lllyasviel/ic-light",
140
+ filename="iclight_sd15_fbc.safetensors",
141
+ local_dir="./",
142
+ local_dir_use_symlinks=False
143
+ )
144
+ except Exception as e:
145
+ print(f"Failed to download with hf_hub_download: {e}")
146
+ # Fallback to torch.hub
147
+ from torch.hub import download_url_to_file
148
+ download_url_to_file(url='https://huggingface.co/lllyasviel/ic-light/resolve/main/iclight_sd15_fbc.safetensors', dst=model_path)
149
 
150
  sd_offset = sf.load_file(model_path)
151
  sd_origin = unet.state_dict()