app_conf.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright (c) Meta Platforms, Inc. and affiliates.
  2. # All rights reserved.
  3. # This source code is licensed under the license found in the
  4. # LICENSE file in the root directory of this source tree.
  5. import logging
  6. import os
  7. from pathlib import Path
  8. logger = logging.getLogger(__name__)
  9. APP_ROOT = os.getenv("APP_ROOT", "/opt/sam2")
  10. API_URL = os.getenv("API_URL", "http://localhost:7263")
  11. MODEL_SIZE = os.getenv("MODEL_SIZE", "base_plus")
  12. logger.info(f"using model size {MODEL_SIZE}")
  13. FFMPEG_NUM_THREADS = int(os.getenv("FFMPEG_NUM_THREADS", "1"))
  14. # Path for all data used in API
  15. DATA_PATH = Path(os.getenv("DATA_PATH", "/data"))
  16. # Max duration an uploaded video can have in seconds. The default is 10
  17. # seconds.
  18. MAX_UPLOAD_VIDEO_DURATION = float(os.environ.get("MAX_UPLOAD_VIDEO_DURATION", "10"))
  19. # If set, it will define which video is returned by the default video query for
  20. # desktop
  21. DEFAULT_VIDEO_PATH = os.getenv("DEFAULT_VIDEO_PATH")
  22. # Prefix for gallery videos
  23. GALLERY_PREFIX = "gallery"
  24. # Path where all gallery videos are stored
  25. GALLERY_PATH = DATA_PATH / GALLERY_PREFIX
  26. # Prefix for uploaded videos
  27. UPLOADS_PREFIX = "uploads"
  28. # Path where all uploaded videos are stored
  29. UPLOADS_PATH = DATA_PATH / UPLOADS_PREFIX
  30. # Prefix for video posters (1st frame of video)
  31. POSTERS_PREFIX = "posters"
  32. # Path where all posters are stored
  33. POSTERS_PATH = DATA_PATH / POSTERS_PREFIX
  34. # Make sure any of those paths exist
  35. os.makedirs(DATA_PATH, exist_ok=True)
  36. os.makedirs(GALLERY_PATH, exist_ok=True)
  37. os.makedirs(UPLOADS_PATH, exist_ok=True)
  38. os.makedirs(POSTERS_PATH, exist_ok=True)