ml-project-template
ml-project-template copied to clipboard
Starter template for your ML/AI projects (uv package manager, RestAPI with FastAPI and Dockerfile support)
ML Project Template
Starter template for your Machine Learning/AI projects.
Features:
dvcfor data versioning and pipeline management (reproducibility)FastAPIfor serving the modeluvpackage managerrufffor linting and formattingpytestfor testinglogurufor loggingDockerfor containerization
Install
Make sure you have uv installed.
Clone the repository:
git clone [email protected]:mlexpertio/ml-project-template.git .
cd ml-project-template
Install Python:
uv python install 3.12.8
Create and activate a virtual environment:
uv venv
source .venv/bin/activate
Install dependencies:
uv sync
Install package in editable mode:
uv pip install -e .
Install pre-commit hooks:
uv run pre-commit install
Reproduce
The project contains three different stages defined in dvc.yaml.
- Create a dataset from the raw data:
uv run dvc repro build-dataset
- Train a model using the dataset:
uv run dvc repro train-model
- Evaluate the model using the test dataset:
uv run dvc repro evaluate
API server
Start the FastAPI server:
uv run python app.py
Test the API:
curl -X POST "http://localhost:8000/predict" \
-H "Content-Type: application/json" \
-d '{"text": "lets launch now"}'
Tests
uv run pytest
Docker
The template includes a Dockerfile to build a Docker image:
docker build -t prophet:latest .
Run the Docker container:
docker run -d -p 8000:8000 --name prophet prophet:latest