Spaces:
Running
on
Zero
Running
on
Zero
Add better progress tracking and timing information for checkpoint download
Browse files
app.py
CHANGED
|
@@ -83,14 +83,30 @@ def get_checkpoint_path(checkpoint_file, default_local_path, repo_id=None, filen
|
|
| 83 |
start_time = time.time()
|
| 84 |
print(f"π₯ Downloading checkpoint from {repo_id}...")
|
| 85 |
print(f"File size: ~15.5 GB - This may take 10-30 minutes")
|
|
|
|
|
|
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
elapsed = time.time() - start_time
|
| 96 |
print(f"β
Download completed in {elapsed/60:.1f} minutes")
|
|
@@ -148,7 +164,11 @@ def generate_image(prompt, aspect_ratio, cfg, seed, checkpoint_file, config_path
|
|
| 148 |
return None, "Error: Config file not found. Please ensure config file exists."
|
| 149 |
|
| 150 |
status_msg += "Starting image generation...\n"
|
| 151 |
-
status_msg += "
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
try:
|
| 154 |
# Create output directory
|
|
@@ -173,8 +193,8 @@ def generate_image(prompt, aspect_ratio, cfg, seed, checkpoint_file, config_path
|
|
| 173 |
"--logdir", str(output_dir) # Set logdir to outputs directory
|
| 174 |
]
|
| 175 |
|
| 176 |
-
status_msg += "Running generation...\n"
|
| 177 |
-
status_msg += "
|
| 178 |
|
| 179 |
# Create log file for debugging
|
| 180 |
log_file = output_dir / "generation.log"
|
|
|
|
| 83 |
start_time = time.time()
|
| 84 |
print(f"π₯ Downloading checkpoint from {repo_id}...")
|
| 85 |
print(f"File size: ~15.5 GB - This may take 10-30 minutes")
|
| 86 |
+
print(f"Cache directory: {cache_dir}")
|
| 87 |
+
print(f"Progress will be shown below...")
|
| 88 |
|
| 89 |
+
# Use tqdm for progress if available
|
| 90 |
+
try:
|
| 91 |
+
from tqdm import tqdm
|
| 92 |
+
from huggingface_hub.utils import tqdm as hf_tqdm
|
| 93 |
+
checkpoint_path = hf_hub_download(
|
| 94 |
+
repo_id=repo_id,
|
| 95 |
+
filename=filename,
|
| 96 |
+
cache_dir=cache_dir,
|
| 97 |
+
local_files_only=False,
|
| 98 |
+
resume_download=True, # Resume if interrupted
|
| 99 |
+
)
|
| 100 |
+
except Exception as e:
|
| 101 |
+
# Fallback if tqdm fails
|
| 102 |
+
print(f"Note: Progress bar unavailable, downloading silently...")
|
| 103 |
+
checkpoint_path = hf_hub_download(
|
| 104 |
+
repo_id=repo_id,
|
| 105 |
+
filename=filename,
|
| 106 |
+
cache_dir=cache_dir,
|
| 107 |
+
local_files_only=False,
|
| 108 |
+
resume_download=True,
|
| 109 |
+
)
|
| 110 |
|
| 111 |
elapsed = time.time() - start_time
|
| 112 |
print(f"β
Download completed in {elapsed/60:.1f} minutes")
|
|
|
|
| 164 |
return None, "Error: Config file not found. Please ensure config file exists."
|
| 165 |
|
| 166 |
status_msg += "Starting image generation...\n"
|
| 167 |
+
status_msg += "β±οΈ Timing breakdown:\n"
|
| 168 |
+
status_msg += " - Checkpoint download: 10-30 min (first time only, ~15.5 GB)\n"
|
| 169 |
+
status_msg += " - Model loading: 2-5 min (first time only)\n"
|
| 170 |
+
status_msg += " - Image generation: 1-3 min\n"
|
| 171 |
+
status_msg += " - Subsequent runs: Only generation time (~1-3 min)\n"
|
| 172 |
|
| 173 |
try:
|
| 174 |
# Create output directory
|
|
|
|
| 193 |
"--logdir", str(output_dir) # Set logdir to outputs directory
|
| 194 |
]
|
| 195 |
|
| 196 |
+
status_msg += "π Running generation...\n"
|
| 197 |
+
status_msg += "π Current step: Model inference (checkpoint should already be downloaded)\n"
|
| 198 |
|
| 199 |
# Create log file for debugging
|
| 200 |
log_file = output_dir / "generation.log"
|