Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ for name, model_file in MODEL_OPTIONS.items():
|
|
27 |
|
28 |
# Custom MaskAnnotator for outline-only masks
|
29 |
class OutlineMaskAnnotator:
|
30 |
-
def __init__(self, color:
|
31 |
self.color = color
|
32 |
self.thickness = thickness
|
33 |
|
@@ -46,7 +46,7 @@ class OutlineMaskAnnotator:
|
|
46 |
scene,
|
47 |
contours,
|
48 |
-1,
|
49 |
-
self.color
|
50 |
self.thickness
|
51 |
)
|
52 |
return scene
|
@@ -59,7 +59,7 @@ LABEL_ANNOTATOR = sv.LabelAnnotator(
|
|
59 |
text_padding=2
|
60 |
)
|
61 |
MASK_ANNOTATOR = OutlineMaskAnnotator(
|
62 |
-
color=
|
63 |
thickness=2
|
64 |
)
|
65 |
|
@@ -120,7 +120,7 @@ def detect_and_annotate(
|
|
120 |
|
121 |
return annotated_image
|
122 |
|
123 |
-
#
|
124 |
with gr.Blocks() as demo:
|
125 |
gr.Markdown("# Medieval Manuscript Detection with YOLO")
|
126 |
|
@@ -177,7 +177,6 @@ with gr.Blocks() as demo:
|
|
177 |
def clear():
|
178 |
return None, None
|
179 |
|
180 |
-
# Connect buttons to functions
|
181 |
detect_btn.click(
|
182 |
process_image,
|
183 |
inputs=[input_image, model_selector, conf_threshold, iou_threshold],
|
|
|
27 |
|
28 |
# Custom MaskAnnotator for outline-only masks
|
29 |
class OutlineMaskAnnotator:
|
30 |
+
def __init__(self, color: tuple = (255, 0, 0), thickness: int = 2): # Changed from sv.Color.red()
|
31 |
self.color = color
|
32 |
self.thickness = thickness
|
33 |
|
|
|
46 |
scene,
|
47 |
contours,
|
48 |
-1,
|
49 |
+
self.color, # Directly use the color tuple
|
50 |
self.thickness
|
51 |
)
|
52 |
return scene
|
|
|
59 |
text_padding=2
|
60 |
)
|
61 |
MASK_ANNOTATOR = OutlineMaskAnnotator(
|
62 |
+
color=(255, 0, 0), # Red color as BGR tuple
|
63 |
thickness=2
|
64 |
)
|
65 |
|
|
|
120 |
|
121 |
return annotated_image
|
122 |
|
123 |
+
# Rest of the Gradio interface remains exactly the same
|
124 |
with gr.Blocks() as demo:
|
125 |
gr.Markdown("# Medieval Manuscript Detection with YOLO")
|
126 |
|
|
|
177 |
def clear():
|
178 |
return None, None
|
179 |
|
|
|
180 |
detect_btn.click(
|
181 |
process_image,
|
182 |
inputs=[input_image, model_selector, conf_threshold, iou_threshold],
|