Update app.py
Browse files
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=
|
| 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=
|
| 298 |
)
|
| 299 |
-
gr.HTML('<div style="height:
|
| 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=
|
| 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>')
|