Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/train-callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
from litmodels import upload_model
from sample_model import LitAutoEncoder

# Define the model name - this should be unique to your model
# The format is <organization>/<teamspace>/<model-name>
MY_MODEL_NAME = "jirka/kaggle/lit-auto-encoder-callback"


class UploadModelCallback(Callback):
def on_train_epoch_end(self, trainer, pl_module):
# Get the best model path from the checkpoint callback
best_model_path = trainer.checkpoint_callback.best_model_path
if best_model_path:
print(f"Uploading model: {best_model_path}")
upload_model(path=best_model_path, name="jirka/kaggle/lit-auto-encoder-callback")
upload_model(path=best_model_path, name=MY_MODEL_NAME)


if __name__ == "__main__":
Expand Down
7 changes: 6 additions & 1 deletion examples/train-resume.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
from litmodels import download_model
from sample_model import LitAutoEncoder

# Define the model name - this should be unique to your model
# The format is <organization>/<teamspace>/<model-name>:<model-version>
MY_MODEL_NAME = "jirka/kaggle/lit-auto-encoder-callback:latest"


if __name__ == "__main__":
dataset = tv.datasets.MNIST(".", download=True, transform=tv.transforms.ToTensor())
train, val = data.random_split(dataset, [55000, 5000])

model_path = download_model(name="jirka/kaggle/lit-auto-encoder-simple", download_dir="my_models")
model_path = download_model(name=MY_MODEL_NAME, download_dir="my_models")
print(f"model: {model_path}")
# autoencoder = LitAutoEncoder.load_from_checkpoint(checkpoint_path=model_path)

Expand Down
7 changes: 6 additions & 1 deletion examples/train-simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
from litmodels import upload_model
from sample_model import LitAutoEncoder

# Define the model name - this should be unique to your model
# The format is <organization>/<teamspace>/<model-name>
MY_MODEL_NAME = "jirka/kaggle/lit-auto-encoder-callback"


if __name__ == "__main__":
dataset = tv.datasets.MNIST(".", download=True, transform=tv.transforms.ToTensor())
train, val = data.random_split(dataset, [55000, 5000])
Expand All @@ -30,4 +35,4 @@
data.DataLoader(val, batch_size=256),
)
print(f"last: {vars(checkpoint_callback)}")
upload_model(path=checkpoint_callback.last_model_path, name="jirka/kaggle/lit-auto-encoder-simple")
upload_model(path=checkpoint_callback.last_model_path, name=MY_MODEL_NAME)
Loading