Skip to content

Lantern is a template and utilities for working with pytorch

License

Notifications You must be signed in to change notification settings

nextml-code/pytorch-lantern

Repository files navigation

Pytorch Lantern

https://readthedocs.org/projects/pytorch-lantern/badge/?version=latest

Lantern contains our process of bringing a project to fruition as efficiently as possible. This is subject to change as we iterate and improve. This package implements tools and missing features to help bridge the gap between frameworks and libraries that we utilize.

The main packages and tools that we build around are:

Usage

Example of tensor type hinting.

from pydantic import BaseModel
from typing import Annotated
import torch
from lantern import Tensor

class Example(BaseModel):
    image: Annotated[torch.Tensor, Tensor.dims("NCHW").float()]
    label: Annotated[torch.Tensor, Tensor.dims("N").long()]

example = Example(
    image=torch.rand(32, 3, 224, 224),  # 32 images, 3 channels, 224x224 pixels
    label=torch.randint(0, 10, (32,))   # 32 labels
)

See the documentation for more information and usage examples.

Create new project with template

Install cookiecutter and poetry:

pip install cookiecutter
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python

Setup project:

cookiecutter https://github.com/nextml-code/pytorch-lantern-template.git
cd <new-project>
poetry install

You can now train the placeholder model and inspect the results:

guild run prepare
guild run train
guild tensorboard

Use lantern without templates

Install lantern from pypi using pip or poetry:

poetry add pytorch-lantern[training]
pip install pytorch-lantern[training]

About

Lantern is a template and utilities for working with pytorch

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages