Vahe commited on
Commit
906934d
1 Parent(s): cbd684f

app final worked

Browse files
__pycache__/xyxy_converter.cpython-310.pyc ADDED
Binary file (1.32 kB). View file
 
app.py CHANGED
@@ -48,19 +48,19 @@ def main():
48
 
49
  os.chdir(YOLO_PATH)
50
 
51
- try:
52
- shutil.rmtree('runs/detect/temp_exp')
53
- except:
54
- pass
55
 
56
- image_path = 'odometer_image.jpg'
57
  # command = f"python detect.py --weights {MODEL_PATH} --source {image_path} --img 640 --conf 0.4 --name 'temp_exp' --hide-labels --hide-conf --save-txt --exist-ok"
58
  command = f'''
59
  python detect.py \
60
  --weights {MODEL_PATH} \
61
  --source {image_path} \
62
  --img 640 \
63
- --conf 0.4 \
64
  --name temp_exp \
65
  --hide-labels \
66
  --hide-conf \
@@ -106,7 +106,8 @@ def main():
106
  except:
107
  pass
108
  else:
109
- processed_image = image_np
 
110
 
111
  # Resize or preprocess the image as needed for your model
112
  # For example, resizing to a specific input size
 
48
 
49
  os.chdir(YOLO_PATH)
50
 
51
+ # try:
52
+ # shutil.rmtree('runs/detect/temp_exp')
53
+ # except:
54
+ # pass
55
 
56
+ image_path = "../odometer_image.jpg"
57
  # command = f"python detect.py --weights {MODEL_PATH} --source {image_path} --img 640 --conf 0.4 --name 'temp_exp' --hide-labels --hide-conf --save-txt --exist-ok"
58
  command = f'''
59
  python detect.py \
60
  --weights {MODEL_PATH} \
61
  --source {image_path} \
62
  --img 640 \
63
+ --conf 0.5 \
64
  --name temp_exp \
65
  --hide-labels \
66
  --hide-conf \
 
106
  except:
107
  pass
108
  else:
109
+ display_text = "An odometer is not detected in the image!!!"
110
+ processed_image = cv2.imread('odometer_image.jpg')
111
 
112
  # Resize or preprocess the image as needed for your model
113
  # For example, resizing to a specific input size
odometer_image.jpg ADDED
xyxy_converter.py CHANGED
@@ -13,8 +13,10 @@ def yolov5_to_image_coordinates(text_file, image_width=640, image_height=640):
13
 
14
  with open(text_file, 'r') as f:
15
  xywh_text = f.read()
16
-
17
- yolo_box = [float(i) for i in xywh_text.replace('\n', '').split(' ')[1:]]
 
 
18
 
19
  x_center, y_center, width, height = yolo_box
20
 
 
13
 
14
  with open(text_file, 'r') as f:
15
  xywh_text = f.read()
16
+
17
+ xywh_splitted = xywh_text.split('\n')[0]
18
+ yolo_box = [float(i) for i in xywh_splitted.split(' ')[1:]]
19
+ # yolo_box = [float(i) for i in xywh_text.replace('\n', '').split(' ')[1:]]
20
 
21
  x_center, y_center, width, height = yolo_box
22
 
yolov5/__pycache__/export.cpython-310.pyc ADDED
Binary file (31.6 kB). View file
 
yolov5/runs/detect/temp_exp/labels/odometer_image.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ 0 0.635938 0.4625 0.30625 0.325
2
+ 0 0.452344 0.715625 0.429688 0.18125
3
+ 0 0.452344 0.715625 0.429688 0.18125
4
+ 0 0.409375 0.657031 0.375 0.148438
5
+ 0 0.409375 0.657031 0.375 0.148438
6
+ 0 0.409375 0.657031 0.375 0.148438
7
+ 0 0.564844 0.671094 0.207813 0.0859375
8
+ 0 0.442187 0.621094 0.38125 0.139062
9
+ 0 0.510156 0.665625 0.254687 0.11875
10
+ 0 0.539062 0.586719 0.375 0.201562
yolov5/runs/detect/temp_exp/odometer_image.jpg ADDED