zh320 / realtime-semantic-segmentation-pytorch

PyTorch implementation of over 30 realtime semantic segmentations models, e.g. BiSeNetv1, BiSeNetv2, CGNet, ContextNet, DABNet, DDRNet, EDANet, ENet, ERFNet, ESPNet, ESPNetv2, FastSCNN, ICNet, LEDNet, LinkNet, PP-LiteSeg, SegNet, ShelfNet, STDC, SwiftNet, and support knowledge distillation, distributed training etc.
Apache License 2.0
107 stars 19 forks source link

Call eval on model before inference #4

Closed TimSC closed 6 months ago

TimSC commented 6 months ago

When running in is_testing = True mode, the model needs eval() to be called before performing inference. Not doing this causes a loss in performance. There might be a better way to do this but this is the best I could find.

zh320 commented 6 months ago

It seems this will cause some confusion if one tries to load some checkpoint but does not want to resume training state. Might be better to call eval mode within the beginning of the predict function.

TimSC commented 6 months ago

Surely you would want to either resume training or do a prediction? Anyway, I moved the eval() mode change to the predict function as you suggested. It probably is better there anyway!