File size: 3,052 Bytes
1289298
7221831
4bd2529
7221831
16b0ea4
8affb32
f34c835
16b0ea4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7221831
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8affb32
 
 
f34c835
8affb32
f34c835
16b0ea4
8affb32
bb31aac
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env python3
"""BackgroundFX Pro - Hugging Face Spaces Entry Point"""
import sys
import os
import re
from pathlib import Path

# ============ IMPORT SEARCH SECTION ============
print("\n" + "="*60, flush=True)
print("SEARCHING FOR PROBLEMATIC IMPORTS", flush=True)
print("="*60, flush=True)

problematic_patterns = [
    (r'^import cv2', 'OpenCV'),
    (r'^from cv2', 'OpenCV'),
    (r'^import numpy', 'NumPy'),
    (r'^from numpy', 'NumPy'),
    (r'^from utils\.cv_processing', 'cv_processing utils'),
    (r'^from processing\.video', 'video processing'),
]

found_issues = []

for root, dirs, files in os.walk("."):
    dirs[:] = [d for d in dirs if not d.startswith('.') and d != '__pycache__']
    for file in files:
        if file.endswith('.py'):
            filepath = os.path.join(root, file)
            try:
                with open(filepath, 'r') as f:
                    lines = f.readlines()
                    for i, line in enumerate(lines, 1):
                        stripped = line.strip()
                        if not stripped or stripped.startswith('#'):
                            continue
                        if line.startswith(' ') or line.startswith('\t'):
                            continue
                        for pattern, lib_name in problematic_patterns:
                            if re.match(pattern, stripped):
                                found_issues.append(f"{filepath}:{i} -> {stripped} [{lib_name}]")
            except:
                pass

if found_issues:
    print("FOUND TOP-LEVEL IMPORTS THAT COULD CAUSE WASM ISSUES:", flush=True)
    for issue in found_issues:
        print(f"  {issue}", flush=True)
else:
    print("No problematic top-level imports found", flush=True)

print("="*60 + "\n", flush=True)

# ============ FILE STRUCTURE SECTION ============
print("\n" + "="*60, flush=True)
print("HUGGING FACE SPACE FILE STRUCTURE", flush=True)
print("="*60, flush=True)
print(f"Working Directory: {os.getcwd()}", flush=True)
print(f"Python Version: {sys.version}", flush=True)
print("\nDirectory Contents:", flush=True)

for root, dirs, files in os.walk("."):
    dirs[:] = [d for d in dirs if not d.startswith('.') and d != '__pycache__']
    level = root.replace(".", "", 1).count(os.sep)
    indent = "  " * level
    print(f"{indent}{os.path.basename(root)}/", flush=True)
    subindent = "  " * (level + 1)
    for file in sorted(files)[:5]:
        if not file.startswith('.'):
            print(f"{subindent}{file}", flush=True)
    if len(files) > 5:
        print(f"{subindent}... and {len(files)-5} more files", flush=True)

print("="*60 + "\n", flush=True)
# ============ END OF DEBUG SECTION ============

# Now continue with your normal code
ROOT = Path(__file__).resolve().parent
if str(ROOT) not in sys.path:
    sys.path.insert(0, str(ROOT))

from ui.ui_components import create_interface

if __name__ == "__main__":  # FIXED: Changed **name** to __name__
    demo = create_interface()
    demo.launch(server_name="0.0.0.0", server_port=7860, show_error=True)