Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,8 @@ from PIL import Image
|
|
11 |
from transformers import CLIPVisionModelWithProjection
|
12 |
from diffusers.models import ControlNetModel
|
13 |
|
|
|
|
|
14 |
from insightface.app import FaceAnalysis
|
15 |
|
16 |
import io
|
@@ -172,33 +174,44 @@ CURRENT_LORA_NAME = None
|
|
172 |
# app = FaceAnalysis(name='antelopev2', root='./', providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
|
173 |
|
174 |
|
175 |
-
# Define your repository, target directory, and local directory
|
176 |
-
repo_id = "briaai/ID_preservation_2.3"
|
177 |
-
target_dir = "models_aura/" # The directory you want to download
|
178 |
-
local_dir = "./checkpoints" # Local directory to save files
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
-
# Initialize the API
|
181 |
-
api = HfApi()
|
182 |
-
# List all files in the repository
|
183 |
-
files = api.list_repo_files(repo_id=repo_id, repo_type="model") # Use repo_type="space" for Spaces
|
184 |
|
185 |
-
#
|
186 |
-
|
187 |
-
# Download each file in the target directory
|
188 |
-
for file in files_in_dir:
|
189 |
-
local_path = os.path.join(local_dir, file)
|
190 |
-
os.makedirs(os.path.dirname(local_path), exist_ok=True) # Ensure local directories exist
|
191 |
-
print(f"Downloading: {file}")
|
192 |
-
hf_hub_download(repo_id=repo_id, filename=file, local_dir=os.path.dirname(local_path))
|
193 |
|
|
|
|
|
194 |
|
195 |
-
|
196 |
-
|
|
|
|
|
197 |
|
198 |
-
|
199 |
-
|
|
|
|
|
|
|
200 |
|
201 |
-
app = FaceAnalysis(name='auraface', root='./checkpoints/models_aura/', providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
|
202 |
app.prepare(ctx_id=0, det_size=(640, 640))
|
203 |
|
204 |
|
|
|
11 |
from transformers import CLIPVisionModelWithProjection
|
12 |
from diffusers.models import ControlNetModel
|
13 |
|
14 |
+
from huggingface_hub import snapshot_download
|
15 |
+
|
16 |
from insightface.app import FaceAnalysis
|
17 |
|
18 |
import io
|
|
|
174 |
# app = FaceAnalysis(name='antelopev2', root='./', providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
|
175 |
|
176 |
|
177 |
+
# # Define your repository, target directory, and local directory
|
178 |
+
# repo_id = "briaai/ID_preservation_2.3"
|
179 |
+
# target_dir = "models_aura/" # The directory you want to download
|
180 |
+
# local_dir = "./checkpoints" # Local directory to save files
|
181 |
+
|
182 |
+
# # Initialize the API
|
183 |
+
# api = HfApi()
|
184 |
+
# # List all files in the repository
|
185 |
+
# files = api.list_repo_files(repo_id=repo_id, repo_type="model") # Use repo_type="space" for Spaces
|
186 |
+
|
187 |
+
# # Filter files that are in the target directory
|
188 |
+
# files_in_dir = [file for file in files if file.startswith(target_dir)]
|
189 |
+
# # Download each file in the target directory
|
190 |
+
# for file in files_in_dir:
|
191 |
+
# local_path = os.path.join(local_dir, file)
|
192 |
+
# os.makedirs(os.path.dirname(local_path), exist_ok=True) # Ensure local directories exist
|
193 |
+
# print(f"Downloading: {file}")
|
194 |
+
# hf_hub_download(repo_id=repo_id, filename=file, local_dir=os.path.dirname(local_path))
|
195 |
|
|
|
|
|
|
|
|
|
196 |
|
197 |
+
# # Local directory where files were downloaded
|
198 |
+
# local_dir = "./checkpoints/models_aura"
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
|
200 |
+
# print(f"Folder structure of '{local_dir}':")
|
201 |
+
# print_tree(local_dir)
|
202 |
|
203 |
+
snapshot_download(
|
204 |
+
"fal/AuraFace-v1",
|
205 |
+
local_dir="models/auraface",
|
206 |
+
)
|
207 |
|
208 |
+
app = FaceAnalysis(
|
209 |
+
name="auraface",
|
210 |
+
providers=["CUDAExecutionProvider", "CPUExecutionProvider"],
|
211 |
+
root=".",
|
212 |
+
)
|
213 |
|
214 |
+
# app = FaceAnalysis(name='auraface', root='./checkpoints/models_aura/', providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
|
215 |
app.prepare(ctx_id=0, det_size=(640, 640))
|
216 |
|
217 |
|