File size: 2,379 Bytes
46d1c50
a7a451b
 
46d1c50
 
21ae650
 
a7a451b
 
f6b35ba
a7a451b
f6b35ba
a7a451b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f6b35ba
a7a451b
 
 
 
 
 
 
 
 
f6b35ba
a7a451b
 
 
 
d394724
a7a451b
 
 
 
 
 
21ae650
a7a451b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""
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__)

# Import all required functions from their actual locations in the utils package
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}")
    # Provide fallback implementations
    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")

# Export all functions for backward compatibility
__all__ = [
    "segment_person_hq",
    "refine_mask_hq", 
    "replace_background_hq",
    "create_professional_background",
    "PROFESSIONAL_BACKGROUNDS",
    "validate_video_file"
]

# For backward compatibility with utilities import
import sys
sys.modules["utilities"] = sys.modules[__name__]

logger.info("Utils module initialized successfully")