# SwanLab — Open-Source ML Training Tracker and Visualizer > A lightweight experiment tracking tool with a modern dashboard for logging, comparing, and visualizing ML training runs. ## Install Save as a script file and run: # SwanLab — Open-Source ML Training Tracker and Visualizer ## Quick Use ```bash pip install swanlab ``` ```python import swanlab swanlab.init(project="my-project") for epoch in range(10): swanlab.log({"loss": 0.5 / (epoch + 1)}) swanlab.finish() ``` ## Introduction SwanLab is an open-source ML experiment tracking and visualization tool that provides a modern web dashboard for logging training metrics, comparing runs, and collaborating on experiments. It can be used fully offline or synced to SwanLab Cloud. ## What SwanLab Does - Logs training metrics, hyperparameters, and system resource usage during model training - Provides an interactive web dashboard for visualizing and comparing experiment runs - Supports logging of images, audio, text, and other media alongside scalar metrics - Integrates with PyTorch, Transformers, LLaMA Factory, Ultralytics, Keras, and more - Offers both cloud-hosted and fully self-hosted deployment options ## Architecture Overview The SwanLab Python client captures metric data from training loops and writes it to a local log directory in a structured format. The `swanlab watch` command starts a local web server that reads these logs and renders an interactive dashboard. For team collaboration, logs can be synced to SwanLab Cloud via the API. The dashboard uses React for the frontend and supports real-time updates during active training runs. ## Self-Hosting & Configuration - Install with `pip install swanlab` on Python 3.8+ - Initialize tracking with `swanlab.init(project="name")` at the start of your script - View local experiments with `swanlab watch --logdir ./swanlog` - Sync to SwanLab Cloud by setting `SWANLAB_API_KEY` in your environment - Use `swanlab.init(mode="local")` for fully offline tracking without any cloud sync ## Key Features - Modern, clean dashboard UI with chart types including line, scatter, bar, and media viewers - Multi-run comparison with overlay charts and parallel coordinate plots - Framework integrations provide one-line setup for popular training libraries - Lightweight client with minimal dependencies and low overhead during training - Self-hosted mode keeps all experiment data on your own infrastructure ## Comparison with Similar Tools - **Weights & Biases** — More mature with broader features; SwanLab offers a lighter open-source alternative - **MLflow** — Broader MLOps platform; SwanLab focuses on experiment tracking with a cleaner UI - **TensorBoard** — TensorFlow-native visualization; SwanLab is framework-agnostic with richer comparison - **ClearML** — Full MLOps suite; SwanLab is lighter and quicker to set up for pure tracking - **Neptune** — Hosted tracking platform; SwanLab provides both self-hosted and cloud options ## FAQ **Q: Can I use SwanLab without creating a cloud account?** A: Yes. Set `mode="local"` in `swanlab.init()` and use `swanlab watch` to view experiments locally. **Q: Which ML frameworks does it integrate with?** A: PyTorch, Transformers, Lightning, Keras, Ultralytics, LLaMA Factory, MMEngine, and others via callback integrations. **Q: How does it compare to Weights & Biases?** A: SwanLab provides similar core tracking features with a lighter footprint. W&B offers more advanced features like sweeps, artifacts, and reports. **Q: Can multiple team members view the same experiments?** A: Yes, through SwanLab Cloud or by sharing access to a self-hosted instance. ## Sources - https://github.com/SwanHubX/SwanLab - https://docs.swanlab.cn/ --- Source: https://tokrepo.com/en/workflows/asset-6d664a46 Author: Script Depot