Certainly! Here’s an example of a Neptune.ai project for tracking machine learning experiments in a computer vision task, such as image classification with PyTorch.
Example: Image Classification Experiment Tracking with Neptune.ai
1. Project Setup
Suppose you have a Neptune project called cv-image-classification.
2. Install Neptune
pip install neptune
3. Initialize Neptune in Your Script
import neptune
run = neptune.init_run(
project="your_workspace/cv-image-classification",
api_token="YOUR_NEPTUNE_API_TOKEN", # You can also use NEPTUNE_API_TOKEN env variable
)
4. Log Hyperparameters
params = {
"batch_size": 32,
"learning_rate": 0.001,
"optimizer": "Adam",
"epochs": 10,
}
run["parameters"] = params
5. Log Metrics During Training
for epoch in range(params["epochs"]):
# ... training code ...
train_loss = 0.2 # example value
val_accuracy = 0.85 # example value
run["train/loss"].log(train_loss)
run["val/accuracy"].log(val_accuracy)
6. Log Model Checkpoints
import torch
# Save model
torch.save(model.state_dict(), "model.pth")
run["model/checkpoints"].upload("model.pth")
7. Log Sample Images
from PIL import Image
# Save a sample image
sample_image = Image.fromarray(image_array)
sample_image.save("sample.png")
run["samples/image"].upload("sample.png")
8. Stop the Run
run.stop()
What You See in Neptune
- Parameters: batch size, learning rate, optimizer, epochs
- Metrics: training loss, validation accuracy per epoch
- Artifacts: model checkpoints, sample images
- Runs Table: Compare different runs with different hyperparameters
Neptune.ai Project Structure Example
cv-image-classification/
├── parameters/
│ ├── batch_size
│ ├── learning_rate
│ └── optimizer
├── train/
│ └── loss
├── val/
│ └── accuracy
├── model/
│ └── checkpoints
└── samples/
└── image
Neptune.ai is very flexible, so you can track anything: metrics, images, audio, text, model files, and more.
For more advanced usage, see the Neptune.ai documentation.
Let me know if you want a full code example or a different use case!