mlbench123 commited on
Commit
8501481
Β·
verified Β·
1 Parent(s): 9db320c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -10,6 +10,9 @@ model = YOLO("best.pt")
10
  CLASS_NAMES = {0: "Full", 1: "Broken"}
11
  CLASS_COLORS = {0: (34, 197, 94), 1: (239, 68, 68)} # green, red
12
 
 
 
 
13
 
14
  # ── Inference ─────────────────────────────────────────────────────────────────
15
  def predict(image: Image.Image):
@@ -285,7 +288,7 @@ with gr.Blocks(css=css, title="GrainVision β€” Rice Grain Classifier") as demo:
285
  </div>
286
  """)
287
 
288
- with gr.Row(equal_height=False):
289
 
290
  # ── Left: Input ───────────────────────────────────────────────────────
291
  with gr.Column(scale=1):
@@ -294,10 +297,17 @@ with gr.Blocks(css=css, title="GrainVision β€” Rice Grain Classifier") as demo:
294
  type="pil",
295
  label="",
296
  elem_classes=["image-wrap"],
297
- height=420,
298
  )
299
- gr.HTML('<div style="height:12px"></div>')
300
  run_btn = gr.Button("Analyse Grains", elem_id="run-btn")
 
 
 
 
 
 
 
301
 
302
  # ── Right: Output ─────────────────────────────────────────────────────
303
  with gr.Column(scale=1):
@@ -306,7 +316,7 @@ with gr.Blocks(css=css, title="GrainVision β€” Rice Grain Classifier") as demo:
306
  type="pil",
307
  label="",
308
  elem_classes=["image-wrap"],
309
- height=420,
310
  )
311
 
312
  gr.HTML('<div style="height:20px"></div>')
 
10
  CLASS_NAMES = {0: "Full", 1: "Broken"}
11
  CLASS_COLORS = {0: (34, 197, 94), 1: (239, 68, 68)} # green, red
12
 
13
+ # ── Sample images ─────────────────────────────────────────────────────────────
14
+ SAMPLE_PATHS = ["image1.jpg", "image2.jpg"]
15
+
16
 
17
  # ── Inference ─────────────────────────────────────────────────────────────────
18
  def predict(image: Image.Image):
 
288
  </div>
289
  """)
290
 
291
+ with gr.Row(equal_height=True):
292
 
293
  # ── Left: Input ───────────────────────────────────────────────────────
294
  with gr.Column(scale=1):
 
297
  type="pil",
298
  label="",
299
  elem_classes=["image-wrap"],
300
+ height=400,
301
  )
302
+ gr.HTML('<div style="height:10px"></div>')
303
  run_btn = gr.Button("Analyse Grains", elem_id="run-btn")
304
+ gr.HTML('<div class="section-label" style="margin-top:16px;">Try an Example</div>')
305
+ gr.Examples(
306
+ examples=[[p] for p in SAMPLE_PATHS],
307
+ inputs=input_img,
308
+ label="",
309
+ examples_per_page=2,
310
+ )
311
 
312
  # ── Right: Output ─────────────────────────────────────────────────────
313
  with gr.Column(scale=1):
 
316
  type="pil",
317
  label="",
318
  elem_classes=["image-wrap"],
319
+ height=400,
320
  )
321
 
322
  gr.HTML('<div style="height:20px"></div>')