johnlockejrr commited on
Commit
5de898a
·
verified ·
1 Parent(s): 3424f21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
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: sv.Color = sv.Color.red(), thickness: int = 2):
31
  self.color = color
32
  self.thickness = thickness
33
 
@@ -46,7 +46,7 @@ class OutlineMaskAnnotator:
46
  scene,
47
  contours,
48
  -1,
49
- self.color.as_bgr(),
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=sv.Color.red(),
63
  thickness=2
64
  )
65
 
@@ -120,7 +120,7 @@ def detect_and_annotate(
120
 
121
  return annotated_image
122
 
123
- # Create Gradio interface (unchanged)
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],