File size: 922 Bytes
bed40a0
 
 
e837f49
bed40a0
 
 
 
84ca6fc
bed40a0
97a1cfe
499b1f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc5c911
499b1f0
bed40a0
 
e837f49
bed40a0
84ca6fc
499b1f0
 
ad895f5
 
bed40a0
e837f49
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
38
39
40
41
import gradio as gr
import PIL.Image as Image

from ultralytics import YOLO

model = None


def predict_image(img):
    """Predicts objects in an image using a YOLOv8 model with adjustable confidence and IOU thresholds."""
    model = YOLO("best.pt")
    # model.predict(source=img, save=True)
    results = model.predict(
        source=img,
        conf=0.25,
        iou=0.25,
        show_labels=True,
        show_conf=True,
        imgsz=640,
    )
    # results = model(img)

    for r in results:
        im_array = r.plot()
        im = Image.fromarray(im_array[..., ::-1])

    return im
    
    # return results[0].show()


demo = gr.Interface(
    fn=predict_image,
    inputs=gr.Image(type="pil", label="Upload Image"),
    outputs=gr.Image(type="pil", label="Result"),
    # outputs="image",
    title="Burks YOLO Coin Detector 🚀",
    description="Upload your image, stupid.",
)
demo.launch(share=True)