Ashoka74 commited on
Commit
c56a332
1 Parent(s): 34dc498

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -45
app.py CHANGED
@@ -41,6 +41,54 @@ import torch
41
  from PIL import Image
42
 
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  try:
46
  import xformers
@@ -134,51 +182,6 @@ def hooked_unet_forward(sample, timestep, encoder_hidden_states, **kwargs):
134
 
135
  unet.forward = hooked_unet_forward
136
 
137
- # Load
138
-
139
- # Model paths
140
- model_path = './models/iclight_sd15_fc.safetensors'
141
- model_path2 = './checkpoints/depth_anything_v2_vits.pth'
142
- model_path3 = './checkpoints/sam2_hiera_large.pt'
143
- model_path4 = './checkpoints/config.json'
144
- model_path5 = './checkpoints/preprocessor_config.json'
145
- model_path6 = './configs/sam2_hiera_l.yaml'
146
- model_path7 = './mvadapter_i2mv_sdxl.safetensors'
147
-
148
- # Base URL for the repository
149
- BASE_URL = 'https://huggingface.co/Ashoka74/Placement/resolve/main/'
150
-
151
- # Model URLs
152
- model_urls = {
153
- model_path: 'iclight_sd15_fc.safetensors',
154
- model_path2: 'depth_anything_v2_vits.pth',
155
- model_path3: 'sam2_hiera_large.pt',
156
- model_path4: 'config.json',
157
- model_path5: 'preprocessor_config.json',
158
- model_path6: 'sam2_hiera_l.yaml',
159
- model_path7: 'mvadapter_i2mv_sdxl.safetensors'
160
- }
161
-
162
- # Ensure directories exist
163
- def ensure_directories():
164
- for path in model_urls.keys():
165
- os.makedirs(os.path.dirname(path), exist_ok=True)
166
-
167
- # Download models
168
- def download_models():
169
- for local_path, filename in model_urls.items():
170
- if not os.path.exists(local_path):
171
- try:
172
- url = f"{BASE_URL}{filename}"
173
- print(f"Downloading {filename}")
174
- download_url_to_file(url, local_path)
175
- print(f"Successfully downloaded {filename}")
176
- except Exception as e:
177
- print(f"Error downloading {filename}: {e}")
178
-
179
- ensure_directories()
180
-
181
- download_models()
182
 
183
 
184
 
 
41
  from PIL import Image
42
 
43
 
44
+ # Load
45
+
46
+ # Model paths
47
+ model_path = './models/iclight_sd15_fc.safetensors'
48
+ model_path2 = './checkpoints/depth_anything_v2_vits.pth'
49
+ model_path3 = './checkpoints/sam2_hiera_large.pt'
50
+ model_path4 = './checkpoints/config.json'
51
+ model_path5 = './checkpoints/preprocessor_config.json'
52
+ model_path6 = './configs/sam2_hiera_l.yaml'
53
+ model_path7 = './mvadapter_i2mv_sdxl.safetensors'
54
+
55
+ # Base URL for the repository
56
+ BASE_URL = 'https://huggingface.co/Ashoka74/Placement/resolve/main/'
57
+
58
+ # Model URLs
59
+ model_urls = {
60
+ model_path: 'iclight_sd15_fc.safetensors',
61
+ model_path2: 'depth_anything_v2_vits.pth',
62
+ model_path3: 'sam2_hiera_large.pt',
63
+ model_path4: 'config.json',
64
+ model_path5: 'preprocessor_config.json',
65
+ model_path6: 'sam2_hiera_l.yaml',
66
+ model_path7: 'mvadapter_i2mv_sdxl.safetensors'
67
+ }
68
+
69
+ # Ensure directories exist
70
+ def ensure_directories():
71
+ for path in model_urls.keys():
72
+ os.makedirs(os.path.dirname(path), exist_ok=True)
73
+
74
+ # Download models
75
+ def download_models():
76
+ for local_path, filename in model_urls.items():
77
+ if not os.path.exists(local_path):
78
+ try:
79
+ url = f"{BASE_URL}{filename}"
80
+ print(f"Downloading {filename}")
81
+ download_url_to_file(url, local_path)
82
+ print(f"Successfully downloaded {filename}")
83
+ except Exception as e:
84
+ print(f"Error downloading {filename}: {e}")
85
+
86
+ ensure_directories()
87
+
88
+ download_models()
89
+
90
+
91
+
92
 
93
  try:
94
  import xformers
 
182
 
183
  unet.forward = hooked_unet_forward
184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
 
186
 
187