Spaces:
Sleeping
Sleeping
Commit ·
b3330b2
1
Parent(s): b40674b
Inspect blob cache sizes; fail fast with local_files_only=True
Browse filesReplaces existence-only check with blob count + GB so we can see if
the cache is partial. Adds local_files_only=True to both from_pretrained
calls so a missing/incomplete cache raises an immediate OSError instead
of hanging on an indefinite download.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -45,20 +45,32 @@ print("[startup] all imports done", flush=True)
|
|
| 45 |
|
| 46 |
dtype = torch.bfloat16
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
_hf_cache = os.path.join(os.environ.get("HF_HOME", "/data/hf_cache"), "hub")
|
| 49 |
-
_transformer_cache = os.path.join(_hf_cache, "models--prithivMLmods--Qwen-Image-Edit-Rapid-AIO-V23")
|
| 50 |
-
_pipeline_cache = os.path.join(_hf_cache, "models--FireRedTeam--FireRed-Image-Edit-1.1")
|
| 51 |
print(f"[startup] HF cache dir : {_hf_cache}", flush=True)
|
| 52 |
-
print(f"[startup] transformer cache exists: {os.path.isdir(_transformer_cache)}", flush=True)
|
| 53 |
-
print(f"[startup] pipeline cache exists : {os.path.isdir(_pipeline_cache)}", flush=True)
|
| 54 |
if os.path.isdir(_hf_cache):
|
| 55 |
print(f"[startup] /hub contents: {os.listdir(_hf_cache)}", flush=True)
|
|
|
|
|
|
|
| 56 |
|
| 57 |
print("[startup] loading transformer from_pretrained (prithivMLmods/Qwen-Image-Edit-Rapid-AIO-V23)...", flush=True)
|
| 58 |
_transformer = QwenImageTransformer2DModel.from_pretrained(
|
| 59 |
"prithivMLmods/Qwen-Image-Edit-Rapid-AIO-V23",
|
| 60 |
torch_dtype=dtype,
|
| 61 |
device_map="cuda",
|
|
|
|
| 62 |
)
|
| 63 |
print("[startup] transformer loaded", flush=True)
|
| 64 |
|
|
@@ -67,6 +79,7 @@ pipe = QwenImageEditPlusPipeline.from_pretrained(
|
|
| 67 |
"FireRedTeam/FireRed-Image-Edit-1.1",
|
| 68 |
transformer=_transformer,
|
| 69 |
torch_dtype=dtype,
|
|
|
|
| 70 |
).to(device)
|
| 71 |
print("[startup] pipeline loaded and moved to device", flush=True)
|
| 72 |
|
|
|
|
| 45 |
|
| 46 |
dtype = torch.bfloat16
|
| 47 |
|
| 48 |
+
def _inspect_cache(label, path):
|
| 49 |
+
if not os.path.isdir(path):
|
| 50 |
+
print(f"[startup] {label}: MISSING", flush=True)
|
| 51 |
+
return
|
| 52 |
+
blobs_dir = os.path.join(path, "blobs")
|
| 53 |
+
if os.path.isdir(blobs_dir):
|
| 54 |
+
blobs = os.listdir(blobs_dir)
|
| 55 |
+
total = sum(os.path.getsize(os.path.join(blobs_dir, b)) for b in blobs
|
| 56 |
+
if os.path.isfile(os.path.join(blobs_dir, b)))
|
| 57 |
+
print(f"[startup] {label}: {len(blobs)} blobs, {total/1024**3:.2f} GB", flush=True)
|
| 58 |
+
else:
|
| 59 |
+
print(f"[startup] {label}: dir exists but no blobs/ subdirectory", flush=True)
|
| 60 |
+
|
| 61 |
_hf_cache = os.path.join(os.environ.get("HF_HOME", "/data/hf_cache"), "hub")
|
|
|
|
|
|
|
| 62 |
print(f"[startup] HF cache dir : {_hf_cache}", flush=True)
|
|
|
|
|
|
|
| 63 |
if os.path.isdir(_hf_cache):
|
| 64 |
print(f"[startup] /hub contents: {os.listdir(_hf_cache)}", flush=True)
|
| 65 |
+
_inspect_cache("transformer (V23)", os.path.join(_hf_cache, "models--prithivMLmods--Qwen-Image-Edit-Rapid-AIO-V23"))
|
| 66 |
+
_inspect_cache("pipeline (FireRed-Image-Edit-1.1)", os.path.join(_hf_cache, "models--FireRedTeam--FireRed-Image-Edit-1.1"))
|
| 67 |
|
| 68 |
print("[startup] loading transformer from_pretrained (prithivMLmods/Qwen-Image-Edit-Rapid-AIO-V23)...", flush=True)
|
| 69 |
_transformer = QwenImageTransformer2DModel.from_pretrained(
|
| 70 |
"prithivMLmods/Qwen-Image-Edit-Rapid-AIO-V23",
|
| 71 |
torch_dtype=dtype,
|
| 72 |
device_map="cuda",
|
| 73 |
+
local_files_only=True,
|
| 74 |
)
|
| 75 |
print("[startup] transformer loaded", flush=True)
|
| 76 |
|
|
|
|
| 79 |
"FireRedTeam/FireRed-Image-Edit-1.1",
|
| 80 |
transformer=_transformer,
|
| 81 |
torch_dtype=dtype,
|
| 82 |
+
local_files_only=True,
|
| 83 |
).to(device)
|
| 84 |
print("[startup] pipeline loaded and moved to device", flush=True)
|
| 85 |
|