Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,42 +1,17 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
| 3 |
import os
|
| 4 |
-
import
|
| 5 |
import glob
|
| 6 |
|
| 7 |
# Ensure 'checkpoint' directory exists
|
| 8 |
os.makedirs("checkpoint", exist_ok=True)
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
output_folder = "checkpoint" # Directory to save the downloaded files
|
| 16 |
-
|
| 17 |
-
# Download all files in the Google Drive folder
|
| 18 |
-
gdown_url = f"https://drive.google.com/drive/folders/{folder_id}"
|
| 19 |
-
try:
|
| 20 |
-
# Download the folder contents
|
| 21 |
-
gdown.download_folder(gdown_url, quiet=False, output=output_folder)
|
| 22 |
-
|
| 23 |
-
# Ensure the downloaded file is named 'model_state-415001.th'
|
| 24 |
-
downloaded_files = glob.glob(os.path.join(output_folder, "*.th"))
|
| 25 |
-
if downloaded_files:
|
| 26 |
-
downloaded_model_path = downloaded_files[0]
|
| 27 |
-
target_model_path = os.path.join(output_folder, "model_state-415001.th")
|
| 28 |
-
|
| 29 |
-
# Rename if necessary
|
| 30 |
-
if downloaded_model_path != target_model_path:
|
| 31 |
-
os.rename(downloaded_model_path, target_model_path)
|
| 32 |
-
|
| 33 |
-
print(f"Downloaded model weights to {target_model_path}")
|
| 34 |
-
else:
|
| 35 |
-
print("Model file 'model_state-415001.th' not found in the folder.")
|
| 36 |
-
except Exception as e:
|
| 37 |
-
print(f"Failed to download weights: {e}")
|
| 38 |
-
|
| 39 |
-
download_weights_from_folder("https://drive.google.com/drive/folders/1Bq0n-w1VT5l99CoaVg02hFpqE5eGLo9O")
|
| 40 |
|
| 41 |
# Define a function to run your script with selected inputs
|
| 42 |
def run_xportrait(
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
| 3 |
import os
|
| 4 |
+
from huggingface_hub import hf_hub_download
|
| 5 |
import glob
|
| 6 |
|
| 7 |
# Ensure 'checkpoint' directory exists
|
| 8 |
os.makedirs("checkpoint", exist_ok=True)
|
| 9 |
|
| 10 |
+
hf_hub_download(
|
| 11 |
+
repo_id="fffiloni/X-Portrait",
|
| 12 |
+
filename="model_state-415001.th",
|
| 13 |
+
local_dir="checkpoint"
|
| 14 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# Define a function to run your script with selected inputs
|
| 17 |
def run_xportrait(
|