Pulastya0 commited on
Commit
e2f1874
·
verified ·
1 Parent(s): 980d192

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -10
app.py CHANGED
@@ -1,18 +1,31 @@
1
  import gradio as gr
2
  import cv2
3
  import numpy as np
 
 
4
 
 
 
 
 
5
  def predict(image):
6
- result =model.predict(source =image,imgsz = 640, conf = 0.25)
7
- annotated_image =result[0].plot()
8
- annotated_image[:, :, ::-1]
9
- return annotated_image
 
 
10
 
 
 
 
11
  app = gr.Interface(
12
- fn = predict,
13
- inputs = gr.Image(type = "numpy", label ="Upload an Image"),
14
- outputs = gr.Image(type = "numpy", label ="Detect a Tooth Cavity"),
15
- title = "Tooth Cavity Detection Using YOLO V10 made by Pulastya 😎",
16
- description = "Upload an Image ant eh YOLO V10 model will detect and Annotate the Tooth Decay"
17
  )
18
- app.launch()
 
 
 
1
  import gradio as gr
2
  import cv2
3
  import numpy as np
4
+ from ultralytics import YOLO
5
+ from PIL import Image
6
 
7
+ # Load YOLO model
8
+ model = YOLO("best.pt") # Ensure 'best.pt' is in the same directory
9
+
10
+ # Define prediction function
11
  def predict(image):
12
+ # Perform YOLO detection
13
+ result = model.predict(source=image, imgsz=640, conf=0.25)
14
+ annotated_image = result[0].plot()
15
+
16
+ # Convert image from BGR to RGB
17
+ annotated_image = cv2.cvtColor(annotated_image, cv2.COLOR_BGR2RGB)
18
 
19
+ return annotated_image
20
+
21
+ # Gradio interface
22
  app = gr.Interface(
23
+ fn=predict,
24
+ inputs=gr.Image(type="numpy", label="Upload an Image"),
25
+ outputs=gr.Image(type="numpy", label="Detected Tooth Cavity"),
26
+ title="Tooth Cavity Detection Using YOLO V10 by Pulastya 😎",
27
+ description="Upload a dental X-ray, and the YOLO V10 model will detect and annotate tooth decay."
28
  )
29
+
30
+ if __name__ == "__main__":
31
+ app.launch()