Spaces:
Sleeping
Sleeping
File size: 1,560 Bytes
0ac505b f850bde 0ac505b f850bde 0ac505b f850bde 0ac505b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
import os
from pathlib import Path
from lmmvibes.vis_gradio.app import launch_app
from lmmvibes.utils.persistent_storage import (
get_hf_home_dir,
get_cache_dir,
is_persistent_storage_available,
get_storage_info
)
# Launch the app for Hugging Face Spaces
if __name__ == "__main__":
# Set up persistent storage for Hugging Face Spaces
if is_persistent_storage_available():
print("π Persistent storage available - configuring for HF Spaces")
# Set Hugging Face cache to persistent storage
hf_home = get_hf_home_dir()
os.environ.setdefault("HF_HOME", str(hf_home))
# Set cache directory for other libraries
cache_dir = get_cache_dir()
os.environ.setdefault("TRANSFORMERS_CACHE", str(cache_dir / "transformers"))
os.environ.setdefault("HF_DATASETS_CACHE", str(cache_dir / "datasets"))
# Print storage info
storage_info = get_storage_info()
print(f"π Data directory: {storage_info['data_dir']}")
print(f"ποΈ Cache directory: {storage_info['cache_dir']}")
print(f"π€ HF Home: {storage_info['hf_home']}")
if storage_info['storage_paths']:
print(f"πΎ Storage: {storage_info['storage_paths']['free_gb']:.1f}GB free / {storage_info['storage_paths']['total_gb']:.1f}GB total")
else:
print("β οΈ Persistent storage not available - using local storage")
# Launch the Gradio app
launch_app(share=False, server_name="0.0.0.0", server_port=7860) |