File size: 685 Bytes
06b9c08
 
 
 
 
 
 
 
 
 
5402ab1
06b9c08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import glob
import gradio as gr
from ultralytics import YOLO

model_path = "trash_mbari_09072023_640imgsz_50epochs_yolov8.pt"
model = YOLO(model_path)


PREDICT_KWARGS = {
    "classes": 0,
    "conf": 0.4,
}


def run(image_path):
    results = model.predict(image_path, **PREDICT_KWARGS)
    return results[0].plot()[:, :, ::-1]  # reverse channels for gradio


title = "Trash Detector"
description = (
    ""
)

examples = glob.glob("images/*.png")

interface = gr.Interface(
    run,
    inputs=[gr.components.Image(type="filepath")],
    outputs=gr.components.Image(type="numpy"),
    title=title,
    description=description,
    examples=examples,
)

interface.queue().launch()