MCPcopy Create free account
hub / github.com/PeizeSun/SparseR-CNN / inference_context

Function inference_context

detectron2/evaluation/evaluator.py:185–196  ·  view source on GitHub ↗

A context where the model is temporarily changed to eval mode, and restored to previous mode afterwards. Args: model: a torch Module

(model)

Source from the content-addressed store, hash-verified

183
184@contextmanager
185def inference_context(model):
186 """
187 A context where the model is temporarily changed to eval mode,
188 and restored to previous mode afterwards.
189
190 Args:
191 model: a torch Module
192 """
193 training_mode = model.training
194 model.eval()
195 yield
196 model.train(training_mode)

Callers 1

inference_on_datasetFunction · 0.85

Calls 1

trainMethod · 0.45

Tested by

no test coverage detected