Update example.py
#3
by
Haroon
- opened
For zero shot classification, model needs to be in eval mode. Otherwise, the prediction probabilities will not be repeatable for the same image across multiple runs.
Reading the source code, MedImageInsight is a class wrapping the model, using the UniCLModel that is nn.Module.
Hence, if you need to set the model in eval mode, you can do the following:
classifier = MedImageInsight(
model_dir="2024.09.27",
vision_model_name="medimageinsigt-v1.0.0.pt",
language_model_name="language_model.pth"
)
classifier.load_model()
classifier.model.eval() # to set model in eval mode