Skip to content

Commit d3ad2be

Browse files
RoseRostamiclaude
andcommitted
Add core library, examples, crack segmentation app, and repo scaffolding
- scripts/: FisherAdapTuneTrainer, AdaFisher, fisher_core, utils - crack_segmentation/: SAM2 and SegFormer fine-tuning with YAML configs and CLI - examples/minimal_image_classifier.py: self-contained runnable example - README, LICENSE (CC BY-NC-SA 4.0), CHANGELOG, CONTRIBUTING, CODE_OF_CONDUCT - pyproject.toml, requirements.txt, Makefile, .gitignore, .pre-commit-config.yaml - .github/: CI workflow and issue templates Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0ab9772 commit d3ad2be

24 files changed

Lines changed: 3283 additions & 1 deletion
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Bug report
3+
about: Report a reproducible bug
4+
labels: bug
5+
---
6+
7+
## Description
8+
9+
A clear description of what the bug is.
10+
11+
## Minimal Reproducible Example
12+
13+
```python
14+
# Paste the smallest code that reproduces the problem
15+
```
16+
17+
## Expected Behaviour
18+
19+
What you expected to happen.
20+
21+
## Actual Behaviour
22+
23+
What actually happened (include the full traceback).
24+
25+
## Environment
26+
27+
- Python version:
28+
- PyTorch version:
29+
- GPU / CUDA version:
30+
- OS:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature request
3+
about: Suggest an improvement or new capability
4+
labels: enhancement
5+
---
6+
7+
## Motivation
8+
9+
What problem does this feature solve? Which use case does it enable?
10+
11+
## Proposed Solution
12+
13+
Describe the change you'd like, including any API design ideas.
14+
15+
## Alternatives Considered
16+
17+
Any alternative approaches you've thought about.

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
check:
11+
name: Lint & type-check (Python ${{ matrix.python-version }})
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ["3.9", "3.10", "3.11", "3.12"]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
cache: pip
25+
26+
- name: Install dev dependencies
27+
run: pip install -e ".[dev]"
28+
29+
- name: Format check
30+
run: make format-check
31+
32+
- name: Lint
33+
run: make lint
34+
35+
- name: Type check
36+
run: make typecheck

.gitignore

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*.pyo
5+
*.pyd
6+
.Python
7+
*.egg
8+
*.egg-info/
9+
dist/
10+
build/
11+
.eggs/
12+
13+
# Virtual environments
14+
.venv/
15+
venv/
16+
env/
17+
18+
# Packaging
19+
*.whl
20+
21+
# Tools
22+
.mypy_cache/
23+
.ruff_cache/
24+
.pre-commit-config.yaml.lock
25+
26+
# Jupyter
27+
.ipynb_checkpoints/
28+
*.ipynb
29+
30+
# Checkpoints and model weights
31+
*.pt
32+
*.pth
33+
*.ckpt
34+
saved_models/
35+
36+
# Logs and outputs
37+
wandb/
38+
logs/
39+
*.log
40+
41+
# Data
42+
*.csv
43+
*.h5
44+
*.hdf5
45+
46+
# OS
47+
.DS_Store
48+
Thumbs.db

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.4.4
4+
hooks:
5+
- id: ruff
6+
args: [--fix]
7+
- id: ruff-format
8+
- repo: https://github.com/pre-commit/mirrors-mypy
9+
rev: v1.10.0
10+
hooks:
11+
- id: mypy
12+
args: [--config-file=pyproject.toml]
13+
pass_filenames: false

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Changelog
2+
3+
All notable changes to FisherAdapTune will be documented here.
4+
5+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6+
7+
## [Unreleased]
8+
9+
## [0.1.0] — 2026-05-22
10+
11+
### Added
12+
13+
- `FisherAdapTuneTrainer`: model-agnostic plug-and-play trainer with Fisher-guided iterative chunk freezing
14+
- `AdaFisher`: diagonal Fisher Information Matrix optimizer used internally for Fisher statistic collection
15+
- `fisher_core`: chunking, Jensen-Shannon divergence tracking, masking, and iterative freeze logic
16+
- `EarlyStopping`, `save_checkpoint`, `plot_js_history` utilities
17+
- SAM2 crack segmentation application (`crack_segmentation/`) with YAML config and full CLI
18+
- Minimal runnable example using synthetic data (`examples/minimal_image_classifier.py`)
19+
- Support for `Linear`, `Conv2d`, `BatchNorm2d`, and `LayerNorm` layers
20+
- Decoupled weight decay applied only to active (unfrozen) parameter entries
21+
- Optional W&B logging and matplotlib JS-distance grid plots
22+
- `pyproject.toml` packaging, `Makefile` automation, pre-commit hooks

CODE_OF_CONDUCT.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Code of Conduct
2+
3+
## Our Standards
4+
5+
We are committed to providing a welcoming and respectful environment for everyone.
6+
7+
Expected behaviour:
8+
- Use welcoming and inclusive language
9+
- Respect differing viewpoints and experiences
10+
- Accept constructive criticism gracefully
11+
- Focus on what is best for the community and the project
12+
13+
Unacceptable behaviour:
14+
- Harassment, trolling, or personal attacks
15+
- Publishing others' private information without consent
16+
- Any conduct that would be considered inappropriate in a professional setting
17+
18+
## Enforcement
19+
20+
Instances of unacceptable behaviour may be reported to **ghodsieh.rostami@gmail.com**.
21+
All reports will be reviewed and investigated promptly.
22+
23+
This Code of Conduct is adapted from the [Contributor Covenant v2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).

CONTRIBUTING.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Contributing to FisherAdapTune
2+
3+
We welcome bug reports, documentation improvements, and feature suggestions.
4+
5+
## Reporting Issues
6+
7+
Open a [GitHub Issue](https://github.com/<your-username>/FisherAdapTune/issues) and include:
8+
9+
- A clear description of the problem
10+
- A minimal reproducible example (ideally using `examples/minimal_image_classifier.py`)
11+
- Your environment: Python version, PyTorch version, GPU, OS
12+
13+
## Development Setup
14+
15+
```bash
16+
git clone https://github.com/<your-username>/FisherAdapTune.git
17+
cd FisherAdapTune
18+
pip install -e ".[dev]"
19+
pre-commit install
20+
```
21+
22+
## Code Style
23+
24+
- Formatting and linting: [Ruff](https://docs.astral.sh/ruff/) (line length 100)
25+
- Type checking: mypy on annotated modules
26+
- Pre-commit hooks run automatically on `git commit`
27+
28+
To run checks manually:
29+
30+
```bash
31+
make check
32+
```
33+
34+
## Pull Requests
35+
36+
1. Fork the repo and create a feature branch from `main`.
37+
2. Run `make check` before pushing.
38+
3. Open a PR with a clear description of what changed and why.
39+
40+
All contributions must be for non-commercial purposes in line with the [CC BY-NC-SA 4.0 license](LICENSE).

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
2+
3+
Copyright (c) 2026 Ghodsieh Rostami
4+
5+
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike
6+
4.0 International License.
7+
8+
You are free to:
9+
Share — copy and redistribute the material in any medium or format
10+
Adapt — remix, transform, and build upon the material
11+
12+
Under the following terms:
13+
Attribution — You must give appropriate credit, provide a link to the license,
14+
and indicate if changes were made.
15+
NonCommercial — You may not use the material for commercial purposes.
16+
ShareAlike — If you remix, transform, or build upon the material, you must
17+
distribute your contributions under the same license as the original.
18+
19+
No additional restrictions — You may not apply legal terms or technological measures that
20+
legally restrict others from doing anything the license permits.
21+
22+
Full license text: https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode

Makefile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.PHONY: help install install-dev install-hooks format format-check lint typecheck check fix clean
2+
3+
help:
4+
@echo "Available targets:"
5+
@echo " install Install package (editable)"
6+
@echo " install-dev Install package with dev dependencies"
7+
@echo " install-hooks Install pre-commit git hooks"
8+
@echo " format Auto-format code with Ruff"
9+
@echo " format-check Verify formatting (no changes)"
10+
@echo " lint Run Ruff lint checks"
11+
@echo " typecheck Run mypy"
12+
@echo " check Run full validation suite (format-check + lint + typecheck)"
13+
@echo " fix Apply Ruff fixes, then rerun full checks"
14+
@echo " clean Remove caches and build artifacts"
15+
16+
install:
17+
pip install -e .
18+
19+
install-dev:
20+
pip install -e ".[dev,logging,plotting]"
21+
22+
install-hooks:
23+
pre-commit install
24+
25+
format:
26+
ruff format scripts/ crack_segmentation/ examples/
27+
28+
format-check:
29+
ruff format --check scripts/ crack_segmentation/ examples/
30+
31+
lint:
32+
ruff check scripts/ crack_segmentation/ examples/
33+
34+
typecheck:
35+
mypy scripts/
36+
37+
check: format-check lint typecheck
38+
39+
fix:
40+
ruff check --fix scripts/ crack_segmentation/ examples/
41+
ruff format scripts/ crack_segmentation/ examples/
42+
$(MAKE) check
43+
44+
clean:
45+
rm -rf __pycache__ scripts/__pycache__ crack_segmentation/__pycache__ examples/__pycache__
46+
rm -rf .mypy_cache .ruff_cache build dist *.egg-info

0 commit comments

Comments
 (0)