Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from ultralytics import YOLO
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import torch
|
| 5 |
+
|
| 6 |
+
# Load model
|
| 7 |
+
model = YOLO("best.pt")
|
| 8 |
+
|
| 9 |
+
def detect_gingivitis(image):
|
| 10 |
+
results = model(image)
|
| 11 |
+
annotated = results[0].plot() # draw bounding boxes
|
| 12 |
+
return Image.fromarray(annotated)
|
| 13 |
+
|
| 14 |
+
# Create Gradio interface
|
| 15 |
+
interface = gr.Interface(
|
| 16 |
+
fn=detect_gingivitis,
|
| 17 |
+
inputs=gr.Image(type="pil"),
|
| 18 |
+
outputs="image",
|
| 19 |
+
title="Gingivitis Detection"
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
interface.launch()
|