tester343 commited on
Commit
c97c04c
·
verified ·
1 Parent(s): d828036

Update app_enhanced.py

Browse files
Files changed (1) hide show
  1. app_enhanced.py +17 -6
app_enhanced.py CHANGED
@@ -16,36 +16,40 @@ try:
16
  import srt
17
  except ImportError as e:
18
  print(f"❌ CRITICAL ERROR: Missing python library. {e}")
19
- # Dummy definitions to allow app to start and show error in UI
20
  cv2 = None
21
  np = None
22
  Image = None
23
  srt = None
24
 
25
  # --- 2. BACKEND MODULE IMPORTS (WITH DUMMY FALLBACKS) ---
26
- # This allows the app to run even if complex backend modules fail to load
27
  def dummy_function(*args, **kwargs): return 0, 0, None, None
28
 
29
  try:
30
  from backend.keyframes.keyframes import black_bar_crop
 
31
  except Exception:
32
  black_bar_crop = dummy_function
33
 
34
  try:
35
  from backend.simple_color_enhancer import SimpleColorEnhancer
 
36
  except Exception:
37
  class SimpleColorEnhancer:
38
  def enhance_single(self, *args): pass
39
 
40
  try:
41
  from backend.quality_color_enhancer import QualityColorEnhancer
 
42
  except Exception:
43
  class QualityColorEnhancer:
44
  def enhance_single(self, *args): pass
45
 
46
  try:
47
  from backend.class_def import bubble, panel, Page
48
- except Exception:
 
 
 
49
  def bubble(**kwargs): return kwargs
50
  def panel(**kwargs): return kwargs
51
  class Page:
@@ -56,8 +60,8 @@ try:
56
  from backend.ai_bubble_placement import ai_bubble_placer
57
  from backend.subtitles.subs_real import get_real_subtitles
58
  from backend.keyframes.keyframes_simple import generate_keyframes_simple
 
59
  except Exception:
60
- # If backend fails, define minimal dummies to prevent crash
61
  def get_real_subtitles(v): pass
62
  class DummyDetector:
63
  def detect_faces(self, p): return []
@@ -285,7 +289,6 @@ class EnhancedComicGenerator:
285
  except: pass
286
 
287
  def cleanup(self):
288
- # Simple cleanup
289
  if os.path.exists(self.frames_dir): shutil.rmtree(self.frames_dir)
290
  os.makedirs(self.frames_dir, exist_ok=True)
291
 
@@ -334,7 +337,15 @@ class EnhancedComicGenerator:
334
  fname = f"frame_{i}.png"
335
  cv2.imwrite(os.path.join(self.frames_dir, fname), frame)
336
  frame_files.append(fname)
337
- bubbles.append(bubble(dialog=sub.content, bubble_offset_x=50, bubble_offset_y=20))
 
 
 
 
 
 
 
 
338
  cap.release()
339
 
340
  # 3. Assemble
 
16
  import srt
17
  except ImportError as e:
18
  print(f"❌ CRITICAL ERROR: Missing python library. {e}")
 
19
  cv2 = None
20
  np = None
21
  Image = None
22
  srt = None
23
 
24
  # --- 2. BACKEND MODULE IMPORTS (WITH DUMMY FALLBACKS) ---
 
25
  def dummy_function(*args, **kwargs): return 0, 0, None, None
26
 
27
  try:
28
  from backend.keyframes.keyframes import black_bar_crop
29
+ print("✅ Black bar cropping module loaded.")
30
  except Exception:
31
  black_bar_crop = dummy_function
32
 
33
  try:
34
  from backend.simple_color_enhancer import SimpleColorEnhancer
35
+ print("✅ SimpleColorEnhancer loaded.")
36
  except Exception:
37
  class SimpleColorEnhancer:
38
  def enhance_single(self, *args): pass
39
 
40
  try:
41
  from backend.quality_color_enhancer import QualityColorEnhancer
42
+ print("✅ QualityColorEnhancer loaded.")
43
  except Exception:
44
  class QualityColorEnhancer:
45
  def enhance_single(self, *args): pass
46
 
47
  try:
48
  from backend.class_def import bubble, panel, Page
49
+ print("✅ Core class definitions loaded.")
50
+ except Exception as e:
51
+ print(f"⚠️ Loading fallback definitions: {e}")
52
+ # Fallback if import fails
53
  def bubble(**kwargs): return kwargs
54
  def panel(**kwargs): return kwargs
55
  class Page:
 
60
  from backend.ai_bubble_placement import ai_bubble_placer
61
  from backend.subtitles.subs_real import get_real_subtitles
62
  from backend.keyframes.keyframes_simple import generate_keyframes_simple
63
+ print("✅ Core utility modules loaded.")
64
  except Exception:
 
65
  def get_real_subtitles(v): pass
66
  class DummyDetector:
67
  def detect_faces(self, p): return []
 
289
  except: pass
290
 
291
  def cleanup(self):
 
292
  if os.path.exists(self.frames_dir): shutil.rmtree(self.frames_dir)
293
  os.makedirs(self.frames_dir, exist_ok=True)
294
 
 
337
  fname = f"frame_{i}.png"
338
  cv2.imwrite(os.path.join(self.frames_dir, fname), frame)
339
  frame_files.append(fname)
340
+ # FIX: Added required arguments for bubble constructor to prevent TypeError
341
+ bubbles.append(bubble(
342
+ dialog=sub.content,
343
+ bubble_offset_x=50,
344
+ bubble_offset_y=20,
345
+ lip_x=-1,
346
+ lip_y=-1,
347
+ emotion='normal'
348
+ ))
349
  cap.release()
350
 
351
  # 3. Assemble