{ "cells": [ { "cell_type": "markdown", "id": "1d923e4f84643d2b", "metadata": {}, "source": "# Test time augmentation" }, { "cell_type": "code", "execution_count": 1, "id": "620ed78a77d63983", "metadata": { "ExecuteTime": { "end_time": "2024-08-27T10:59:02.570959Z", "start_time": "2024-08-27T10:59:02.527272Z" } }, "outputs": [], "source": [ "# inspecting a sample tta configuration\n", "import mml.configs\n", "from pathlib import Path\n", "from omegaconf import OmegaConf" ] }, { "cell_type": "code", "execution_count": 8, "id": "c905c0e1e7a6aaf4", "metadata": { "ExecuteTime": { "end_time": "2024-08-27T11:00:53.129520Z", "start_time": "2024-08-27T11:00:53.118971Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "mode: mean\n", "variations:\n", " identity:\n", " - name: RandomHorizontalFlip\n", " p: 0.0\n", " rot90:\n", " - name: RandomRotation\n", " degrees:\n", " - 90\n", " - 90\n", " p: 1.0\n", " rot270:\n", " - name: RandomRotation\n", " degrees:\n", " - 270\n", " - 270\n", " p: 1.0\n", " hflip:\n", " - name: RandomHorizontalFlip\n", " p: 1.0\n", "\n" ] } ], "source": [ "path = Path(mml.configs.__file__).parent / \"tta\" / \"rotate.yaml\"\n", "cfg = OmegaConf.load(path)\n", "print(OmegaConf.to_yaml(cfg))" ] }, { "cell_type": "markdown", "id": "ee3966b85422869f", "metadata": {}, "source": "`mode` determines the merging strategy, currently only `mean` is supported but other strategies might be implemented later (majority vote, etc.). `variations` lists all [kornia augmentations](https://kornia.readthedocs.io/en/latest/augmentation.module.html) that shall be performed - ideally they are deterministic. `mml` will apply each transform to each image and merge the predictions of the model according to the `mode`. Note that `tta` is only active during testing and predicting with models - not during training nor validation." }, { "cell_type": "code", "execution_count": null, "id": "1c0c31de9f762235", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 5 }