Quickstart
Install SleepKit
We provide several installation methods including pip, poetry, and Docker. Install SleepKit via pip/poetry for the latest stable release or by cloning the GitHub repo for the most up-to-date. Additionally, a VSCode Dev Container is available and defined in ./.devcontainer to run in an isolated Docker environment.
Install
Clone the repository if you are interested in contributing to the development or wish to experiment with the latest source code. After cloning, navigate into the directory and install the package. In this mode, Poetry is recommended.
# Clone the repository
git clone https://github.com/AmbiqAI/sleepkit.git
# Navigate to the cloned directory
cd sleepkit
# Install the package in editable mode for development
poetry install
When using editable mode via Poetry, be sure to activate the python environment: poetry shell
.
On Windows using Powershell, use .venv\Scripts\activate.ps1
.
Install the SleepKit package using pip or Poetry. Visit the Python Package Index (PyPI) for more details on the package: https://pypi.org/project/sleepkit/
Or, if you prefer to use Poetry, you can install the package with the following command:
Alternatively, you can install the latest development version directly from the GitHub repository. Make sure to have the Git command-line tool installed on your system. The @main command installs the main branch and may be modified to another branch, i.e. @canary.
Or, using Poetry:
Requirements
Check the project's pyproject.toml file for a list of up-to-date Python dependencies. Note that the installation methods above install all required dependencies. The following are optional dependencies only needed when running demo
command using Ambiq's evaluation board (EVB
) backend:
Once installed, SleepKit can be used as either a CLI-based tool or as a Python package to perform advanced experimentation.
Use SleepKit with CLI
The SleepKit command line interface (CLI) allows for simple single-line commands without the need for a Python environment. The CLI requires no customization or Python code. You can simply run all tasks from the terminal with the sleepkit
command. Check out the CLI Guide to learn more about available options.
Example
sleepkit
commands use the following syntax:
Or using short flags:
Where:
MODE
is one ofdownload
,feature
,train
,evaluate
,export
, ordemo
TASK
is one ofdetect
,stage
,apnea
, orarousal
CONFIG
is configuration as JSON content or file path
Extract features from the datasets using the supplied configuration file.
Train a sleep stage model using the supplied configuration file.
Evaluate the trained sleep stage model using the supplied configuration file.
Use SleepKit with Python
The SleepKit Python package allows for more fine-grained control and customization. You can use the package to train, evaluate, and deploy models for a variety of tasks. The package is designed to be simple and easy to use.
For example, you can create a custom model, train it, evaluate its performance on a validation set, and even export a quantized TensorFlow Lite model for deployment. Check out the Python Guide to learn more about using SleepKit as a Python package.
Example
- Configuration parameters: