glenn-jocher
commited on
Commit
•
2c073cd
1
Parent(s):
3bef77f
Add train.py ``--img-size` floor (#4099)
Browse files- train.py +1 -1
- utils/general.py +3 -3
train.py
CHANGED
@@ -207,7 +207,7 @@ def train(hyp, # path/to/hyp.yaml or hyp dictionary
|
|
207 |
# Image sizes
|
208 |
gs = max(int(model.stride.max()), 32) # grid size (max stride)
|
209 |
nl = model.model[-1].nl # number of detection layers (used for scaling hyp['obj'])
|
210 |
-
imgsz = check_img_size(opt.imgsz, gs) # verify imgsz is gs-multiple
|
211 |
|
212 |
# DP mode
|
213 |
if cuda and RANK == -1 and torch.cuda.device_count() > 1:
|
|
|
207 |
# Image sizes
|
208 |
gs = max(int(model.stride.max()), 32) # grid size (max stride)
|
209 |
nl = model.model[-1].nl # number of detection layers (used for scaling hyp['obj'])
|
210 |
+
imgsz = check_img_size(opt.imgsz, gs, floor=gs * 2) # verify imgsz is gs-multiple
|
211 |
|
212 |
# DP mode
|
213 |
if cuda and RANK == -1 and torch.cuda.device_count() > 1:
|
utils/general.py
CHANGED
@@ -181,11 +181,11 @@ def check_requirements(requirements='requirements.txt', exclude=()):
|
|
181 |
print(emojis(s)) # emoji-safe
|
182 |
|
183 |
|
184 |
-
def check_img_size(img_size, s=32):
|
185 |
# Verify img_size is a multiple of stride s
|
186 |
-
new_size = make_divisible(img_size, int(s)) # ceil gs-multiple
|
187 |
if new_size != img_size:
|
188 |
-
print('WARNING: --img-size
|
189 |
return new_size
|
190 |
|
191 |
|
|
|
181 |
print(emojis(s)) # emoji-safe
|
182 |
|
183 |
|
184 |
+
def check_img_size(img_size, s=32, floor=0):
|
185 |
# Verify img_size is a multiple of stride s
|
186 |
+
new_size = max(make_divisible(img_size, int(s)), floor) # ceil gs-multiple
|
187 |
if new_size != img_size:
|
188 |
+
print(f'WARNING: --img-size {img_size} must be multiple of max stride {s}, updating to {new_size}')
|
189 |
return new_size
|
190 |
|
191 |
|