Skip to content

Commit

Permalink
Explicit model.eval() call if opt.train=False (#3475)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
developer0hye and glenn-jocher authored Jun 6, 2021
1 parent cf4f95b commit a1c3572
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions models/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a1c3572

Please sign in to comment.