yujiepan commited on
Commit
f04497e
Β·
1 Parent(s): bb7473f

Show detailed file list in cache info and merge tabs

Browse files
Files changed (1) hide show
  1. app.py +30 -13
app.py CHANGED
@@ -217,19 +217,38 @@ def get_cache_info():
217
  for f in pt_files if os.path.exists(f))
218
  temp_size_mb = temp_size / (1024 * 1024)
219
 
 
 
 
 
 
 
 
 
 
 
 
220
  # HF cache
 
221
  try:
222
  cache_info = scan_cache_dir()
223
  hf_size_mb = cache_info.size_on_disk / (1024 * 1024)
224
  hf_repos = len(cache_info.repos)
225
- except Exception:
226
- hf_size_mb = 0
227
- hf_repos = 0
228
-
229
- info = f"πŸ“Š Cache Info:\n\n"
230
- info += f"Temp .pt files: {len(pt_files)} file(s), {temp_size_mb:.2f} MB\n"
231
- info += f"HuggingFace cache: {hf_repos} repo(s), {hf_size_mb:.2f} MB\n"
232
- info += f"Total: {temp_size_mb + hf_size_mb:.2f} MB"
 
 
 
 
 
 
 
233
  return info
234
  except Exception as e:
235
  return f"❌ Error: {str(e)}"
@@ -273,14 +292,12 @@ with gr.Blocks(title="HuggingFace Model Weight Inspector") as demo:
273
  fetch_btn = gr.Button("πŸ”Ž Fetch", variant="primary", scale=1)
274
 
275
  with gr.Tabs():
276
- with gr.Tab("Tensor Info"):
277
  with gr.Row():
278
  with gr.Column():
279
- info_output = gr.Markdown()
280
  with gr.Column():
281
- preview_output = gr.Markdown()
282
-
283
- with gr.Tab("Download & Logs"):
284
  download_output = gr.File(label="Download Tensor (.pt file)")
285
  log_output = gr.Textbox(label="πŸ“‹ Download Log", lines=6, interactive=False)
286
 
 
217
  for f in pt_files if os.path.exists(f))
218
  temp_size_mb = temp_size / (1024 * 1024)
219
 
220
+ info = f"πŸ“Š Cache Info:\n\n"
221
+ info += f"═══ Temp .pt files: {len(pt_files)} file(s), {temp_size_mb:.2f} MB ═══\n"
222
+
223
+ if pt_files:
224
+ for file in pt_files:
225
+ size = os.path.getsize(file) / (1024 * 1024)
226
+ filename = os.path.basename(file)
227
+ info += f" β€’ {filename} ({size:.2f} MB)\n"
228
+ else:
229
+ info += " (empty)\n"
230
+
231
  # HF cache
232
+ info += f"\n═══ HuggingFace Cache ═══\n"
233
  try:
234
  cache_info = scan_cache_dir()
235
  hf_size_mb = cache_info.size_on_disk / (1024 * 1024)
236
  hf_repos = len(cache_info.repos)
237
+
238
+ info += f"Total: {hf_repos} repo(s), {hf_size_mb:.2f} MB\n\n"
239
+
240
+ if hf_repos > 0:
241
+ for repo in cache_info.repos:
242
+ repo_size = repo.size_on_disk / (1024 * 1024)
243
+ info += f" πŸ“¦ {repo.repo_id}\n"
244
+ info += f" Size: {repo_size:.2f} MB, Revisions: {len(repo.revisions)}\n"
245
+ info += f" Last accessed: {repo.last_accessed}\n"
246
+ else:
247
+ info += " (empty)\n"
248
+ except Exception as e:
249
+ info += f" Error reading HF cache: {str(e)}\n"
250
+
251
+ info += f"\n═══ Total: {temp_size_mb + (hf_size_mb if 'hf_size_mb' in locals() else 0):.2f} MB ═══"
252
  return info
253
  except Exception as e:
254
  return f"❌ Error: {str(e)}"
 
292
  fetch_btn = gr.Button("πŸ”Ž Fetch", variant="primary", scale=1)
293
 
294
  with gr.Tabs():
295
+ with gr.Tab("Results"):
296
  with gr.Row():
297
  with gr.Column():
298
+ info_output = gr.Markdown(label="Tensor Info")
299
  with gr.Column():
300
+ preview_output = gr.Markdown(label="Tensor Preview")
 
 
301
  download_output = gr.File(label="Download Tensor (.pt file)")
302
  log_output = gr.Textbox(label="πŸ“‹ Download Log", lines=6, interactive=False)
303