shkumar156 commited on
Commit
f3729e4
·
verified ·
1 Parent(s): c69a256

Update yolo_detect.py

Browse files
Files changed (1) hide show
  1. yolo_detect.py +20 -18
yolo_detect.py CHANGED
@@ -1,19 +1,21 @@
1
- import sys
2
- from ultralytics import YOLO
3
- from pathlib import Path
4
-
5
- if len(sys.argv) < 3:
6
- print("Usage: python yolo_detect.py <weights_path> <image_path>")
7
- sys.exit(1)
8
-
9
- weights_path = sys.argv[1]
10
- image_path = sys.argv[2]
11
-
12
- model = YOLO(weights_path)
13
- results = model(image_path, save=True, project='runs/detect', exist_ok=True)
14
-
15
- # Print the path to the saved image
16
- for r in results:
17
- for path in Path(r.save_dir).glob("*"):
18
- if path.is_file():
 
 
19
  print(str(path))
 
1
+ import sys
2
+ from ultralytics import YOLO
3
+ from pathlib import Path
4
+
5
+ if len(sys.argv) < 3:
6
+ print("Usage: python yolo_detect.py <weights_path> <image_path>")
7
+ sys.exit(1)
8
+
9
+ weights_path = sys.argv[1]
10
+ image_path = sys.argv[2]
11
+
12
+ print("Using weights file:", weights_path)
13
+
14
+ model = YOLO(weights_path)
15
+ results = model(image_path, save=True, project='runs/detect', exist_ok=True)
16
+
17
+ # Print the path to the saved image
18
+ for r in results:
19
+ for path in Path(r.save_dir).glob("*"):
20
+ if path.is_file():
21
  print(str(path))