fix most of wandb callbacks

This commit is contained in:
hobogalaxy committed 2021-01-10 17:39:28 +01:00
1 parent 66097c4bf3
commit 90174d52c4
9 files changed
+100 -120

No files matched your search

@@ -0,0 +1,41 @@
from pytorch_modules.transforms import mnist_transforms
from PIL import Image
# the LitModel you import should be the same as the one you used for training!
from pytorch_modules.lightning_models.simple_mnist_classifier import LitModel
# ckpt can be a url!
def predict():
"""
This method is example of inference with a trained model.
It Loads trained image classification model from checkpoint.
Then it loads example image and predicts its label.
Model used in simple_mnist_classifier.py should be the same as during training!!!
"""
CKPT_PATH = "epoch=0.ckpt"
# load model from checkpoint
trained_model = LitModel.load_from_checkpoint(checkpoint_path=CKPT_PATH)
# switch to evaluation mode
trained_model.eval()
trained_model.freeze()
# load data
img = Image.open("data/example_img.png").convert("L") # for monochromatic conversion
# img = Image.open("data/example_img.png").convert("RGB") # for RGB conversion
# preprocess
img = mnist_transforms.mnist_test_transforms(img)
img = img.reshape((1, *img.size())) # reshape to form batch of size 1
# inference
output = trained_model(img)
print(output)
if __name__ == "__main__":
predict()