Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -57,11 +57,6 @@ class ImageClassifierCataract:
|
|
57 |
label_background = np.ones((50, output_image.shape[1], 3), dtype=np.uint8) * 255
|
58 |
output_image[-50:] = label_background
|
59 |
|
60 |
-
font = cv2.FONT_HERSHEY_SIMPLEX
|
61 |
-
font_scale = 0.4
|
62 |
-
cv2.putText(output_image, f"Analysis Time: {current_time.strftime('%Y-%m-%d %H:%M:%S')}", (10, output_image.shape[0] - 30), font, font_scale, (0, 0, 0), 1)
|
63 |
-
cv2.putText(output_image, f"Predicted Class: {predicted_class}", (10, output_image.shape[0] - 10), font, font_scale, (0, 0, 0), 1)
|
64 |
-
|
65 |
image_height, image_width, _ = output_image.shape
|
66 |
box_size = 100
|
67 |
box_x = (image_width - box_size) // 2
|
@@ -69,17 +64,15 @@ class ImageClassifierCataract:
|
|
69 |
object_box_color = (255, 0, 0)
|
70 |
cv2.rectangle(output_image, (box_x, box_y), (box_x + box_size, box_y + box_size), object_box_color, 2)
|
71 |
|
72 |
-
|
73 |
-
output_image = output_image[box_y:box_y+box_size, box_x:box_x+box_size]
|
74 |
-
|
75 |
-
return output_image
|
76 |
|
77 |
def run_interface(self):
|
78 |
input_interface = gr.Interface(
|
79 |
fn=self.classify_image,
|
80 |
inputs="image",
|
81 |
-
outputs="image",
|
82 |
-
live=True
|
|
|
83 |
)
|
84 |
input_interface.launch()
|
85 |
|
|
|
57 |
label_background = np.ones((50, output_image.shape[1], 3), dtype=np.uint8) * 255
|
58 |
output_image[-50:] = label_background
|
59 |
|
|
|
|
|
|
|
|
|
|
|
60 |
image_height, image_width, _ = output_image.shape
|
61 |
box_size = 100
|
62 |
box_x = (image_width - box_size) // 2
|
|
|
64 |
object_box_color = (255, 0, 0)
|
65 |
cv2.rectangle(output_image, (box_x, box_y), (box_x + box_size, box_y + box_size), object_box_color, 2)
|
66 |
|
67 |
+
return output_image, predicted_class, current_time.strftime('%Y-%m-%d %H:%M:%S')
|
|
|
|
|
|
|
68 |
|
69 |
def run_interface(self):
|
70 |
input_interface = gr.Interface(
|
71 |
fn=self.classify_image,
|
72 |
inputs="image",
|
73 |
+
outputs=["image", "text", "text"],
|
74 |
+
live=True,
|
75 |
+
examples=[["example.jpg"]]
|
76 |
)
|
77 |
input_interface.launch()
|
78 |
|