From 919dc6e6db71c3b79e67cf757da3d70fe628fc7c Mon Sep 17 00:00:00 2001 From: Mark Kurtz Date: Wed, 28 Jul 2021 15:29:27 -0400 Subject: [PATCH] Set model to eval on export if training isn't requested --- models/export.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/models/export.py b/models/export.py index dc4a039d68bb..eed1e8e88a45 100644 --- a/models/export.py +++ b/models/export.py @@ -161,6 +161,8 @@ def load_state_dict(model, state_dict, train, exclude_anchors): img, model = img.half(), model.half() # to FP16 if opt.train: model.train() # training mode (no grid construction in Detect layer) + else: + model.eval() 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