danielritchie commited on
Commit
180137f
·
verified ·
1 Parent(s): 3a603bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -32,22 +32,22 @@ def compare_models(input_image):
32
  # Convert from Gradio's PIL image to OpenCV format
33
  image = np.array(input_image)
34
 
35
- # Process with both models
36
- duck_image = process_image(image, duck_model)
37
  standard_image = process_image(image, standard_model)
 
38
 
39
  # Create side-by-side comparison
40
  height, width = image.shape[:2]
41
  canvas = np.zeros((height, width * 2, 3), dtype=np.uint8)
42
 
43
- # Place images side by side
44
- canvas[:, :width] = duck_image
45
- canvas[:, width:] = standard_image
46
 
47
  # Add model labels
48
- cv2.putText(canvas, "Duck Detector", (10, 30),
49
  cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
50
- cv2.putText(canvas, "Standard YOLOv8", (width + 10, 30),
51
  cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
52
 
53
  return canvas
@@ -55,12 +55,13 @@ def compare_models(input_image):
55
  # Create Gradio interface
56
  iface = gr.Interface(
57
  fn=compare_models,
58
- inputs=gr.Image(type="pil"),
59
- outputs=gr.Image(type="numpy"),
60
  title="YOLO Model Comparison",
61
- description="Compare Duck Detector with standard YOLOv8 model",
62
  examples=[["test_image.jpg"]],
63
- cache_examples=True
 
64
  )
65
 
66
  # Launch the interface
 
32
  # Convert from Gradio's PIL image to OpenCV format
33
  image = np.array(input_image)
34
 
35
+ # Process with both models (standard first, then duck)
 
36
  standard_image = process_image(image, standard_model)
37
+ duck_image = process_image(image, duck_model)
38
 
39
  # Create side-by-side comparison
40
  height, width = image.shape[:2]
41
  canvas = np.zeros((height, width * 2, 3), dtype=np.uint8)
42
 
43
+ # Place images side by side (standard left, duck right)
44
+ canvas[:, :width] = standard_image
45
+ canvas[:, width:] = duck_image
46
 
47
  # Add model labels
48
+ cv2.putText(canvas, "Standard YOLOv8", (10, 30),
49
  cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
50
+ cv2.putText(canvas, "Duck Detector", (width + 10, 30),
51
  cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
52
 
53
  return canvas
 
55
  # Create Gradio interface
56
  iface = gr.Interface(
57
  fn=compare_models,
58
+ inputs=gr.Image(type="pil", height=200), # Smaller input image
59
+ outputs=gr.Image(type="numpy", height=400), # Larger output for side-by-side comparison
60
  title="YOLO Model Comparison",
61
+ description="Compare standard YOLOv8 model (left) with Duck Detector (right)",
62
  examples=[["test_image.jpg"]],
63
+ cache_examples=True,
64
+ css="img.output {width: 100% !important; height: auto !important;}" # Force output to span full width
65
  )
66
 
67
  # Launch the interface