Spaces:
Sleeping
Sleeping
Commit ·
3dbdc96
1
Parent(s): 21806b3
Fix HuggingFace cache directory permissions
Browse files- Set HF_HOME, TRANSFORMERS_CACHE, HF_DATASETS_CACHE to writable temp directory
- Prevent PermissionError when downloading SmolVLM2 model to /.cache
- Configure cache directories before importing HF libraries
- Fix model download issues in Docker environment
- highlights_api.py +10 -2
highlights_api.py
CHANGED
|
@@ -4,13 +4,21 @@ FastAPI Wrapper for Audio-Enhanced Video Highlights
|
|
| 4 |
Converts your SmolVLM2 + Whisper system into a web API for Android apps
|
| 5 |
"""
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
from fastapi import FastAPI, UploadFile, File, HTTPException, BackgroundTasks
|
| 8 |
from fastapi.responses import FileResponse, JSONResponse
|
| 9 |
from fastapi.middleware.cors import CORSMiddleware
|
| 10 |
from pydantic import BaseModel
|
| 11 |
-
import os
|
| 12 |
import sys
|
| 13 |
-
import tempfile
|
| 14 |
import uuid
|
| 15 |
import json
|
| 16 |
import asyncio
|
|
|
|
| 4 |
Converts your SmolVLM2 + Whisper system into a web API for Android apps
|
| 5 |
"""
|
| 6 |
|
| 7 |
+
import os
|
| 8 |
+
import tempfile
|
| 9 |
+
|
| 10 |
+
# Set cache directories to writable locations before importing HF libraries
|
| 11 |
+
CACHE_DIR = tempfile.mkdtemp(prefix="hf_cache_")
|
| 12 |
+
os.environ['HF_HOME'] = CACHE_DIR
|
| 13 |
+
os.environ['TRANSFORMERS_CACHE'] = CACHE_DIR
|
| 14 |
+
os.environ['HF_DATASETS_CACHE'] = CACHE_DIR
|
| 15 |
+
os.environ['TORCH_HOME'] = CACHE_DIR
|
| 16 |
+
|
| 17 |
from fastapi import FastAPI, UploadFile, File, HTTPException, BackgroundTasks
|
| 18 |
from fastapi.responses import FileResponse, JSONResponse
|
| 19 |
from fastapi.middleware.cors import CORSMiddleware
|
| 20 |
from pydantic import BaseModel
|
|
|
|
| 21 |
import sys
|
|
|
|
| 22 |
import uuid
|
| 23 |
import json
|
| 24 |
import asyncio
|