Spaces:
Sleeping
Sleeping
Fix: correct InsightFace model directory structure (root/models/name)
Browse files- Dockerfile +3 -3
- app/config.py +1 -1
- setup_models.py +5 -3
Dockerfile
CHANGED
|
@@ -24,8 +24,8 @@ RUN useradd -m -u 1000 user
|
|
| 24 |
WORKDIR /home/user/app
|
| 25 |
|
| 26 |
# Create directories with correct ownership for models
|
| 27 |
-
RUN mkdir -p /home/user/app/models/
|
| 28 |
-
/home/user/app/models
|
| 29 |
/home/user/app/.cache \
|
| 30 |
&& chown -R user:user /home/user/app
|
| 31 |
|
|
@@ -47,7 +47,7 @@ RUN python setup_models.py
|
|
| 47 |
|
| 48 |
# Set HuggingFace and InsightFace to use local models
|
| 49 |
ENV HF_HOME=/home/user/app/.cache/huggingface
|
| 50 |
-
ENV INSIGHTFACE_HOME=/home/user/app/
|
| 51 |
|
| 52 |
# Expose port (HF Spaces uses 7860 by default)
|
| 53 |
EXPOSE 7860
|
|
|
|
| 24 |
WORKDIR /home/user/app
|
| 25 |
|
| 26 |
# Create directories with correct ownership for models
|
| 27 |
+
RUN mkdir -p /home/user/app/models/anti_spoof \
|
| 28 |
+
/home/user/app/insightface_models/models \
|
| 29 |
/home/user/app/.cache \
|
| 30 |
&& chown -R user:user /home/user/app
|
| 31 |
|
|
|
|
| 47 |
|
| 48 |
# Set HuggingFace and InsightFace to use local models
|
| 49 |
ENV HF_HOME=/home/user/app/.cache/huggingface
|
| 50 |
+
ENV INSIGHTFACE_HOME=/home/user/app/insightface_models
|
| 51 |
|
| 52 |
# Expose port (HF Spaces uses 7860 by default)
|
| 53 |
EXPOSE 7860
|
app/config.py
CHANGED
|
@@ -16,7 +16,7 @@ class Settings(BaseSettings):
|
|
| 16 |
DEBUG: bool = True
|
| 17 |
|
| 18 |
# Model paths
|
| 19 |
-
AURAFACE_MODEL_DIR: str = "models/auraface"
|
| 20 |
ANTISPOOF_MODEL_DIR: str = "models/anti_spoof"
|
| 21 |
SILENT_FACE_REPO_DIR: str = "Silent-Face-Anti-Spoofing"
|
| 22 |
|
|
|
|
| 16 |
DEBUG: bool = True
|
| 17 |
|
| 18 |
# Model paths
|
| 19 |
+
AURAFACE_MODEL_DIR: str = "insightface_models/models/auraface"
|
| 20 |
ANTISPOOF_MODEL_DIR: str = "models/anti_spoof"
|
| 21 |
SILENT_FACE_REPO_DIR: str = "Silent-Face-Anti-Spoofing"
|
| 22 |
|
setup_models.py
CHANGED
|
@@ -25,7 +25,9 @@ def setup_auraface():
|
|
| 25 |
try:
|
| 26 |
from huggingface_hub import snapshot_download
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
| 29 |
model_dir.mkdir(parents=True, exist_ok=True)
|
| 30 |
|
| 31 |
print("Downloading AuraFace-v1 from HuggingFace...")
|
|
@@ -113,8 +115,8 @@ def verify_models():
|
|
| 113 |
print("=" * 50)
|
| 114 |
|
| 115 |
required_files = [
|
| 116 |
-
# AuraFace models (
|
| 117 |
-
"models/auraface",
|
| 118 |
# Anti-spoofing models
|
| 119 |
"models/anti_spoof/anti_spoof_models",
|
| 120 |
"models/anti_spoof/detection_model",
|
|
|
|
| 25 |
try:
|
| 26 |
from huggingface_hub import snapshot_download
|
| 27 |
|
| 28 |
+
# InsightFace expects models at {root}/models/{name}/
|
| 29 |
+
# So we download to insightface_models/models/auraface/
|
| 30 |
+
model_dir = Path("insightface_models/models/auraface")
|
| 31 |
model_dir.mkdir(parents=True, exist_ok=True)
|
| 32 |
|
| 33 |
print("Downloading AuraFace-v1 from HuggingFace...")
|
|
|
|
| 115 |
print("=" * 50)
|
| 116 |
|
| 117 |
required_files = [
|
| 118 |
+
# AuraFace models (InsightFace expects {root}/models/{name}/)
|
| 119 |
+
"insightface_models/models/auraface",
|
| 120 |
# Anti-spoofing models
|
| 121 |
"models/anti_spoof/anti_spoof_models",
|
| 122 |
"models/anti_spoof/detection_model",
|