image_output_1.png
from pytorch_lightning.callbacks import ModelCheckpoint

from pytorch_lightning.callbacks.early_stopping import EarlyStopping

checkpoint_callback = ModelCheckpoint(monitor='val_loss', filename='model-{epoch:02d}-{val_loss:.2f}', save_top_k=1, mode='min')
early_stop_callback = EarlyStopping(monitor='val_loss', patience=3, verbose=False, mode='min')

print(f'Best Model: {checkpoint_callback.best_model_path}')
inference_model = CountModel.load_from_checkpoint(checkpoint_callback.best_model_path)