From a1c3572bc9e0db60f9978dcf047435a703f58a93 Mon Sep 17 00:00:00 2001 From: Yonghye Kwon Date: Mon, 7 Jun 2021 01:39:36 +0900 Subject: [PATCH] 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 --- models/export.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/models/export.py b/models/export.py index 2db6a7699953..6e3e1207f659 100644 --- a/models/export.py +++ b/models/export.py @@ -58,8 +58,7 @@ # Update model if opt.half: img, model = img.half(), model.half() # to FP16 - if opt.train: - model.train() # training mode (no grid construction in Detect layer) + model.train() if opt.train else model.eval() # training mode = no Detect() layer grid construction for k, m in model.named_modules(): m._non_persistent_buffers_set = set() # pytorch 1.6.0 compatibility if isinstance(m, models.common.Conv): # assign export-friendly activations