Spaces:
Runtime error
Runtime error
Ekins Kuuzie
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -16,27 +16,27 @@ model = YOLO('best.pt')
|
|
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 |
|
23 |
-
detection = (os.listdir(path))
|
24 |
|
25 |
-
def extract_digits(x):
|
26 |
-
|
27 |
-
|
28 |
|
29 |
-
sorted_ = sorted(detection, key=extract_digits)
|
30 |
|
31 |
-
if len(sorted_)>1:
|
32 |
-
|
33 |
-
else:
|
34 |
-
|
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 |
+
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 |
|