MogensR commited on
Commit
16b0ea4
·
verified ·
1 Parent(s): 7a4dd4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -4
app.py CHANGED
@@ -2,9 +2,55 @@
2
  """BackgroundFX Pro - Hugging Face Spaces Entry Point"""
3
  import sys
4
  import os
 
5
  from pathlib import Path
6
 
7
- # ============ ADD THIS SECTION FOR DEBUGGING ============
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  print("\n" + "="*60, flush=True)
9
  print("HUGGING FACE SPACE FILE STRUCTURE", flush=True)
10
  print("="*60, flush=True)
@@ -13,13 +59,11 @@
13
  print("\nDirectory Contents:", flush=True)
14
 
15
  for root, dirs, files in os.walk("."):
16
- # Skip .git and cache directories
17
  dirs[:] = [d for d in dirs if not d.startswith('.') and d != '__pycache__']
18
  level = root.replace(".", "", 1).count(os.sep)
19
  indent = " " * level
20
  print(f"{indent}{os.path.basename(root)}/", flush=True)
21
  subindent = " " * (level + 1)
22
- # Show first 5 files in each directory
23
  for file in sorted(files)[:5]:
24
  if not file.startswith('.'):
25
  print(f"{subindent}{file}", flush=True)
@@ -36,6 +80,6 @@
36
 
37
  from ui.ui_components import create_interface
38
 
39
- if __name__ == "__main__":
40
  demo = create_interface()
41
  demo.launch(server_name="0.0.0.0", server_port=7860, show_error=True)
 
2
  """BackgroundFX Pro - Hugging Face Spaces Entry Point"""
3
  import sys
4
  import os
5
+ import re
6
  from pathlib import Path
7
 
8
+ # ============ IMPORT SEARCH SECTION ============
9
+ print("\n" + "="*60, flush=True)
10
+ print("SEARCHING FOR PROBLEMATIC IMPORTS", flush=True)
11
+ print("="*60, flush=True)
12
+
13
+ problematic_patterns = [
14
+ (r'^import cv2', 'OpenCV'),
15
+ (r'^from cv2', 'OpenCV'),
16
+ (r'^import numpy', 'NumPy'),
17
+ (r'^from numpy', 'NumPy'),
18
+ (r'^from utils\.cv_processing', 'cv_processing utils'),
19
+ (r'^from processing\.video', 'video processing'),
20
+ ]
21
+
22
+ found_issues = []
23
+
24
+ for root, dirs, files in os.walk("."):
25
+ dirs[:] = [d for d in dirs if not d.startswith('.') and d != '__pycache__']
26
+ for file in files:
27
+ if file.endswith('.py'):
28
+ filepath = os.path.join(root, file)
29
+ try:
30
+ with open(filepath, 'r') as f:
31
+ lines = f.readlines()
32
+ for i, line in enumerate(lines, 1):
33
+ stripped = line.strip()
34
+ if not stripped or stripped.startswith('#'):
35
+ continue
36
+ if line.startswith(' ') or line.startswith('\t'):
37
+ continue
38
+ for pattern, lib_name in problematic_patterns:
39
+ if re.match(pattern, stripped):
40
+ found_issues.append(f"{filepath}:{i} -> {stripped} [{lib_name}]")
41
+ except:
42
+ pass
43
+
44
+ if found_issues:
45
+ print("FOUND TOP-LEVEL IMPORTS THAT COULD CAUSE WASM ISSUES:", flush=True)
46
+ for issue in found_issues:
47
+ print(f" {issue}", flush=True)
48
+ else:
49
+ print("No problematic top-level imports found", flush=True)
50
+
51
+ print("="*60 + "\n", flush=True)
52
+
53
+ # ============ FILE STRUCTURE SECTION ============
54
  print("\n" + "="*60, flush=True)
55
  print("HUGGING FACE SPACE FILE STRUCTURE", flush=True)
56
  print("="*60, flush=True)
 
59
  print("\nDirectory Contents:", flush=True)
60
 
61
  for root, dirs, files in os.walk("."):
 
62
  dirs[:] = [d for d in dirs if not d.startswith('.') and d != '__pycache__']
63
  level = root.replace(".", "", 1).count(os.sep)
64
  indent = " " * level
65
  print(f"{indent}{os.path.basename(root)}/", flush=True)
66
  subindent = " " * (level + 1)
 
67
  for file in sorted(files)[:5]:
68
  if not file.startswith('.'):
69
  print(f"{subindent}{file}", flush=True)
 
80
 
81
  from ui.ui_components import create_interface
82
 
83
+ if __name__ == "__main__": # FIXED: Changed **name** to __name__
84
  demo = create_interface()
85
  demo.launch(server_name="0.0.0.0", server_port=7860, show_error=True)