Niv Sardi commited on
Commit
4b0ef46
1 Parent(s): 95698cf

imtool: change image format to try to debug why yolo doesn't like it

Browse files
Files changed (1) hide show
  1. crawler/imtool.py +12 -5
crawler/imtool.py CHANGED
@@ -119,8 +119,9 @@ def crop(fn, logos):
119
 
120
  c = (255, 0, 0)
121
  nim = im[fy:fy+TILE_SIZE, fx:fx+TILE_SIZE]
122
- img_name =f"{img_out}/{basename}.{x}.{y}.png"
123
- txt_name =f"{txt_out}/{basename}.{x}.{y}.txt"
 
124
  cv2.imwrite(img_name, nim)
125
  if len(li):
126
  with open(txt_name, 'w') as f:
@@ -133,7 +134,13 @@ def crop(fn, logos):
133
  print(a)
134
 
135
  if __name__ == '__main__':
136
- boxes = read_bounding_boxes("./data/debug.full.txt")
137
- print(boxes)
138
- crop("./data/debug.full.png", boxes)
 
 
 
 
 
 
139
 
 
119
 
120
  c = (255, 0, 0)
121
  nim = im[fy:fy+TILE_SIZE, fx:fx+TILE_SIZE]
122
+ img_name =f"{img_out}/{basename}-x{x}y{y}.png"
123
+ txt_name =f"{txt_out}/{basename}-x{x}y{y}.txt"
124
+
125
  cv2.imwrite(img_name, nim)
126
  if len(li):
127
  with open(txt_name, 'w') as f:
 
134
  print(a)
135
 
136
  if __name__ == '__main__':
137
+ with os.scandir('./data/') as it:
138
+ for e in it:
139
+ if e.name.endswith('.txt') and e.is_file():
140
+ print(e.name)
141
+ try:
142
+ boxes = read_bounding_boxes(e.path)
143
+ crop(e.path.replace('.txt', '.png'), boxes)
144
+ except Exception as err:
145
+ print(err)
146