qqwjq1981 commited on
Commit
d09e1fc
Β·
verified Β·
1 Parent(s): e67bb3b

Update utils/bubble_utils.py

Browse files
Files changed (1) hide show
  1. utils/bubble_utils.py +8 -4
utils/bubble_utils.py CHANGED
@@ -74,7 +74,7 @@ def visualize_all_debug(img, translations, bubble_polygons, step_name="debug", p
74
  out_path = f"{prefix}_{step_name}.png"
75
  debug.save(out_path)
76
  print(f"πŸ“Œ Saved debug visualization β†’ {out_path}")
77
- return debug
78
 
79
 
80
  # ===================== Main Bubble Translation Pipeline ===================
@@ -87,6 +87,7 @@ def bubble_pipeline_single(file_obj, num_chunks=1, polygon_strategy="hybrid", de
87
  - Bubble-aware polygon correction
88
  - Clean text rendering inside refined bubble interiors
89
  """
 
90
 
91
  # -------------------------------------------------------
92
  # 1. Load image
@@ -101,10 +102,12 @@ def bubble_pipeline_single(file_obj, num_chunks=1, polygon_strategy="hybrid", de
101
  print(f"πŸ” Found {len(bubble_polygons)} refined bubbles")
102
 
103
  if debug:
104
- visualize_all_debug(
105
  full_img, [], bubble_polygons,
106
  step_name="bubbles_only", prefix="bubble_dbg"
107
  )
 
 
108
 
109
  # -------------------------------------------------------
110
  # 3. MASK-BASED OCR (replaces standard OCR)
@@ -132,10 +135,11 @@ def bubble_pipeline_single(file_obj, num_chunks=1, polygon_strategy="hybrid", de
132
  print("⚠️ No bubble polygons β†’ skip polygon correction")
133
 
134
  if debug:
135
- visualize_all_debug(
136
  full_img, translations, bubble_polygons,
137
  step_name="after_correction", prefix="bubble_dbg"
138
  )
 
139
 
140
  # -------------------------------------------------------
141
  # 5. Render translated text inside refined interior polygons
@@ -178,7 +182,7 @@ def bubble_pipeline_single(file_obj, num_chunks=1, polygon_strategy="hybrid", de
178
 
179
  table_data = [[t["original"], t["translated"]] for t in translations]
180
 
181
- return filename, orig_html, trans_html, table_data, [translations]
182
 
183
  def split_image_into_chunks(img, num_chunks):
184
  """
 
74
  out_path = f"{prefix}_{step_name}.png"
75
  debug.save(out_path)
76
  print(f"πŸ“Œ Saved debug visualization β†’ {out_path}")
77
+ return out_path
78
 
79
 
80
  # ===================== Main Bubble Translation Pipeline ===================
 
87
  - Bubble-aware polygon correction
88
  - Clean text rendering inside refined bubble interiors
89
  """
90
+ debug_files = []
91
 
92
  # -------------------------------------------------------
93
  # 1. Load image
 
102
  print(f"πŸ” Found {len(bubble_polygons)} refined bubbles")
103
 
104
  if debug:
105
+ p = visualize_all_debug(
106
  full_img, [], bubble_polygons,
107
  step_name="bubbles_only", prefix="bubble_dbg"
108
  )
109
+ debug_files.append(p)
110
+
111
 
112
  # -------------------------------------------------------
113
  # 3. MASK-BASED OCR (replaces standard OCR)
 
135
  print("⚠️ No bubble polygons β†’ skip polygon correction")
136
 
137
  if debug:
138
+ p = visualize_all_debug(
139
  full_img, translations, bubble_polygons,
140
  step_name="after_correction", prefix="bubble_dbg"
141
  )
142
+ debug_files.append(p)
143
 
144
  # -------------------------------------------------------
145
  # 5. Render translated text inside refined interior polygons
 
182
 
183
  table_data = [[t["original"], t["translated"]] for t in translations]
184
 
185
+ return filename, orig_html, trans_html, table_data, [translations], debug_files
186
 
187
  def split_image_into_chunks(img, num_chunks):
188
  """