Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse files- .gitattributes +3 -3
- .gitignore +6 -1
- Assets/Cyberpunk.jpg +3 -0
- Assets/Picasso.jpg +3 -0
- Assets/Pixar.jpg +0 -0
- Assets/VanGogh.jpg +3 -0
- __pycache__/app.cpython-310.pyc +0 -0
- app.py +43 -3
- check_cache.py +10 -0
- hide_cache_contents.sh +49 -0
.gitattributes
CHANGED
|
@@ -33,6 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
Assets/Cyberpunk.jpg filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
Assets/Picasso.jpg filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
Assets/VanGogh.jpg filter=lfs diff=lfs merge=lfs -text
|
.gitignore
CHANGED
|
@@ -1 +1,6 @@
|
|
| 1 |
-
.env
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.env
|
| 2 |
+
# Ignore everything in .cache except the Assets directory
|
| 3 |
+
.cache/*
|
| 4 |
+
!.cache/Assets/
|
| 5 |
+
|
| 6 |
+
cache/
|
Assets/Cyberpunk.jpg
ADDED
|
Git LFS Details
|
Assets/Picasso.jpg
ADDED
|
Git LFS Details
|
Assets/Pixar.jpg
ADDED
|
Assets/VanGogh.jpg
ADDED
|
Git LFS Details
|
__pycache__/app.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/app.cpython-310.pyc and b/__pycache__/app.cpython-310.pyc differ
|
|
|
app.py
CHANGED
|
@@ -8,9 +8,49 @@ from dotenv import load_dotenv
|
|
| 8 |
load_dotenv()
|
| 9 |
|
| 10 |
def setup_cache_directory():
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
def download_space(cache_dir):
|
| 16 |
token = os.environ.get("HF_TOKEN")
|
|
|
|
| 8 |
load_dotenv()
|
| 9 |
|
| 10 |
def setup_cache_directory():
|
| 11 |
+
"""Create a hidden cache directory '.cache'.
|
| 12 |
+
|
| 13 |
+
If an existing 'cache' directory exists, migrate its contents into '.cache'.
|
| 14 |
+
Set restrictive permissions (owner rwx) and on macOS set the Finder hidden flag
|
| 15 |
+
unless the environment variable `HIDE_CACHE` is explicitly set to '0'.
|
| 16 |
+
"""
|
| 17 |
+
hidden_cache = Path(".cache")
|
| 18 |
+
public_cache = Path("cache")
|
| 19 |
+
|
| 20 |
+
# If the hidden cache doesn't exist but a public one does, move it.
|
| 21 |
+
try:
|
| 22 |
+
if not hidden_cache.exists():
|
| 23 |
+
if public_cache.exists():
|
| 24 |
+
# Prefer move to preserve contents and metadata
|
| 25 |
+
public_cache.rename(hidden_cache)
|
| 26 |
+
else:
|
| 27 |
+
hidden_cache.mkdir(exist_ok=True)
|
| 28 |
+
else:
|
| 29 |
+
# ensure it exists
|
| 30 |
+
hidden_cache.mkdir(exist_ok=True)
|
| 31 |
+
|
| 32 |
+
# Restrict permissions to owner only (rwx------)
|
| 33 |
+
try:
|
| 34 |
+
hidden_cache.chmod(0o700)
|
| 35 |
+
except Exception:
|
| 36 |
+
# chmod may fail on some filesystems or platforms; ignore
|
| 37 |
+
pass
|
| 38 |
+
|
| 39 |
+
# On macOS, optionally set Finder hidden flag for extra concealment
|
| 40 |
+
if sys.platform == "darwin":
|
| 41 |
+
hide_flag = os.environ.get("HIDE_CACHE", "1")
|
| 42 |
+
if hide_flag != "0":
|
| 43 |
+
try:
|
| 44 |
+
# 'chflags hidden <path>' will make the folder hidden in Finder
|
| 45 |
+
os.system(f"/usr/bin/chflags hidden {hidden_cache}")
|
| 46 |
+
except Exception:
|
| 47 |
+
pass
|
| 48 |
+
|
| 49 |
+
return hidden_cache
|
| 50 |
+
except Exception:
|
| 51 |
+
# Fallback: try to create a simple cache folder named 'cache'
|
| 52 |
+
public_cache.mkdir(exist_ok=True)
|
| 53 |
+
return public_cache
|
| 54 |
|
| 55 |
def download_space(cache_dir):
|
| 56 |
token = os.environ.get("HF_TOKEN")
|
check_cache.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
p = Path('.cache')
|
| 3 |
+
print('path', p)
|
| 4 |
+
print('exists', p.exists())
|
| 5 |
+
try:
|
| 6 |
+
st = p.stat()
|
| 7 |
+
print('mode', oct(st.st_mode & 0o777))
|
| 8 |
+
print('uid', st.st_uid, 'gid', st.st_gid)
|
| 9 |
+
except Exception as e:
|
| 10 |
+
print('error', e)
|
hide_cache_contents.sh
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env zsh
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
|
| 4 |
+
# hide_cache_contents.sh
|
| 5 |
+
# Hides all files and folders inside .cache except the Assets folder by setting
|
| 6 |
+
# the macOS `hidden` file flag (chflags hidden). Run with `--undo` to remove
|
| 7 |
+
# the hidden flag.
|
| 8 |
+
|
| 9 |
+
SCRIPT_DIR="$(cd "$(dirname "${0}")" && pwd)"
|
| 10 |
+
CACHE_DIR="$SCRIPT_DIR/.cache"
|
| 11 |
+
|
| 12 |
+
if [ ! -d "$CACHE_DIR" ]; then
|
| 13 |
+
echo ".cache directory not found at $CACHE_DIR"
|
| 14 |
+
exit 1
|
| 15 |
+
fi
|
| 16 |
+
|
| 17 |
+
ACTION="hide"
|
| 18 |
+
if [ "${1:-}" = "--undo" ]; then
|
| 19 |
+
ACTION="unhide"
|
| 20 |
+
fi
|
| 21 |
+
|
| 22 |
+
echo "Will $ACTION items in: $CACHE_DIR (preserving Assets)"
|
| 23 |
+
|
| 24 |
+
for entry in "$CACHE_DIR"/.* "$CACHE_DIR"/*; do
|
| 25 |
+
# skip nonexistent globs
|
| 26 |
+
[ -e "$entry" ] || continue
|
| 27 |
+
base=$(basename "$entry")
|
| 28 |
+
# skip current/parent
|
| 29 |
+
if [ "$base" = "." ] || [ "$base" = ".." ]; then
|
| 30 |
+
continue
|
| 31 |
+
fi
|
| 32 |
+
# always preserve Assets (do not hide it)
|
| 33 |
+
if [ "$base" = "Assets" ]; then
|
| 34 |
+
if [ "$ACTION" = "hide" ]; then
|
| 35 |
+
chflags nohidden "$entry" 2>/dev/null || true
|
| 36 |
+
else
|
| 37 |
+
chflags nohidden "$entry" 2>/dev/null || true
|
| 38 |
+
fi
|
| 39 |
+
continue
|
| 40 |
+
fi
|
| 41 |
+
|
| 42 |
+
if [ "$ACTION" = "hide" ]; then
|
| 43 |
+
chflags hidden "$entry" 2>/dev/null || true
|
| 44 |
+
else
|
| 45 |
+
chflags nohidden "$entry" 2>/dev/null || true
|
| 46 |
+
fi
|
| 47 |
+
done
|
| 48 |
+
|
| 49 |
+
echo "Done: $ACTION completed. Use '$0 --undo' to revert."
|