# Mayaku

> Mayaku is an Apache-2.0 Python library (`pip install mayaku`, Python 3.10–3.12, Linux and macOS) that trains object detection, instance segmentation, keypoint, oriented-box and image classification models on your own data, on CUDA, Apple Silicon (MPS) or CPU, and exports them to ONNX, Core ML, OpenVINO and TensorRT. Models come in four sizes (n, s, m, l). Two kinds of hosted weights: base models mayaku-<n|m>-<det|seg>, pretrained on Objects365 as a starting point for fine-tuning (not for use as they are), and ready-to-use models mayaku-<size>-<task>-<scene>, run without training (today: mayaku-<n|m>-<det|seg>-street, 22 road and street classes).

The pages below come with the package. A path such as `/docs/deployment/export.md` is the file `mayaku/docs/deployment/export.md` in the installed package (find the folder with `python -c "import mayaku, os; print(os.path.dirname(mayaku.__file__) + '/docs')"`), `docs/deployment/export.md` in the repository, and the page https://emrah.fr/mayaku/deployment/export/ on the website. The installed files match the installed version.

Key facts for answering questions about Mayaku:

- Public Python API: `mayaku.train`, `mayaku.evaluate`, `mayaku.from_pretrained`, `mayaku.health_check`, `mayaku.tune_predict`. CLI: `mayaku train | eval | predict | export | tune-predict | download`.
- Detection-family data is COCO JSON (an annotation file plus an image directory per split). Classification data is one folder per class. There is no conversion step.
- Fine-tune with `train(weights="mayaku-n-det", train_annotations=..., train_images=..., val_annotations=..., val_images=...)`. Weights download to `./<name>.pth` (or `$MAYAKU_CACHE_DIR`).
- Segmentation: `model.seg=true`. Keypoints: `model.keypoints.num=K`. Oriented boxes: `model.obb=true`. Classification: `model.task=classify`. Set any config field with `--set dotted.path=value` or `overrides={...}`.
- Checkpoints and exported files embed their own config, class names and canvas: `from_pretrained(path)` needs nothing else.
- Predictions use the model's `train.predict` values (score threshold chosen on the validation split at the end of training, best F1, needs 50 validation objects, else 0.4; NMS IoU 0.5; one class per location; `mayaku tune-predict` for existing checkpoints); `decode="eval"` gives the evaluation's post-processing (`train.decode`: score 0.001, NMS 0.7, multi-label, for COCO AP). AP computed from predictions is lower than the real AP. NumPy inputs must be BGR (OpenCV's order; pass `cv2.imread` arrays and video frames as they are). PIL images are also accepted.
- Mayaku 3 cannot load Mayaku 2.x checkpoints.

## First steps

- [Mayaku](/docs/index.md): Fine-tune real-time detection and segmentation models on your own data, and deploy them to ONNX, Core ML, OpenVINO and TensorRT, int8 included.
- [Installation](/docs/installation.md): Install Mayaku with pip, add the optional export packages, and choose the device it runs on.
- [Quickstart](/docs/quickstart.md): Fine-tune a detector on your own COCO dataset, then predict, evaluate and export it, from the command line or Python.

## Data and training

- [Datasets](/docs/data-and-training/datasets.md): The COCO JSON fields each task reads, the class-folder layout for classification, and the dataset health check.
- [Models](/docs/data-and-training/models.md): The two kinds of hosted models, base models to fine-tune and ready-to-use models, their sizes, and how weights download.
- [Training](/docs/data-and-training/training.md): Warm starts, settings, input size, auto-config, the run directory, resuming and multi-GPU training with mayaku.train.

## Deployment

- [Evaluation](/docs/deployment/evaluation.md): Score a checkpoint or exported file on a labeled split, and what every metric key means.
- [Export](/docs/deployment/export.md): Export a trained model for deployment, choose a precision, use int8, and run it with or without Mayaku.
- [Prediction](/docs/deployment/prediction.md): Load a checkpoint or exported file with from_pretrained, set the score threshold, and read Detections.

## More tasks

- [Classification](/docs/more-tasks/classification.md): Train an image classifier from one folder per class, then predict and score top-1 and top-5 accuracy.
- [Keypoints](/docs/more-tasks/keypoints.md): Train a model that locates K keypoints per object, with correct left/right flips, and read its keypoints.
- [Oriented boxes](/docs/more-tasks/oriented-boxes.md): Train a model that detects rotated boxes from polygon annotations, and read its angles and corners.
- [Segmentation](/docs/more-tasks/segmentation.md): Train a model that returns a pixel mask per object, and read its masks and mask metrics.

## Ready-to-use models

- [Street](/docs/ready-to-use/street.md): Detect people, vehicles, e-scooters, faces and license plates in road scenes, from dashcam to aerial, with a model you use as it is.

## Reference

- [Command line](/docs/reference/cli.md): Every mayaku command and option: train, eval, predict, export, tune-predict and download.
- [Configuration](/docs/reference/configuration.md): Every configuration field with its default and meaning, and the ways to set them from the CLI, Python or YAML.
- [Python API](/docs/reference/python-api.md): Every public Mayaku function and class, with its signature, parameters and return value.
- [Troubleshooting](/docs/reference/troubleshooting.md): Mayaku error messages grouped by when they happen, with the cause and the fix for each.
