<jupyter_start><jupyter_text>Train your pytorch model<jupyter_code># Insert the model to pytorch lightning
config = CONFIG
lightning_model = lightning.SegModel.from_conf(config)


# init the trainer and optional callbacks
extra_callbacks = []
# extra_callbacks = [lightning.WandbImageCallback()]
trainer = lightning.SegTrainer.from_conf(config, extra_callbacks=extra_callbacks)

# pannuke dataset
pannuke = PannukeDataModule(
    database_type="hdf5",
    augmentations=["hue_sat", "non_rigid", "blur"],
    normalize=False,
)<jupyter_output><empty_output><jupyter_text>Train the model<jupyter_code># from src.dl.lightning.lightning_utils import ModelSummary
# summarizer = ModelSummary(lightning_model, mode='full')
# summarizer
# Train
trainer.fit(model=lightning_model, datamodule=pannuke)
from src.utils import FileHandler

# Test
trainer.test(
    model=lightning_model,
    ckpt_path=FileHandler.get_model_checkpoint(
        experiment=config.experiment_args.experiment_name,
        version=config.experiment_args.experiment_version,
        which="last"
    ),
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09809264305177112, 'fraction_numerical': 0.0009082652134423251, 'mean_word_length': 6.6, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '446410', 'license': 'MIT', 'n_tokens_mistral': 379, 'n_tokens_neox': 370, 'n_words': 61, 'path': 'notebooks/1_train_model.ipynb', 'repo_name': 'okunator/Dippa', 'size': '1101'}