leoeric commited on
Commit
bd6dbaf
Β·
1 Parent(s): dc2ca3c

Add better progress tracking and timing information for checkpoint download

Browse files
Files changed (1) hide show
  1. app.py +30 -10
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
- checkpoint_path = hf_hub_download(
88
- repo_id=repo_id,
89
- filename=filename,
90
- cache_dir=cache_dir,
91
- local_files_only=False,
92
- resume_download=True, # Resume if interrupted
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 += "This may take 1-3 minutes for first run (model loading).\n"
 
 
 
 
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 += "Note: First run includes checkpoint download (~10-20 min) and model loading (~2-5 min).\n"
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"