|
|
|
|
|
"""BackgroundFX Pro - Hugging Face Spaces Entry Point""" |
|
|
import sys |
|
|
import os |
|
|
import re |
|
|
from pathlib import Path |
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
|
|
|
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__": |
|
|
demo = create_interface() |
|
|
demo.launch(server_name="0.0.0.0", server_port=7860, show_error=True) |