SohomToom commited on
Commit
966bd1f
·
verified ·
1 Parent(s): 2502b39

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -41,17 +41,18 @@ def sample_border_color(image, box, padding=2):
41
 
42
  def detect_text_boxes(image):
43
  results = ocr.ocr(image, cls=True)
44
- if not results or not results[0]:
45
- return []
46
  boxes = []
47
- for line in results[0]:
48
- box, (text, confidence) = line
49
- if text.strip():
50
- x_min = int(min(pt[0] for pt in box))
51
- x_max = int(max(pt[0] for pt in box))
52
- y_min = int(min(pt[1] for pt in box))
53
- y_max = int(max(pt[1] for pt in box))
54
- boxes.append(((x_min, y_min, x_max, y_max), text, confidence))
 
 
 
55
  return boxes
56
 
57
  def remove_text_dynamic_fill(img_path, output_path):
 
41
 
42
  def detect_text_boxes(image):
43
  results = ocr.ocr(image, cls=True)
 
 
44
  boxes = []
45
+ if results and results[0]:
46
+ for line in results[0]:
47
+ box, (text, confidence) = line
48
+ if text.strip():
49
+ x_min = int(min(pt[0] for pt in box))
50
+ x_max = int(max(pt[0] for pt in box))
51
+ y_min = int(min(pt[1] for pt in box))
52
+ y_max = int(max(pt[1] for pt in box))
53
+ boxes.append(((x_min, y_min, x_max, y_max), text, confidence))
54
+ else:
55
+ print("No text detected in the image.")
56
  return boxes
57
 
58
  def remove_text_dynamic_fill(img_path, output_path):