feat: Add DeepFace model weights download functionality to installation script
This commit introduces a new function in the `install.sh` script to download DeepFace model weights, enhancing the setup process for users. The function checks for the presence of DeepFace and attempts to download the ArcFace model weights, providing fallback options and user-friendly messages for manual download if automatic attempts fail. This improvement streamlines the initial configuration for facial recognition capabilities in the application.
This commit is contained in:
+16
-3
@@ -8,7 +8,8 @@ from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
# Load environment variables from .env file if it exists
|
||||
env_path = Path(__file__).parent.parent.parent.parent / ".env"
|
||||
# Path: backend/db/session.py -> backend/db -> backend -> punimtag/ -> .env
|
||||
env_path = Path(__file__).parent.parent.parent / ".env"
|
||||
load_dotenv(dotenv_path=env_path)
|
||||
|
||||
|
||||
@@ -87,8 +88,16 @@ try:
|
||||
**auth_pool_kwargs
|
||||
)
|
||||
AuthSessionLocal = sessionmaker(bind=auth_engine, autoflush=False, autocommit=False, future=True)
|
||||
except ValueError:
|
||||
except ValueError as e:
|
||||
# DATABASE_URL_AUTH not set - auth database not available
|
||||
print(f"[DB Session] ⚠️ Auth database not configured: {e}")
|
||||
auth_engine = None
|
||||
AuthSessionLocal = None
|
||||
except Exception as e:
|
||||
# Other errors (connection failures, etc.) - log but don't crash
|
||||
import os
|
||||
print(f"[DB Session] ⚠️ Failed to initialize auth database: {e}")
|
||||
print(f"[DB Session] URL was: {os.getenv('DATABASE_URL_AUTH', 'not set')}")
|
||||
auth_engine = None
|
||||
AuthSessionLocal = None
|
||||
|
||||
@@ -96,7 +105,11 @@ except ValueError:
|
||||
def get_auth_db() -> Generator:
|
||||
"""Yield a DB session for auth database request lifecycle."""
|
||||
if AuthSessionLocal is None:
|
||||
raise ValueError("Auth database not configured. Set DATABASE_URL_AUTH environment variable.")
|
||||
from fastapi import HTTPException, status
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||
detail="Auth database not configured. Please set DATABASE_URL_AUTH environment variable in the backend configuration."
|
||||
)
|
||||
db = AuthSessionLocal()
|
||||
try:
|
||||
yield db
|
||||
|
||||
Reference in New Issue
Block a user