Tejeshwar commited on
Commit
23a1c71
·
verified ·
1 Parent(s): 152b9b1

Update yolov12/detector.py

Browse files
Files changed (1) hide show
  1. yolov12/detector.py +15 -8
yolov12/detector.py CHANGED
@@ -1,5 +1,6 @@
1
  import subprocess
2
  import os
 
3
 
4
  def run_yolov12_inference(img_path):
5
  project_dir = "static/uploaded"
@@ -16,14 +17,20 @@ def run_yolov12_inference(img_path):
16
  "--name", "yolov12_output",
17
  "--exist-ok"
18
  ]
19
-
20
- subprocess.run(command, check=True)
21
-
22
- # Try reading the prediction txt file
23
- file_name = os.path.basename(img_path)
24
- label_file = os.path.join(result_dir, "labels", file_name.replace(".jpg", ".txt"))
25
-
26
- is_damaged = False
 
 
 
 
 
 
27
  try:
28
  with open(label_file, "r") as f:
29
  for line in f:
 
1
  import subprocess
2
  import os
3
+ from pathlib import Path
4
 
5
  def run_yolov12_inference(img_path):
6
  project_dir = "static/uploaded"
 
17
  "--name", "yolov12_output",
18
  "--exist-ok"
19
  ]
20
+ # TEMPORARY: simulate label output
21
+ filename = Path(args.source).name
22
+ label_path = Path(args.project) / args.name / "labels"
23
+ label_path.mkdir(parents=True, exist_ok=True)
24
+
25
+ with open(label_path / filename.replace(".jpg", ".txt"), "w") as f:
26
+ f.write("0 0.5 0.5 1 1 0.90\n") # fake class 0
27
+ subprocess.run(command, check=True)
28
+
29
+ # Try reading the prediction txt file
30
+ file_name = os.path.basename(img_path)
31
+ label_file = os.path.join(result_dir, "labels", file_name.replace(".jpg", ".txt"))
32
+
33
+ is_damaged = False
34
  try:
35
  with open(label_file, "r") as f:
36
  for line in f: