Ekins Kuuzie commited on
Commit
59fb740
·
verified ·
1 Parent(s): 08a5bdc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -16,27 +16,27 @@ model = YOLO('best.pt')
16
 
17
  def predict_image(test_image):
18
  # save images
19
- return model.predict(test_image, save=True, conf=0.1, batch=2, show=True)
20
 
21
  path = "runs/detect"
22
 
23
- # detection = (os.listdir(path))
24
 
25
- # def extract_digits(x):
26
- # digits = ''.join(filter(str.isdigit, x))
27
- # return int(digits) if digits else float('inf') #Use float('inf') as a default value
28
 
29
- # sorted_ = sorted(detection, key=extract_digits)
30
 
31
- # if len(sorted_)>1:
32
- # latest_detection = sorted_[-2] #
33
- # else:
34
- # latest_detection = sorted_[0]
35
 
36
- # detection_path = os.path.join(path, latest_detection)
37
 
38
- # pred = cv2.imread(os.path.join(detection_path, test_image))
39
- # return pred
40
 
41
 
42
 
 
16
 
17
  def predict_image(test_image):
18
  # save images
19
+ model.predict(test_image, save=True, conf=0.1, batch=2, show=True)
20
 
21
  path = "runs/detect"
22
 
23
+ detection = (os.listdir(path))
24
 
25
+ def extract_digits(x):
26
+ digits = ''.join(filter(str.isdigit, x))
27
+ return int(digits) if digits else float('inf') #Use float('inf') as a default value
28
 
29
+ sorted_ = sorted(detection, key=extract_digits)
30
 
31
+ if len(sorted_)>1:
32
+ latest_detection = sorted_[-2] # getting the latest predictions
33
+ else:
34
+ latest_detection = sorted_[0]
35
 
36
+ detection_path = os.path.join(path, latest_detection)
37
 
38
+ pred = cv2.imread(os.path.join(detection_path, test_image))
39
+ return pred
40
 
41
 
42