Ekins Kuuzie commited on
Commit
96fab68
·
verified ·
1 Parent(s): 02b64a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -3
app.py CHANGED
@@ -16,8 +16,26 @@ model = YOLO('best.pt')
16
 
17
  def predict_image(test_image):
18
  # save images
19
- results = model.predict(test_image, save=True, conf=0.1, batch=2)
20
- return results
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
 
23
 
@@ -25,7 +43,7 @@ def predict_image(test_image):
25
  platform = gr.Interface( fn = predict_image,
26
  title ="PTCADx: Computer-Aided Detection of Pneumothorax in Chest X-ray Images",
27
  inputs = "image",
28
- outputs = "annotedimage",
29
  description="""
30
  Introducing a revolutionary computer-aided detection tool designed to enhance the efficiency of clinicians in detecting pneumothorax in chest X-ray images.
31
  """,
 
16
 
17
  def predict_image(test_image):
18
  # save images
19
+ model.predict(test_image, save=True, conf=0.1, batch=2)
20
+
21
+ path = "runs\\detect"
22
+ detection = (os.listdir(path))
23
+
24
+ def extract_digits(x):
25
+ digits = ''.join(filter(str.isdigit, x))
26
+ return int(digits) if digits else float('inf') #Use float('inf') as a default value
27
+
28
+ sorted_ = sorted(detection, key=extract_digits)
29
+
30
+ if len(sorted_)>1:
31
+ latest_detection = sorted_[-2] #
32
+ else:
33
+ latest_detection = sorted_[0]
34
+
35
+ detection_path = os.path.join(path, latest_detection)
36
+
37
+ pred = cv2.imread(os.path.join(detection_path, test_image))
38
+ return pred
39
 
40
 
41
 
 
43
  platform = gr.Interface( fn = predict_image,
44
  title ="PTCADx: Computer-Aided Detection of Pneumothorax in Chest X-ray Images",
45
  inputs = "image",
46
+ outputs = "image",
47
  description="""
48
  Introducing a revolutionary computer-aided detection tool designed to enhance the efficiency of clinicians in detecting pneumothorax in chest X-ray images.
49
  """,