Explicit `model.eval()` call `if opt.train=False` (#3475)
* call model.eval() when opt.train is False call model.eval() when opt.train is False * single-line if statement * cleanup Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
cf4f95bc5f
commit
a1c3572bc9
|
|
@ -58,8 +58,7 @@ if __name__ == '__main__':
|
||||||
# Update model
|
# Update model
|
||||||
if opt.half:
|
if opt.half:
|
||||||
img, model = img.half(), model.half() # to FP16
|
img, model = img.half(), model.half() # to FP16
|
||||||
if opt.train:
|
model.train() if opt.train else model.eval() # training mode = no Detect() layer grid construction
|
||||||
model.train() # training mode (no grid construction in Detect layer)
|
|
||||||
for k, m in model.named_modules():
|
for k, m in model.named_modules():
|
||||||
m._non_persistent_buffers_set = set() # pytorch 1.6.0 compatibility
|
m._non_persistent_buffers_set = set() # pytorch 1.6.0 compatibility
|
||||||
if isinstance(m, models.common.Conv): # assign export-friendly activations
|
if isinstance(m, models.common.Conv): # assign export-friendly activations
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue