Niv Sardi commited on
Commit
226d6f5
1 Parent(s): a966873

correctly set yolov5 layout

Browse files

Signed-off-by: Niv Sardi <xaiki@debian-BULLSEYE-live-builder-AMD64>

Files changed (1) hide show
  1. crawler/imtool.py +8 -5
crawler/imtool.py CHANGED
@@ -61,8 +61,10 @@ def cut_logo(im, l):
61
 
62
  def crop(fn, logos):
63
  basename = os.path.basename(fn).replace('.png', '')
64
- out = f"./data/squares"
65
- pathlib.Path(out).mkdir(parents=True, exist_ok=True)
 
 
66
 
67
  im = cv2.imread(fn)
68
 
@@ -117,10 +119,11 @@ def crop(fn, logos):
117
 
118
  c = (255, 0, 0)
119
  nim = im[fy:fy+TILE_SIZE, fx:fx+TILE_SIZE]
120
- name =f"{out}/{basename}.{x}.{y}"
121
- cv2.imwrite(f"{name}.png", nim)
 
122
  if len(li):
123
- with open(f"{name}.txt", 'w') as f:
124
  for p in li:
125
  cx = cw/2 + p.x
126
  cy = ch/2 + p.y
 
61
 
62
  def crop(fn, logos):
63
  basename = os.path.basename(fn).replace('.png', '')
64
+ img_out = f"./data/squares/labels"
65
+ txt_out = f"./data/squares/labels"
66
+ pathlib.Path(img_out).mkdir(parents=True, exist_ok=True)
67
+ pathlib.Path(txt_out).mkdir(parents=True, exist_ok=True)
68
 
69
  im = cv2.imread(fn)
70
 
 
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:
127
  for p in li:
128
  cx = cw/2 + p.x
129
  cy = ch/2 + p.y