|
|
""" |
|
|
Fixed utils/__init__.py - Properly imports existing functions from utils modules |
|
|
Replaces the recursive lazy-loading approach with direct imports |
|
|
""" |
|
|
|
|
|
from __future__ import annotations |
|
|
|
|
|
import logging |
|
|
from typing import Any |
|
|
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
|
try: |
|
|
from .cv_processing import ( |
|
|
segment_person_hq, |
|
|
refine_mask_hq, |
|
|
replace_background_hq, |
|
|
PROFESSIONAL_BACKGROUNDS |
|
|
) |
|
|
logger.debug("Successfully imported cv_processing functions") |
|
|
except ImportError as e: |
|
|
logger.error(f"Failed to import cv_processing functions: {e}") |
|
|
|
|
|
def segment_person_hq(*args, **kwargs): |
|
|
raise NotImplementedError("segment_person_hq not available") |
|
|
def refine_mask_hq(*args, **kwargs): |
|
|
raise NotImplementedError("refine_mask_hq not available") |
|
|
def replace_background_hq(*args, **kwargs): |
|
|
raise NotImplementedError("replace_background_hq not available") |
|
|
PROFESSIONAL_BACKGROUNDS = {} |
|
|
|
|
|
try: |
|
|
from .utils import ( |
|
|
validate_video_file, |
|
|
) |
|
|
logger.debug("Successfully imported utils functions") |
|
|
except ImportError as e: |
|
|
logger.error(f"Failed to import utils functions: {e}") |
|
|
def validate_video_file(*args, **kwargs): |
|
|
raise NotImplementedError("validate_video_file not available") |
|
|
|
|
|
try: |
|
|
from .cv_processing import create_professional_background |
|
|
logger.debug("Successfully imported create_professional_background") |
|
|
except ImportError: |
|
|
try: |
|
|
from .utils import create_professional_background |
|
|
logger.debug("Successfully imported create_professional_background from utils") |
|
|
except ImportError as e: |
|
|
logger.error(f"Failed to import create_professional_background: {e}") |
|
|
def create_professional_background(*args, **kwargs): |
|
|
raise NotImplementedError("create_professional_background not available") |
|
|
|
|
|
|
|
|
__all__ = [ |
|
|
"segment_person_hq", |
|
|
"refine_mask_hq", |
|
|
"replace_background_hq", |
|
|
"create_professional_background", |
|
|
"PROFESSIONAL_BACKGROUNDS", |
|
|
"validate_video_file" |
|
|
] |
|
|
|
|
|
|
|
|
import sys |
|
|
sys.modules["utilities"] = sys.modules[__name__] |
|
|
|
|
|
logger.info("Utils module initialized successfully") |