File size: 906 Bytes
1f724ba
 
 
e2f1874
 
1f724ba
e2f1874
 
 
 
1f724ba
e2f1874
 
 
 
 
 
1f724ba
e2f1874
 
 
1f724ba
e2f1874
 
 
 
3bbc1f6
1f724ba
e2f1874
 
 
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
import gradio as gr
import cv2
import numpy as np
from ultralytics import YOLO
from PIL import Image

# Load YOLO model
model = YOLO("best.pt")  # Ensure 'best.pt' is in the same directory

# Define prediction function
def predict(image):
    # Perform YOLO detection
    result = model.predict(source=image, imgsz=640, conf=0.25)
    annotated_image = result[0].plot()

    # Convert image from BGR to RGB
    annotated_image = cv2.cvtColor(annotated_image, cv2.COLOR_BGR2RGB)

    return annotated_image

# Gradio interface
app = gr.Interface(
    fn=predict,
    inputs=gr.Image(type="numpy", label="Upload an Image"),
    outputs=gr.Image(type="numpy", label="Detected Tooth Cavity"),
    title="Tooth Cavity Detection Using YOLO V10 by Pulastya 😎",
    description="Upload a dental Photo, and the YOLO V10 model will detect and annotate tooth decay."
)

if __name__ == "__main__":
    app.launch()