Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
208 commits
Select commit Hold shift + click to select a range
6691f6e
feat(dependencies): add torch, torchvision
dhc667 Nov 15, 2025
3ddce09
feat(dependencies): add pillow
dhc667 Nov 15, 2025
ba5037a
Merge pull request #22 from CfM47/feat/add-pytorch-and-pillow-depende…
CfM47 Nov 15, 2025
9d3824c
docs: update contributing-md
CfM47 Nov 15, 2025
bcc7083
Merge pull request #24 from CfM47/docs/update-contributing-md
CfM47 Nov 15, 2025
b5968c3
feat: add basic scaffolding, simple cnn approach for classification
dhc667 Nov 16, 2025
8812dc8
docs(REAMDE): add data setup instructions
dhc667 Nov 16, 2025
345a121
feat: add data exploration notebook
dhc667 Nov 16, 2025
e2054e7
fix(tests): add pytest fix
dhc667 Nov 16, 2025
9a5bf58
refactor(config): separate configuration loading from approaches
dhc667 Nov 16, 2025
86bb98d
style(cnn_v1): rename config file for clarity
dhc667 Nov 16, 2025
ec3334d
Merge pull request #26 from CfM47/feat/add-scaffolding--cnn-classifier
dhc667 Nov 21, 2025
0c9edba
feat: Introduce core interfaces for AutoML pipeline components includ…
fprestamo Dec 19, 2025
a26c256
feat: Add Model Interface
fprestamo Dec 19, 2025
a0f3c0e
feat: Implement ViT and Swin models, and update project configuration.
fprestamo Dec 20, 2025
4cd650f
feat: Add AutoML Orchestration.
fprestamo Dec 20, 2025
430cc4b
refactor(auto-ml): Fix typing, linting errors, make verifications tests
dhc667 Dec 25, 2025
c1e304c
feat: Update test_dataset_loader and test_pipeline
fprestamo Dec 25, 2025
c8e64cc
fix: delete structure
dhc667 Dec 26, 2025
64d1b6b
fix: delete old approach in favor of auto ml
dhc667 Dec 26, 2025
c122918
Merge pull request #28 from CfM47/feat/auto-ml
dhc667 Dec 26, 2025
2a243fa
feat: Update auto_ml components, main script, and tests.
fprestamo Dec 26, 2025
29079b6
feat: Update model test files.
fprestamo Dec 26, 2025
8179211
fix(linting): resolve ruff linting errors
theleywin Dec 26, 2025
1d5cb7c
Merge pull request #29 from CfM47/feat/add-automl-evaluator-node
theleywin Dec 26, 2025
07e3968
feat: Add QuadtreeSegmentationModel and ClassificationModelInterface …
CfM47 Dec 26, 2025
4b4888d
Add autoencoder-based mask evaluator and tests
fprestamo Dec 28, 2025
4a6a755
fix(linting): resolve ruff linting errors
theleywin Dec 28, 2025
83bd91b
test(quadtree): Add tests for quadtree segmentation
CfM47 Dec 28, 2025
3388dcf
fix(types): resolve mypy typing errors
theleywin Dec 28, 2025
f36612a
Merge pull request #32 from CfM47/feat/add-mask-coherence-evaluator
theleywin Dec 28, 2025
aa0d44a
Merge branch 'dev' into feat/quadtree
theleywin Dec 28, 2025
2ed9535
Merge pull request #30 from CfM47/feat/quadtree
theleywin Dec 28, 2025
3a9bd2b
refactor: split implementations.py into modular structure
theleywin Dec 28, 2025
aa63bed
refactor: change implementations/models -> implementations/segmentators
theleywin Dec 28, 2025
edfb258
Merge pull request #33 from CfM47/refactor/implementations
fprestamo Dec 28, 2025
ddeba71
feat: add CNN classifier and validator notebook
dhc667 Dec 27, 2025
39f1593
fix: appease the makefile
dhc667 Dec 28, 2025
df9fb85
feat: create classification model interface implementation with CNN
dhc667 Dec 28, 2025
b0fd91c
test: add quad tree + CNN Classifier integration test
dhc667 Dec 29, 2025
8f4122c
Merge pull request #31 from CfM47/feat/cnn-classifier-and-validator
fprestamo Dec 29, 2025
4a21769
refactor: rename segmentator models implementations file names, appea…
dhc667 Dec 29, 2025
034cd05
Merge pull request #34 from CfM47/refactor/model-names--appease-makefile
dhc667 Dec 29, 2025
8c59ab2
feat: implement comprehensive augmentation system with SEM-specific t…
theleywin Dec 29, 2025
4b9ba3e
feat: add train method for classifier model interface
dhc667 Dec 29, 2025
cfe32dc
fix: make tests deterministic
dhc667 Dec 29, 2025
e811f5f
doc: augmentators docs
DiegoViera1511 Dec 29, 2025
9d4b370
doc: add an USAGE_GUIDE and create a modular structure for augmentato…
theleywin Dec 29, 2025
c50ab06
Merge branch 'dev' into feat/augmentators
theleywin Dec 29, 2025
f39993c
fix: mypy issues
theleywin Dec 29, 2025
a521e25
Merge branch 'feat/augmentators' of https://github.com/CfM47/ML-Proje…
theleywin Dec 29, 2025
7a3a67c
Merge pull request #36 from CfM47/feat/augmentators
fprestamo Dec 30, 2025
444a369
feat: add train method for classifier model interface
dhc667 Dec 29, 2025
eca1171
fix: make tests deterministic
dhc667 Dec 29, 2025
26393c7
feat(datasets): add function to load classification dataset
CfM47 Dec 30, 2025
76b15d9
feat(quadtree): implement train function in quadtree segmentation model
CfM47 Dec 30, 2025
aa73682
fix: rebase conflicts
dhc667 Dec 30, 2025
b702d40
Merge branch 'feat/train-method-for-classifier-interface' of https://…
dhc667 Dec 30, 2025
461757a
fix(quadtre): train classifier argument of invalid type
CfM47 Dec 30, 2025
58203b1
fix: put quadtree segmentator classifier training dataset path in init
dhc667 Dec 30, 2025
4aa179b
Merge pull request #35 from CfM47/feat/train-method-for-classifier-in…
dhc667 Dec 30, 2025
659a5f3
feat: adding vit classifier and created unit tests for ViT classifier…
LoLProM Dec 30, 2025
bdae5b9
fix: fixing linting errors
LoLProM Dec 30, 2025
bd05456
feat: enhance ViT model with training functionality and adaptive batc…
LoLProM Dec 31, 2025
585b08e
fix: typing issue
dhc667 Dec 31, 2025
ac6c838
Delete unnecesary cast
fprestamo Dec 31, 2025
c167e9a
Remove unused import 'cast' from interfaces.py
fprestamo Dec 31, 2025
842466d
Merge pull request #37 from CfM47/feat/vit-classifier
fprestamo Dec 31, 2025
cedc8d4
fix: Save metrics distribution instead of jsut one value.
fprestamo Dec 31, 2025
b121fb2
feat: implement 18 segmentation evaluators with per-class and macro-a…
Sekai02 Dec 31, 2025
e99710b
feat: Implement AutoML caching and autosaver functionality with tests
LoLProM Dec 31, 2025
e9446c3
fix: fixing returning any error
LoLProM Dec 31, 2025
dc083ed
refactor: split segmentation.py into separate metric files
Sekai02 Dec 31, 2025
2c8d7ef
Merge pull request #38 from CfM47/feat/add-automl-autosave
fprestamo Dec 31, 2025
852c095
fix: make automl folder visible.
fprestamo Dec 31, 2025
efdb580
Update AutoML result keys and experiment parameters
fprestamo Dec 31, 2025
c62844f
fix: ruff issues
pablo-bego Jan 1, 2026
279c8b8
fix: disable test for IoUClass0Evaluator
pablo-bego Jan 1, 2026
a82620b
Merge branch 'dev' into feat/segmentation-models-evaluators
theleywin Jan 1, 2026
286b022
Fix test
fprestamo Jan 1, 2026
ddc093b
Merge pull request #39 from CfM47/feat/segmentation-models-evaluators
theleywin Jan 1, 2026
39be605
Merge branch 'dev' into fix/automl-autosave
fprestamo Jan 1, 2026
d393fc3
Fix ruff
fprestamo Jan 1, 2026
8c75447
Merge pull request #41 from CfM47/fix/automl-autosave
theleywin Jan 1, 2026
86838a9
test(quadtree): add tests for hyperparameter tuning
CfM47 Jan 1, 2026
afb59e1
Add simulated annealing for quadtree hyperparameter tuning
fprestamo Jan 1, 2026
b99e392
Refactor quadtree hyperparameter tuning and tests
fprestamo Jan 1, 2026
acbf74d
Merge pull request #42 from CfM47/feat/quadtree-tunning
fprestamo Jan 1, 2026
3088387
feat: add auto ML setup scaffolding
dhc667 Jan 1, 2026
334d7c6
Implement evaluator and model node setup functions
fprestamo Jan 1, 2026
702112a
feat: initialize evaluator node with dataset
fprestamo Jan 1, 2026
9e51122
feat(model-setup): instantiadted quadtree nodes per classifier
CfM47 Jan 1, 2026
1126784
fix(model-setup): fix typo in metric to optimize quadtree
CfM47 Jan 1, 2026
f7348d3
Merge branch 'feat/add-auto-ml-setup' of https://github.com/CfM47/ML-…
dhc667 Jan 1, 2026
c14b7cb
fix: make quad tree model train CNN with 50 epochs
dhc667 Jan 2, 2026
0c0e72e
feat: Add training and val history and fix an error during trains and…
fprestamo Jan 1, 2026
58d881f
Merge pull request #40 from CfM47/feat/add-auto-ml-setup
fprestamo Jan 2, 2026
e9fc0a4
Merge branch 'dev' into feat/add-training-val-history
fprestamo Jan 2, 2026
5b4b348
Merge pull request #43 from CfM47/feat/add-training-val-history
fprestamo Jan 2, 2026
5212947
fix: dataset path injection
dhc667 Jan 2, 2026
4d0073f
fix: inject auto ml cache dir
dhc667 Jan 2, 2026
da2b27a
fix: add logging for classification models
dhc667 Jan 2, 2026
901566f
fix: standardize logging for segmentator models
dhc667 Jan 2, 2026
f961d1c
fix: typing issues
dhc667 Jan 2, 2026
39e9103
fix: typo
dhc667 Jan 2, 2026
4e514c7
Merge pull request #45 from CfM47/feat/add-auto-ml-setup
dhc667 Jan 2, 2026
2a5983b
feat: get augmentators nodes function
DiegoViera1511 Jan 2, 2026
bbf89fb
Add model hyperparameter customization for ViT and Swin
fprestamo Jan 2, 2026
4975e90
Merge pull request #46 from CfM47/fix/vit-and-swim-hyperparameters
dhc667 Jan 2, 2026
ef1d921
feat: add kaggle notebook
dhc667 Jan 2, 2026
b195dd3
Merge pull request #47 from CfM47/add-kaggle-notebook
fprestamo Jan 2, 2026
bf2f033
fix: main path fix
dhc667 Jan 2, 2026
eda1a26
Merge pull request #49 from CfM47/fix/paths
fprestamo Jan 2, 2026
6f68c45
fix: missing path type hint
dhc667 Jan 2, 2026
9fc1c1e
update: augmentators functions
theleywin Jan 2, 2026
e37c67a
fix: ruff linting on baseline
theleywin Jan 2, 2026
bbbb06c
Merge branch 'dev' into feat/add-auto-ml-setup
theleywin Jan 2, 2026
8ebdca7
feat: Add initial image dataset, sampling script, and AutoML cache.
fprestamo Jan 2, 2026
47b7540
fix batch size error
fprestamo Jan 2, 2026
4d4c419
fix: epochs error
dhc667 Jan 2, 2026
95f77be
Merge pull request #51 from CfM47/feat/add-auto-ml-setup
fprestamo Jan 2, 2026
145da49
Merge branch 'dev' into fix/paths
fprestamo Jan 2, 2026
e519c86
Merge pull request #50 from CfM47/fix/paths
fprestamo Jan 2, 2026
7c7fd82
feat: add auto ml node filtering
dhc667 Jan 2, 2026
ceb2c59
Merge pull request #52 from CfM47/feat/filter-automl-nodes
fprestamo Jan 2, 2026
f5422ce
refactor: replace baseline node with identity augmentator in get_augm…
fprestamo Jan 2, 2026
6b54488
Merge pull request #53 from CfM47/feat/fix-baseline-data-augmentator
dhc667 Jan 2, 2026
a5f465c
fix: negative strides on fliplr function
theleywin Jan 2, 2026
9316db8
Merge pull request #54 from CfM47/fix/flip-augmentators
dhc667 Jan 2, 2026
1dcb552
feat(cnn): add configurable num_blocks parameter for smaller input sizes
dhc667 Jan 2, 2026
0bc2e13
feat(quadtree): add detailed logging for training and evaluation proc…
fprestamo Jan 2, 2026
453d67a
feat(models): update ViT and Swin model configurations for improved p…
fprestamo Jan 2, 2026
deb6300
Merge pull request #55 from CfM47/fix/cnn-smaller-inputs
fprestamo Jan 2, 2026
4b4f851
Merge branch 'dev' into feat/add-biger-models
fprestamo Jan 2, 2026
1a1023e
Merge pull request #56 from CfM47/feat/add-biger-models
dhc667 Jan 2, 2026
7175c0e
feat(models): addded swin classifier model
CfM47 Jan 2, 2026
9a469ad
feat: add sliding window segmentation model with majority voting
Sekai02 Jan 2, 2026
cc8e39c
fix: resolve line length errors in sliding window tests
Sekai02 Jan 2, 2026
64073ce
fix: resolve mypy error in sliding window segmentation
Sekai02 Jan 2, 2026
8696772
fix: correct assertions in sliding window tests
Sekai02 Jan 2, 2026
8b05022
refactor: make swin model names consistent
dhc667 Jan 3, 2026
ef6d71e
feat: add confidence-weighted voting to sliding window segmentation
Sekai02 Jan 3, 2026
b3336c1
fix: add trailing comma in sliding window segmentation
Sekai02 Jan 3, 2026
575a2f9
fix: adjust confidence weighted test for boundary effects
Sekai02 Jan 3, 2026
7e9e17d
docs: update aggregation method description and enhance metrics docum…
Sekai02 Jan 3, 2026
b247abb
Merge pull request #59 from CfM47/feat/sliding-window-segmentation
Sekai02 Jan 3, 2026
d1a5e6c
Add model training results and execution times cache
fprestamo Jan 3, 2026
fac2ae1
Add script to recalculate macro metrics in results cache
fprestamo Jan 3, 2026
9bce1db
feat: add evaluation metrics and training data for new models in resu…
fprestamo Jan 3, 2026
611d218
feat: update evaluation metrics with improved values in results cache
fprestamo Jan 3, 2026
e6098bf
feat: implement F1 mean calculation and save results to JSON
fprestamo Jan 3, 2026
b23ca35
feat: add final model training setup
dhc667 Jan 3, 2026
533b300
feat: add patience-based training for swin model
dhc667 Jan 3, 2026
7938f6d
feat: add validation dataset split for final training
dhc667 Jan 3, 2026
a667a23
feat: add kaggle notebooks
dhc667 Jan 3, 2026
d06edb0
fix: remove branch from kaggle notebooks for mergeability
dhc667 Jan 3, 2026
5d8dcad
docs: update readme
dhc667 Jan 3, 2026
e0c79d7
fix: linting
dhc667 Jan 3, 2026
ddf97b8
fix: training config defaults
dhc667 Jan 3, 2026
11cc0ca
feat: improve images
dhc667 Jan 3, 2026
f588d33
fix: track best val model even if patience is not set
dhc667 Jan 4, 2026
51e8025
refactor: move result processing scripts to results/scripts
dhc667 Jan 4, 2026
61c1b55
Merge pull request #64 from CfM47/refactor/add-results
dhc667 Jan 4, 2026
9af1525
Merge pull request #58 from CfM47/feat/swin-classifier
dhc667 Jan 4, 2026
c7b41d4
Merge branch 'dev' into feat/add-final-model-training-setup
theleywin Jan 4, 2026
51d5a39
fix: typing issue
dhc667 Jan 4, 2026
d635438
Merge branch 'dev' into feat/add-results
theleywin Jan 4, 2026
c3c84c6
Merge pull request #62 from CfM47/feat/add-final-model-training-setup
theleywin Jan 4, 2026
02a18f4
Merge pull request #63 from CfM47/feat/add-results
theleywin Jan 4, 2026
9448574
feat: add training history graph
dhc667 Jan 6, 2026
89e5799
docs: add state of the art
CfM47 Jan 8, 2026
abb35aa
Merge pull request #67 from CfM47/feat/add-training-history-graph
CfM47 Jan 8, 2026
6b6c8eb
Merge pull request #66 from CfM47/feat/soa
CfM47 Jan 8, 2026
ced9d84
feat(report): added abstract and introduction to report
CfM47 Jan 3, 2026
f2da2db
feat(report): add quadtree section
CfM47 Jan 4, 2026
73c4526
feat(report): add data augmentation section to report
CfM47 Jan 4, 2026
efccba7
feat(report): add vit and swin segmentation sections to report
CfM47 Jan 4, 2026
acb830d
feat(report): add some cohesive paragraphs
CfM47 Jan 4, 2026
3bc261a
feat(report): add vit classifier section
CfM47 Jan 4, 2026
f6d41e1
feat(report): add evaluation and metrics section
CfM47 Jan 5, 2026
30d071a
feat(report): add automl metodology section
CfM47 Jan 5, 2026
4397601
fix(report): improved vit segmentation subsection
CfM47 Jan 5, 2026
492c65c
fix(report): improved swin semgentation subsection
CfM47 Jan 5, 2026
4331888
fix(report): fix quadtree section
CfM47 Jan 5, 2026
50b13a8
fix(report): fix vit classifier section
CfM47 Jan 5, 2026
36d8d05
feat(report): add automl results
CfM47 Jan 9, 2026
7a968a4
feat: add train loss and val loss plots for models comparitions in tr…
fprestamo Jan 9, 2026
bd3cc21
Merge branch 'feat/report' of https://github.com/CfM47/ML-Project int…
fprestamo Jan 9, 2026
86edbca
Add average fold plots to training and comparison visualizations
fprestamo Jan 9, 2026
6dc49b5
feat(report): add dataset description
CfM47 Jan 9, 2026
7e02888
feat: add analisis de Curvas de Aprendizaje
fprestamo Jan 9, 2026
447cfae
feat:add loss vs data size analysis
fprestamo Jan 9, 2026
b275adf
feat: add more analysis
fprestamo Jan 9, 2026
3460f19
feat: update main.tex
fprestamo Jan 9, 2026
a764b78
feat: update report
fprestamo Jan 9, 2026
877bf34
feat(results): add more metrics to results
CfM47 Jan 9, 2026
9aca74f
feat:update report
fprestamo Jan 9, 2026
68c40e4
Merge branch 'feat/report' of https://github.com/CfM47/ML-Project int…
fprestamo Jan 9, 2026
aef13ad
feat: update report
fprestamo Jan 9, 2026
99fb876
feat:update report
fprestamo Jan 9, 2026
c30544a
feat(report): update
CfM47 Jan 9, 2026
af20284
Merge pull request #61 from CfM47/feat/report
CfM47 Jan 9, 2026
387fcdf
feat(notebooks): update data exploration with training dataset
CfM47 Jan 9, 2026
7f990cc
feat(notebooks): properly name labels
CfM47 Jan 9, 2026
c577f91
Merge pull request #68 from CfM47/feat/update-data-exploration
CfM47 Jan 10, 2026
4b0c9bf
hotfix(report): some minor changes
CfM47 Jan 9, 2026
f05b721
fix(report): add some clarifications
CfM47 Jan 10, 2026
5ac22b9
Merge pull request #69 from CfM47/fix/report-sw
CfM47 Jan 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,10 @@ poetry.toml
# LSP config files
pyrightconfig.json

# End of https://www.toptal.com/developers/gitignore/api/python
# End of https://www.toptal.com/developers/gitignore/api/python

/data/
/.data/

# LLM
.claude/
86 changes: 86 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Agent Coding Style Guidelines

This document outlines specific coding style conventions to be followed for all code generation and modification tasks.

## 1. Docstrings

All function and method docstrings should be written in the imperative mood.

- **DO**: `"""Create a new user in the database."""`
- **DON'T**: `"""Creates a new user in the database."""`
- **DON'T**: `"""This function creates a new user..."""`

## 2. Function and Method Ordering

Code within a file should be organized in order of abstraction, from highest to lowest (top-down).

- The main entry point or the highest-level orchestration function (e.g., `main`) should appear first.
- Helper functions called by the main function should be defined below it.
- Lower-level helpers called by other helpers should be defined even further down.

### Example Structure:

```python
def main():
"""Run the full process."""
# High-level orchestration
data = load_data()
processed_data = process_data(data)
save_data(processed_data)

# --- Helper Functions ---

def load_data():
"""Load data from the source."""
# ... implementation ...

def process_data(data):
"""Process the raw data."""
# ... implementation ...

def save_data(data):
"""Save the processed data."""
# ... implementation ...
```

## 3. Trailing Commas

Use trailing commas in multiline lists, tuples, dictionaries, function definitions, and function calls where each item is on a new line. This improves readability and simplifies diffs in version control.

### Example:

```python
# List
items = [
"item_a",
"item_b",
"item_c", # Trailing comma here
]

# Function definition
def my_function(
param_a: int,
param_b: str, # Trailing comma here
) -> bool:
pass

# Function call
result = another_function(
arg_a=1,
arg_b="hello", # Trailing comma here
)
```

## 4. Configuration File Comments

In configuration files (e.g., `.yaml`), add comments to document the possible values for fields that have a limited, explicit set of options (i.e., enums).

### Example:

```yaml
training:
optimizer: "Adam" # Options: "Adam", "SGD", "RMSprop"
early_stopping:
metric: "val_loss" # Options: "val_loss", "val_accuracy"
mode: "min" # Options: "min", "max"
```
31 changes: 31 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,37 @@ git pull --rebase origin dev

---

## 🆕 Working on Dependent Features

Sometimes you may need to start working on a feature (B) that depends on another feature (A) that is not yet merged into `dev`. In this case, you can create a new branch for feature B from the branch of feature A.

1. **Create a branch for feature B from branch A:**

```bash
# Make sure you are on branch A
git checkout feat/branch-A

# Create branch B from branch A
git checkout -b feat/branch-B
```

2. **Work on feature B and once feature A is merged into `dev`, you need to rebase your branch B onto `dev`.**

```bash
# Make sure you are on branch B
git checkout feat/branch-B

# Fetch the latest changes from the remote
git fetch origin

# Rebase your branch onto dev
git rebase origin/dev
```

This will reapply your changes from branch B on top of the `dev` branch.

---

## 4️⃣ Squashing Commits (Optional but Recommended)

Before pushing your branch, if you have multiple commits, it is recommended to **squash them into a single commit**:
Expand Down
220 changes: 220 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,223 @@
Machine Learning Project for senior year Computer Science ML course.

![Pull Request Checks](https://github.com/CfM47/ML-Project/actions/workflows/pr-checks.yml/badge.svg)

## Overview

This project implements an AutoML pipeline for **SEM (Scanning Electron Microscopy) image segmentation**. It provides two main workflows:

1. **AutoML Exploration** - Automatically explore combinations of augmentations and models to find optimal configurations
2. **Swin Model Training** - Dedicated training pipeline for Swin Transformer segmentation with learning curve analysis

## Installation

This project uses [uv](https://docs.astral.sh/uv/) for dependency management.

```bash
# Clone the repository
git clone https://github.com/CfM47/ML-Project.git
cd ML-Project

# Install dependencies
uv sync

# Install dev dependencies (for testing/linting)
uv sync --group dev
```

## Data Setup

### SEM Images

Place the SEM Images dataset in the `data/sem_images/raw/` directory:

```
data/sem_images/raw/Brittle/{images.png...}
data/sem_images/raw/Ductile/{images.png...}
```

For training/test splits:
```
data/train/unlabeled/{images.png...}
data/train/labeled/{masks.png...}
data/test/unlabeled/{images.png...}
data/test/labeled/{masks.png...}
```

## Usage

### Workflow 1: AutoML Exploration

The AutoML system explores combinations of augmentation strategies and segmentation models using k-fold cross-validation.

```python
from main import _run_with_setup

_run_with_setup(
unlabeled_dir="data/train/unlabeled",
labeled_dir="data/train/labeled",
classification_dataset_dir="data/classification",
auto_ml_cache_dir="cache/automl",
augmentator_indices=[0, 1], # Optional: filter augmentators
model_indices=[0, 1], # Optional: filter models
)
```

**Available Models** (via `setup/models/setup.py`):
- ViT Segmentation Model
- Swin Segmentation Model
- QuadTree + CNN/ViT classifiers
- SlidingWindow + CNN/ViT classifiers

**Available Augmentations** (via `setup/augmentators/setup.py`):
- Identity (no augmentation)
- Combined 2Geo + 2Photo + 1SEM
- Combined 3Geo + 1Photo + 1SEM

### Workflow 2: Swin Model Training

Dedicated training pipeline with learning curve analysis and early stopping support.

#### Learning Curve Validation

Run k-fold cross-validation at varying training percentages:

```python
from model.swin.train import run_percentage_validation
from model.swin.config import SwinTrainingConfig

config = SwinTrainingConfig(
train_percentages=[10, 20, 30, 40, 50, 60, 70, 80],
n_folds=5,
epochs=40,
patience=5, # Early stopping (None to disable)
)

metrics, fig = run_percentage_validation(
train_unlabeled_dir="data/train/unlabeled",
train_labeled_dir="data/train/labeled",
config=config,
)
```

#### Final Model Training

Train on full dataset with 80/20 validation split:

```python
from model.swin.train import run_final_training
from model.swin.config import SwinTrainingConfig

config = SwinTrainingConfig(
epochs=40,
patience=5,
output_dir="results/swin",
)

model, test_metrics, mask_pairs, fig = run_final_training(
train_unlabeled_dir="data/train/unlabeled",
train_labeled_dir="data/train/labeled",
test_unlabeled_dir="data/test/unlabeled",
test_labeled_dir="data/test/labeled",
config=config,
)
```

#### CLI Usage

```bash
# Learning curve validation
python -m model.swin.train validate \
--train-unlabeled data/train/unlabeled \
--train-labeled data/train/labeled \
--output-dir results/swin

# Final training with test evaluation
python -m model.swin.train train \
--train-unlabeled data/train/unlabeled \
--train-labeled data/train/labeled \
--test-unlabeled data/test/unlabeled \
--test-labeled data/test/labeled \
--output-dir results/swin
```

### Kaggle Notebooks

Pre-configured notebooks for running on Kaggle are available in `kaggle/`:

- `run-automl.ipynb` - AutoML exploration
- `run-training.ipynb` - Swin final model training
- `run-validation.ipynb` - Swin learning curve validation

## Configuration

### SwinTrainingConfig

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `train_percentages` | `List[int]` | `[10, 20, ..., 80]` | Percentages for learning curve |
| `n_folds` | `int` | `5` | Number of cross-validation folds |
| `epochs` | `int` | `40` | Training epochs |
| `batch_size` | `int` | `2` | Batch size |
| `learning_rate` | `float` | `1e-4` | Learning rate |
| `embed_dim` | `int` | `96` | Swin embedding dimension |
| `depths` | `List[int]` | `[2, 2, 6, 2]` | Swin layer depths |
| `num_heads` | `List[int]` | `[3, 6, 12, 24]` | Swin attention heads |
| `patience` | `int \| None` | `None` | Early stopping patience (None = disabled) |
| `augmentation_copies` | `int` | `2` | Augmentation copies per sample |
| `num_test_visualizations` | `int` | `10` | Samples to visualize |
| `output_dir` | `Path` | `results/swin` | Output directory |
| `seed` | `int` | `42` | Random seed |
| `device` | `str` | `"auto"` | Device: "auto", "cuda", "mps", "cpu" |

## Project Structure

```
ML-Project/
├── auto_ml/ # Core AutoML framework
│ ├── implementations/ # Concrete implementations
│ │ ├── augmentators/ # Data augmentation strategies
│ │ ├── classifiers/ # CNN, ViT classifiers
│ │ ├── evaluators/ # Metrics (Dice, IoU, Accuracy, etc.)
│ │ ├── segmentators/ # Swin, ViT, QuadTree, SlidingWindow
│ │ ├── datasets.py # Dataset loading utilities
│ │ └── nodes.py # AutoML pipeline nodes
│ ├── interfaces.py # Abstract interfaces
│ └── automl.py # AutoML orchestration
├── model/ # Swin training pipeline
│ └── swin/
│ ├── config.py # SwinTrainingConfig
│ ├── train.py # Training entry points
│ ├── data.py # Data utilities
│ ├── evaluation.py # Evaluation helpers
│ ├── metrics.py # Metrics dataclasses
│ └── visualization.py # Plotting utilities
├── setup/ # Pre-configured setups for AutoML
│ ├── augmentators/ # Augmentation node configurations
│ ├── evaluator/ # Evaluator configurations
│ └── models/ # Model node configurations
├── kaggle/ # Kaggle notebook templates
├── tests/ # Unit tests
├── main.py # AutoML entry point
└── pyproject.toml # Project configuration
```

## Development

```bash
# Run tests
make test

# Type checking
make typecheck

# Linting
make lint

# Format code
make format
```

## License

This project is for educational purposes as part of a senior year ML course.
3 changes: 3 additions & 0 deletions auto_ml/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""AutoML package."""

from auto_ml.automl import AutoML as AutoML
Loading
Loading