Spaces:
Runtime error
Runtime error
Update gradio_demo.py
Browse files- gradio_demo.py +46 -5
gradio_demo.py
CHANGED
@@ -141,12 +141,53 @@ unet.forward = hooked_unet_forward
|
|
141 |
|
142 |
# Load
|
143 |
|
|
|
144 |
model_path = './models/iclight_sd15_fc.safetensors'
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
sd_offset = sf.load_file(model_path)
|
152 |
sd_origin = unet.state_dict()
|
|
|
141 |
|
142 |
# Load
|
143 |
|
144 |
+
# Model paths
|
145 |
model_path = './models/iclight_sd15_fc.safetensors'
|
146 |
+
model_path2 = './checkpoints/depth_anything_v2_vits.pth'
|
147 |
+
model_path3 = './checkpoints/sam2_hiera_large.pt'
|
148 |
+
model_path4 = './checkpoints/config.json'
|
149 |
+
model_path5 = './checkpoints/preprocessor_config.json'
|
150 |
+
model_path6 = './configs/sam2_hiera_l.yaml'
|
151 |
+
model_path7 = './mvadapter_i2mv_sdxl.safetensors'
|
152 |
+
|
153 |
+
# Base URL for the repository
|
154 |
+
BASE_URL = 'https://huggingface.co/Ashoka74/Placement/resolve/main/'
|
155 |
+
|
156 |
+
# Model URLs
|
157 |
+
model_urls = {
|
158 |
+
model_path: 'iclight_sd15_fc.safetensors',
|
159 |
+
model_path2: 'depth_anything_v2_vits.pth',
|
160 |
+
model_path3: 'sam2_hiera_large.pt',
|
161 |
+
model_path4: 'config.json',
|
162 |
+
model_path5: 'preprocessor_config.json',
|
163 |
+
model_path6: 'sam2_hiera_l.yaml',
|
164 |
+
model_path7: 'mvadapter_i2mv_sdxl.safetensors'
|
165 |
+
}
|
166 |
+
|
167 |
+
# Ensure directories exist
|
168 |
+
def ensure_directories():
|
169 |
+
for path in model_urls.keys():
|
170 |
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
171 |
+
|
172 |
+
# Download models
|
173 |
+
def download_models():
|
174 |
+
for local_path, filename in model_urls.items():
|
175 |
+
if not os.path.exists(local_path):
|
176 |
+
try:
|
177 |
+
url = f"{BASE_URL}{filename}"
|
178 |
+
print(f"Downloading {filename}")
|
179 |
+
download_url_to_file(url, local_path)
|
180 |
+
print(f"Successfully downloaded {filename}")
|
181 |
+
except Exception as e:
|
182 |
+
print(f"Error downloading {filename}: {e}")
|
183 |
+
|
184 |
+
ensure_directories()
|
185 |
+
|
186 |
+
download_models()
|
187 |
+
|
188 |
+
|
189 |
+
if not os.path.exists(model_path):
|
190 |
+
download_url_to_file(url='https://huggingface.co/lllyasviel/ic-light/resolve/main/iclight_sd15_fc.safetensors', dst=model_path)
|
191 |
|
192 |
sd_offset = sf.load_file(model_path)
|
193 |
sd_origin = unet.state_dict()
|