iammraat commited on
Commit
fcf7044
·
verified ·
1 Parent(s): 81dee09

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -590,7 +590,6 @@
590
 
591
 
592
 
593
-
594
  import gradio as gr
595
  import torch
596
  import numpy as np
@@ -627,7 +626,7 @@ def calculate_iou(box1, box2):
627
 
628
  def remove_nested_boxes(boxes, iou_thresh=0.7):
629
  """Remove boxes that are nested inside others"""
630
- if not boxes:
631
  return []
632
 
633
  # Add area to each box
@@ -657,7 +656,7 @@ def remove_nested_boxes(boxes, iou_thresh=0.7):
657
 
658
  def merge_boxes_into_lines(raw_boxes, y_overlap_thresh=0.5, x_gap_thresh=100):
659
  """Merge boxes into lines with better horizontal merging"""
660
- if not raw_boxes or len(raw_boxes) == 0:
661
  return []
662
 
663
  # Convert polygons to rectangles
@@ -671,7 +670,7 @@ def merge_boxes_into_lines(raw_boxes, y_overlap_thresh=0.5, x_gap_thresh=100):
671
  # Remove nested boxes
672
  rects = remove_nested_boxes(rects)
673
 
674
- if not rects:
675
  return []
676
 
677
  # Sort by Y position
 
590
 
591
 
592
 
 
593
  import gradio as gr
594
  import torch
595
  import numpy as np
 
626
 
627
  def remove_nested_boxes(boxes, iou_thresh=0.7):
628
  """Remove boxes that are nested inside others"""
629
+ if len(boxes) == 0:
630
  return []
631
 
632
  # Add area to each box
 
656
 
657
  def merge_boxes_into_lines(raw_boxes, y_overlap_thresh=0.5, x_gap_thresh=100):
658
  """Merge boxes into lines with better horizontal merging"""
659
+ if raw_boxes is None or len(raw_boxes) == 0:
660
  return []
661
 
662
  # Convert polygons to rectangles
 
670
  # Remove nested boxes
671
  rects = remove_nested_boxes(rects)
672
 
673
+ if len(rects) == 0:
674
  return []
675
 
676
  # Sort by Y position