--img-size stride-multiple verification

This commit is contained in:
Glenn Jocher committed 2020-06-12 22:10:46 -07:00
1 parent 4ba47b1b1b
commit 099e6f5ebd
4 files changed
+11 -4

No files matched your search

+8 -1
View File
@@ -37,13 +37,20 @@ def init_seeds(seed=0):
def check_git_status():
# Suggest 'git pull' if repo is out of date
if platform in ['linux', 'darwin']:
# Suggest 'git pull' if repo is out of date
s = subprocess.check_output('if [ -d .git ]; then git fetch && git status -uno; fi', shell=True).decode('utf-8')
if 'Your branch is behind' in s:
print(s[s.find('Your branch is behind'):s.find('\n\n')] + '\n')
def check_img_size(img_size, s=32):
# Verify img_size is a multiple of stride s
if img_size % s != 0:
print('WARNING: --img-size %g must be multiple of max stride %g' % (img_size, s))
return make_divisible(img_size, s) # nearest gs-multiple
def make_divisible(x, divisor):
# Returns x evenly divisble by divisor
return math.ceil(x / divisor) * divisor