info
Browse files
app.py
CHANGED
@@ -6,6 +6,8 @@ import math
|
|
6 |
import gradio as gr
|
7 |
|
8 |
|
|
|
|
|
9 |
def find_signature_bounding_boxes(image):
|
10 |
# Start measuring time
|
11 |
start_time = time.time()
|
@@ -67,6 +69,7 @@ def find_signature_bounding_boxes(image):
|
|
67 |
# End measuring time
|
68 |
end_time = time.time()
|
69 |
print(f"Function took {end_time - start_time:.2f} seconds to process the image.")
|
|
|
70 |
|
71 |
return possible_signatures
|
72 |
|
@@ -125,8 +128,8 @@ def run_detection(input_image):
|
|
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 |
-
|
129 |
-
return image_with_box
|
130 |
|
131 |
if __name__ == "__main__":
|
132 |
|
@@ -155,11 +158,11 @@ if __name__ == "__main__":
|
|
155 |
gallery = gr.outputs.Image(type="pil").style(full_width=True, full_height=True)
|
156 |
|
157 |
run_button.click(fn=run_detection, inputs=[
|
158 |
-
input_image], outputs=[gallery])
|
159 |
gr.Examples(
|
160 |
[["Sample1.jpg"],["Sample2.jpg"]],
|
161 |
inputs = [input_image],
|
162 |
-
outputs = [gallery],
|
163 |
fn=run_detection,
|
164 |
cache_examples=True,
|
165 |
label='Try these examples:'
|
|
|
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 |
# 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 |
|
|
|
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__":
|
135 |
|
|
|
158 |
gallery = gr.outputs.Image(type="pil").style(full_width=True, full_height=True)
|
159 |
|
160 |
run_button.click(fn=run_detection, inputs=[
|
161 |
+
input_image], outputs=[gallery, info])
|
162 |
gr.Examples(
|
163 |
[["Sample1.jpg"],["Sample2.jpg"]],
|
164 |
inputs = [input_image],
|
165 |
+
outputs = [gallery, info],
|
166 |
fn=run_detection,
|
167 |
cache_examples=True,
|
168 |
label='Try these examples:'
|