Noursine commited on
Commit
19e1e85
·
verified ·
1 Parent(s): f240db0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -1,22 +1,19 @@
1
  import gradio as gr
2
  from PIL import Image
3
  from ultralytics import YOLO
4
- import numpy as np
5
 
6
- # Load your model
7
  model = YOLO("best (2).pt")
8
 
9
- # Prediction function
10
  def detect_teeth(image):
11
- results = model.predict(image, conf=0.26)
12
 
13
- # Optional post-processing
14
  r = results[0]
15
  if r.masks is not None:
16
  r.masks.data = (r.masks.data > 0.3).float()
17
 
18
- # Create segmented image with bounding boxes and masks
19
- output_img = r.plot()
20
  return Image.fromarray(output_img)
21
 
22
  # Gradio interface
@@ -24,8 +21,8 @@ interface = gr.Interface(
24
  fn=detect_teeth,
25
  inputs=gr.Image(type="pil", label="Upload Dental X-ray"),
26
  outputs=gr.Image(type="pil", label="Detection Result"),
27
- title="Dental X-ray Detection",
28
- description="Upload a dental X-ray to see segmentation and detection results using YOLOv8."
29
  )
30
 
31
  interface.launch()
 
1
  import gradio as gr
2
  from PIL import Image
3
  from ultralytics import YOLO
 
4
 
5
+ # Load the model with original name
6
  model = YOLO("best (2).pt")
7
 
 
8
  def detect_teeth(image):
9
+ results = model.predict(image)
10
 
 
11
  r = results[0]
12
  if r.masks is not None:
13
  r.masks.data = (r.masks.data > 0.3).float()
14
 
15
+ # Render without confidence scores or labels
16
+ output_img = r.plot(conf=False, labels=False, boxes=True)
17
  return Image.fromarray(output_img)
18
 
19
  # Gradio interface
 
21
  fn=detect_teeth,
22
  inputs=gr.Image(type="pil", label="Upload Dental X-ray"),
23
  outputs=gr.Image(type="pil", label="Detection Result"),
24
+ title="Dental Segmentation App",
25
+ description="Upload a dental X-ray to see the segmentation result using YOLOv8."
26
  )
27
 
28
  interface.launch()