Skip to content

Commit 59ee14a

Browse files
committed
minor tweaks for hf_cache location
1 parent a86a6fe commit 59ee14a

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/maxdiffusion/generate_flux2klein.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,16 @@ def main(argv):
661661
)
662662

663663
# 6. Locate cached PyTorch weights
664-
cache_dir = "/mnt/data/hf_cache/hub/models--black-forest-labs--FLUX.2-klein-4B/snapshots"
664+
hf_home = os.environ.get("HF_HOME")
665+
if not hf_home:
666+
if os.path.exists("/mnt/data/hf_cache"):
667+
hf_home = "/mnt/data/hf_cache"
668+
else:
669+
hf_home = os.path.expanduser("~/.cache/huggingface")
670+
671+
cache_dir = os.path.join(hf_home, "hub", "models--black-forest-labs--FLUX.2-klein-4B", "snapshots")
665672
if not os.path.exists(cache_dir):
666-
raise FileNotFoundError(f"Hugging Face cache directory not found: {cache_dir}")
673+
raise FileNotFoundError(f"Hugging Face cache directory not found: {cache_dir}. Please ensure HF_HOME is set correctly.")
667674
snapshots = os.listdir(cache_dir)
668675
if not snapshots:
669676
raise FileNotFoundError("No snapshots found in Hugging Face cache directory.")

0 commit comments

Comments
 (0)