add predict.py
This commit is contained in:
1 parent
c6efd0e27e
commit
e1fb2c634b
5 files changed
+33
-10
No files matched your search
@@ -0,0 +1,24 @@
|
||||
from pipeline_modules.lightning_wrapper import LitModel
|
||||
from pipeline_modules import transforms
|
||||
import pytorch_lightning as pl
|
||||
from train import load_config
|
||||
import torch
|
||||
|
||||
|
||||
# load config
|
||||
config = load_config()
|
||||
|
||||
# load model from checkpoint
|
||||
pretrained_model = LitModel.load_from_checkpoint("example.ckpt", config=config)
|
||||
pretrained_model.eval()
|
||||
|
||||
# load data
|
||||
img = None
|
||||
|
||||
# preprocess
|
||||
img = transforms.efficient_net_test_preprocess(img)
|
||||
img = img.reshape((1, *img.size())) # reshape to form batch of size 1
|
||||
|
||||
# inference
|
||||
output = pretrained_model(img)
|
||||
print(output)
|
||||
Reference in new issue
Block a user