image1

Quickstart with Modlee

Welcome to Modlee! This guide will help you get up and running quickly with Modlee, whether you’re new to machine learning or just new to our platform.

Account Setup

Sign up for a Modlee account if you haven’t already or sign in to access your account.


Python Setup

1. Install Python

To use the Modlee package, you’ll need to have Python installed on your computer. To download Python, visit the official Python website and download the latest version. To use the Modlee package, you need at least Python 3.10 or newer. If this is your first time downloading Python, please refer to the official Python installation guide for beginners.


Install the Modlee Package

PyPI

Once you have Python installed and activated a virtual environment, you can install the Modlee package from PyPI. Run this command from the terminal/command line:

pip install modlee

image2

Our package is built on top of PyTorch, PyTorch-lightning, MLFlow, and more to ensure you can continue developing ML with frameworks that you are familiar with.

Source

Alternatively, you can build the package from the source by cloning this repository and installing it from the pyproject.toml configuration file:

git clone https://github.com/modlee-ai/modlee
cd modlee
pip install .

image3


Set API Key

Navigate to the dashboard and generate an API key. Either save your API key to an environment variable:

export MODLEE_API_KEY="my-api-key"

image4

Or pass directly to the modlee.init function (less recommended):

# your_experiment_script.py
import modlee
modlee.init(api_key="my-api-key")

image5


How to Use Modlee - Quick Example

Get started with Modlee by following these steps to set up and train a model using our recommender system. This guide will walk you through the process with a simple end-to-end example.

pip install modlee
import modlee
import lightning.pytorch as pl
import torch
import torchvision
from torch.utils.data import DataLoader
from torchvision import datasets, transforms

# Initialize Modlee with your API key
modlee.init(api_key="your-api-key")

transform = transforms.Compose([
    transforms.Grayscale(num_output_channels=1),
    transforms.ToTensor(),
    transforms.Normalize((0.5,), (0.5,))
])

# Load the Fashion MNIST dataset
train_dataset = datasets.FashionMNIST(root='./data', train=True, download=True, transform=transform)
test_dataset = datasets.FashionMNIST(root='./data', train=False, download=True, transform=transform)

# Create DataLoaders for training and testing
training_loader = DataLoader(train_dataset, batch_size=16, shuffle=True)
test_loader = DataLoader(test_dataset, batch_size=16, shuffle=False)

# Create a recommender for image classification tasks
recommender = modlee.recommender.ImageClassificationRecommender(
    num_classes=10
)

# Fit the recommender with the training DataLoader
recommender.fit(training_loader)

# Retrieve the recommended model from the recommender
modlee_model = recommender.model
print(f"\nRecommended model: \n{modlee_model}")

# Train the recommended model
with modlee.start_run() as run:
    trainer = pl.Trainer(max_epochs=1)
    trainer.fit(
        model=modlee_model,
        train_dataloaders=training_loader,
        val_dataloaders=test_loader
    )

You should see a recommended model as an output. If you are running into issues, please refer to our Troubleshooting Page for more help.


Supported Use Cases

At the moment we support modalities of images, tabular, time-series, and text, and tasks of classification and segmentation, with more coming soon. As with recommendation, use Discord to let us know which modalities and tasks you’d prefer or help make these changes on our GitHub.