to-be commited on
Commit
6530ca6
1 Parent(s): 8a30892
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -5,9 +5,6 @@ import time
5
  import math
6
  import gradio as gr
7
 
8
-
9
- processing_time = ''
10
-
11
  def find_signature_bounding_boxes(image):
12
  # Start measuring time
13
  start_time = time.time()
@@ -69,9 +66,9 @@ def find_signature_bounding_boxes(image):
69
  # End measuring time
70
  end_time = time.time()
71
  print(f"Function took {end_time - start_time:.2f} seconds to process the image.")
72
- processing_time = f"Detection took {end_time - start_time:.2f} seconds. "
73
 
74
- return possible_signatures
75
 
76
  def merge_nearby_rectangles(rectangles, nearness):
77
  def is_near(rect1, rect2):
@@ -121,14 +118,14 @@ def run_detection(input_image):
121
  image = np.asarray(input_image.convert("RGB"))
122
 
123
  # Find bounding boxes of possible signatures on the document
124
- signatures = find_signature_bounding_boxes(image)
125
  print('Nr of signatures found: ' + str(len(signatures)))
126
  # Draw bounding boxes on the image
127
  for (x, y, w, h) in signatures:
128
  cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)
129
  image_with_box = Image.fromarray(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
130
 
131
- info = processing_time + 'Nr of signatures found: ' + str(len(signatures))
132
  return image_with_box, info
133
 
134
  if __name__ == "__main__":
 
5
  import math
6
  import gradio as gr
7
 
 
 
 
8
  def find_signature_bounding_boxes(image):
9
  # Start measuring time
10
  start_time = time.time()
 
66
  # End measuring time
67
  end_time = time.time()
68
  print(f"Function took {end_time - start_time:.2f} seconds to process the image.")
69
+ info = f"Detection took {end_time - start_time:.2f} seconds. "
70
 
71
+ return possible_signatures, info
72
 
73
  def merge_nearby_rectangles(rectangles, nearness):
74
  def is_near(rect1, rect2):
 
118
  image = np.asarray(input_image.convert("RGB"))
119
 
120
  # Find bounding boxes of possible signatures on the document
121
+ signatures, info = find_signature_bounding_boxes(image)
122
  print('Nr of signatures found: ' + str(len(signatures)))
123
  # Draw bounding boxes on the image
124
  for (x, y, w, h) in signatures:
125
  cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)
126
  image_with_box = Image.fromarray(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
127
 
128
+ info = info + 'Nr of signatures found: ' + str(len(signatures))
129
  return image_with_box, info
130
 
131
  if __name__ == "__main__":