You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I realised that in my code, like in the foundation models example notebook, we do not explicitly put the model into the .eval() mode or activate torch.no_grad() or torch.inference_mode() context managers.
The same is true for the older example notebooks on which I based my code:
I got worried that I was using models in train mode and that I would need to recompute all the features I computed over the last couple of weeks, but then I checked the source code and realised that we rely on the _infer_batch() function, which runs model.eval() for all models that use it (line 173):
Description
I realised that in my code, like in the foundation models example notebook, we do not explicitly put the model into the
.eval()
mode or activatetorch.no_grad()
ortorch.inference_mode()
context managers.The same is true for the older example notebooks on which I based my code:
extract_deep_features()
andextract_composition_features()
in https://github.com/TissueImageAnalytics/tiatoolbox/blob/develop/examples/full-pipelines/slide-graph.ipynbextract_deep_features()
andextract_composition_features()
in https://github.com/TissueImageAnalytics/tiatoolbox/blob/develop/examples/inference-pipelines/slide-graph.ipynbI got worried that I was using models in
train
mode and that I would need to recompute all the features I computed over the last couple of weeks, but then I checked the source code and realised that we rely on the_infer_batch()
function, which runsmodel.eval()
for all models that use it (line 173):tiatoolbox/tiatoolbox/models/architecture/vanilla.py
Lines 148 to 178 in 4a1940d
Suggestion
I think this behaviour is as it should be, but maybe adding a message specifying that the models are being put into
eval
mode would be beneficial.The text was updated successfully, but these errors were encountered: