Spaces:
Runtime error
Runtime error
Show detailed file list in cache info and merge tabs
Browse files
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 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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("
|
| 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 |
|