Caries1 commited on
Commit
d065cca
·
verified ·
1 Parent(s): 804e158

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py CHANGED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ # Kütüphane yükleme hatalarını minimize etmek için
3
+ os.environ['SYSTEM'] = 'spaces'
4
+
5
+ import gradio as gr
6
+ from ultralytics import YOLO
7
+ import cv2
8
+ import numpy as np
9
+
10
+ # Yetki hatası önlemi
11
+ os.environ['YOLO_CONFIG_DIR'] = '/tmp/Ultralytics'
12
+
13
+ # Model yükle
14
+ model = YOLO("best.pt")
15
+
16
+ def predict_caries(image, conf_threshold):
17
+ if image is None:
18
+ return None
19
+ results = model.predict(source=image, conf=conf_threshold, iou=0.2, imgsz=640)
20
+ res_plotted = results[0].plot(labels=False, conf=False)
21
+ return cv2.cvtColor(res_plotted, cv2.COLOR_BGR2RGB)
22
+
23
+ with gr.Blocks() as demo:
24
+ gr.Markdown("# 🦷 Dental Caries Detection System For Akansh Mani")
25
+ with gr.Row():
26
+ with gr.Column():
27
+ input_img = gr.Image(type="numpy", label="Upload X-Ray")
28
+ conf_slider = gr.Slider(0.01, 0.95, value=0.25, label="Confidence Threshold")
29
+ btn = gr.Button("🔍 Run AI Analysis", variant="primary")
30
+ with gr.Column():
31
+ output_img = gr.Image(type="numpy", label="Result")
32
+
33
+ btn.click(fn=predict_caries, inputs=[input_img, conf_slider], outputs=output_img)
34
+
35
+ if __name__ == "__main__":
36
+ demo.launch()