cvic 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+
13
+ - uses: astral-sh/setup-uv@v5
14
+ with:
15
+ python-version: "3.12"
16
+
17
+ - name: Install (CPU torch)
18
+ run: |
19
+ uv venv .venv --python 3.12 --clear
20
+ uv pip install --python .venv/bin/python torch torchvision --index-url https://download.pytorch.org/whl/cpu
21
+ uv pip install --python .venv/bin/python -e ".[dev]"
22
+
23
+ - name: Run tests
24
+ run: .venv/bin/pytest tests/ -v -x -k "not test_smoke"
cvic-0.1.0/.gitignore ADDED
@@ -0,0 +1,212 @@
1
+ # Tunic run artifacts
2
+ ray_results/
3
+ *.json
4
+ *.pt
5
+
6
+ # Byte-compiled / optimized / DLL files
7
+ __pycache__/
8
+ *.py[codz]
9
+ *$py.class
10
+
11
+ # C extensions
12
+ *.so
13
+
14
+ # Distribution / packaging
15
+ .Python
16
+ build/
17
+ develop-eggs/
18
+ dist/
19
+ downloads/
20
+ eggs/
21
+ .eggs/
22
+ lib/
23
+ lib64/
24
+ parts/
25
+ sdist/
26
+ var/
27
+ wheels/
28
+ share/python-wheels/
29
+ *.egg-info/
30
+ .installed.cfg
31
+ *.egg
32
+ MANIFEST
33
+
34
+ # PyInstaller
35
+ # Usually these files are written by a python script from a template
36
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
37
+ *.manifest
38
+ *.spec
39
+
40
+ # Installer logs
41
+ pip-log.txt
42
+ pip-delete-this-directory.txt
43
+
44
+ # Unit test / coverage reports
45
+ htmlcov/
46
+ .tox/
47
+ .nox/
48
+ .coverage
49
+ .coverage.*
50
+ .cache
51
+ nosetests.xml
52
+ coverage.xml
53
+ *.cover
54
+ *.py.cover
55
+ .hypothesis/
56
+ .pytest_cache/
57
+ cover/
58
+
59
+ # Translations
60
+ *.mo
61
+ *.pot
62
+
63
+ # Django stuff:
64
+ *.log
65
+ local_settings.py
66
+ db.sqlite3
67
+ db.sqlite3-journal
68
+
69
+ # Flask stuff:
70
+ instance/
71
+ .webassets-cache
72
+
73
+ # Scrapy stuff:
74
+ .scrapy
75
+
76
+ # Sphinx documentation
77
+ docs/_build/
78
+
79
+ # PyBuilder
80
+ .pybuilder/
81
+ target/
82
+
83
+ # Jupyter Notebook
84
+ .ipynb_checkpoints
85
+
86
+ # IPython
87
+ profile_default/
88
+ ipython_config.py
89
+
90
+ # pyenv
91
+ # For a library or package, you might want to ignore these files since the code is
92
+ # intended to run in multiple environments; otherwise, check them in:
93
+ # .python-version
94
+
95
+ # pipenv
96
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
97
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
98
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
99
+ # install all needed dependencies.
100
+ #Pipfile.lock
101
+
102
+ # UV
103
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
104
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
105
+ # commonly ignored for libraries.
106
+ #uv.lock
107
+
108
+ # poetry
109
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
110
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
111
+ # commonly ignored for libraries.
112
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
113
+ #poetry.lock
114
+ #poetry.toml
115
+
116
+ # pdm
117
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
118
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
119
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
120
+ #pdm.lock
121
+ #pdm.toml
122
+ .pdm-python
123
+ .pdm-build/
124
+
125
+ # pixi
126
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
127
+ #pixi.lock
128
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
129
+ # in the .venv directory. It is recommended not to include this directory in version control.
130
+ .pixi
131
+
132
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
133
+ __pypackages__/
134
+
135
+ # Celery stuff
136
+ celerybeat-schedule
137
+ celerybeat.pid
138
+
139
+ # SageMath parsed files
140
+ *.sage.py
141
+
142
+ # Environments
143
+ .env
144
+ .envrc
145
+ .venv
146
+ env/
147
+ venv/
148
+ ENV/
149
+ env.bak/
150
+ venv.bak/
151
+
152
+ # Spyder project settings
153
+ .spyderproject
154
+ .spyproject
155
+
156
+ # Rope project settings
157
+ .ropeproject
158
+
159
+ # mkdocs documentation
160
+ /site
161
+
162
+ # mypy
163
+ .mypy_cache/
164
+ .dmypy.json
165
+ dmypy.json
166
+
167
+ # Pyre type checker
168
+ .pyre/
169
+
170
+ # pytype static type analyzer
171
+ .pytype/
172
+
173
+ # Cython debug symbols
174
+ cython_debug/
175
+
176
+ # PyCharm
177
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
178
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
179
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
180
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
181
+ #.idea/
182
+
183
+ # Abstra
184
+ # Abstra is an AI-powered process automation framework.
185
+ # Ignore directories containing user credentials, local state, and settings.
186
+ # Learn more at https://abstra.io/docs
187
+ .abstra/
188
+
189
+ # Visual Studio Code
190
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
191
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
192
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
193
+ # you could uncomment the following to ignore the entire vscode folder
194
+ # .vscode/
195
+
196
+ # Ruff stuff:
197
+ .ruff_cache/
198
+
199
+ # PyPI configuration file
200
+ .pypirc
201
+
202
+ # Cursor
203
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
204
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
205
+ # refer to https://docs.cursor.com/context/ignore-files
206
+ .cursorignore
207
+ .cursorindexingignore
208
+
209
+ # Marimo
210
+ marimo/_static/
211
+ marimo/_lsp/
212
+ __marimo__/
@@ -0,0 +1 @@
1
+ 3.12
cvic-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,155 @@
1
+ Metadata-Version: 2.4
2
+ Name: cvic
3
+ Version: 0.1.0
4
+ Summary: Local hyperparameter search and cross-validation for image classifiers using Ray Tune + timm
5
+ Project-URL: Homepage, https://github.com/ljbuturovic/cvic
6
+ Project-URL: Repository, https://github.com/ljbuturovic/cvic
7
+ Author: Ljubomir Buturovic
8
+ License: MIT
9
+ Keywords: cross-validation,hyperparameter-tuning,image-classification,optuna,ray-tune,timm
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
14
+ Requires-Python: >=3.12
15
+ Requires-Dist: numpy>=2.4.3
16
+ Requires-Dist: optuna>=4.7.0
17
+ Requires-Dist: pillow>=12.1.1
18
+ Requires-Dist: pyyaml>=6.0
19
+ Requires-Dist: ray[train,tune]>=2.54.0
20
+ Requires-Dist: scikit-learn>=1.8.0
21
+ Requires-Dist: timm>=1.0.25
22
+ Requires-Dist: torch>=2.0.0
23
+ Requires-Dist: torchvision>=0.15.0
24
+ Requires-Dist: tqdm>=4.66.0
25
+ Requires-Dist: webdataset>=1.0.2
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.0; extra == 'dev'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # cvic
31
+
32
+ [![tests](https://github.com/ljbuturovic/cvic/actions/workflows/test.yml/badge.svg)](https://github.com/ljbuturovic/cvic/actions/workflows/test.yml)
33
+ ![License](https://img.shields.io/badge/License-MIT-yellow.svg)
34
+
35
+ Local, automated hyperparameter search for image classifiers — from dataset to tuned model with one command, distributed across your local GPUs.
36
+
37
+ cvic uses off-the-shelf models and packages, so you won't get SOTA performance. But it can get surprisingly close, with almost zero effort. Useful as a baseline, or for experimentation with architectures and GPUs.
38
+
39
+ Built on [Ray Tune](https://docs.ray.io/en/latest/tune/index.html), [Optuna](https://optuna.org/), and [timm](https://github.com/huggingface/pytorch-image-models). Requires Python ≥ 3.12.
40
+
41
+ It ships two commands:
42
+
43
+ - **`tunic`** — hold-out hyperparameter tuning (single train/validation split).
44
+ - **`cvic`** — k-fold cross-validation hyperparameter search (for smaller datasets where a single split is noisy).
45
+
46
+ > This is the local subset of [krunic](https://github.com/ljbuturovic/krunic). The cloud launcher (SkyPilot/AWS) lives in krunic; cvic runs entirely on your own machine.
47
+
48
+ ## Install
49
+
50
+ ```bash
51
+ pipx install cvic
52
+ ```
53
+
54
+ or with uv:
55
+
56
+ ```bash
57
+ uv tool install cvic
58
+ ```
59
+
60
+ ## Quick start
61
+
62
+ **Hold-out tuning:**
63
+ ```bash
64
+ tunic --data /path/to/dataset --model resnet50 --n_trials 30 --epochs 30 --output results.json
65
+ ```
66
+
67
+ **Cross-validation tuning:**
68
+ ```bash
69
+ cvic --data /path/to/dataset --model resnet50 --n-trials 30 --epochs 30 --folds 5
70
+ ```
71
+
72
+ **Train final model from tuning results:**
73
+ ```bash
74
+ tunic --final results.json --data /path/to/dataset --epochs 50 --amp
75
+ ```
76
+
77
+ **Smoke test (synthetic data, no dataset needed):**
78
+ ```bash
79
+ tunic --smoke-test
80
+ cvic --smoke-test
81
+ ```
82
+
83
+ ## Dataset format
84
+
85
+ The dataset format is auto-detected:
86
+
87
+ - **ImageFolder** — standard `split/class/image.ext` layout
88
+ - **WebDataset** — sharded TAR files; detected when `wds/dataset_info.json` exists
89
+
90
+ ## tunic — hold-out hyperparameter search
91
+
92
+ ```
93
+ tunic --data PATH --model MODEL [options]
94
+ ```
95
+
96
+ | Flag | Default | Description |
97
+ |---|---|---|
98
+ | `--data` | required | Dataset root (ImageFolder or WebDataset) |
99
+ | `--model` | required | Any timm model name |
100
+ | `--n_trials` | 80 | Number of Optuna trials |
101
+ | `--epochs` | 30 | Training epochs per trial (also used for `--final`) |
102
+ | `--tune-metric` | `val_auroc` | Metric for trial selection and pruning |
103
+ | `--training_fraction` | 1.0 | Fraction of training data (val always uses 1.0) |
104
+ | `--batch-size` | 32 | Batch size per trial |
105
+ | `--amp` | | Enable automatic mixed precision |
106
+ | `--resume` | | Warm-start from a previous experiment directory |
107
+ | `--final` | | Skip tuning; train final model from results JSON |
108
+ | `--combine` | | Train final model on train+val combined |
109
+ | `--final-model` | `tunic_final.pt` | Output path for final model weights |
110
+ | `--device` | `auto` | `auto`, `cuda`, `mps`, or `cpu` |
111
+ | `--smoke-test` | | Quick end-to-end test with synthetic data |
112
+
113
+ ## cvic — cross-validation hyperparameter search
114
+
115
+ ```
116
+ cvic --data PATH --model MODEL [options]
117
+ ```
118
+
119
+ | Flag | Default | Description |
120
+ |---|---|---|
121
+ | `--data` | required | Dataset root (ImageFolder or WebDataset) |
122
+ | `--model` | required | Any timm model name |
123
+ | `--n-trials` | | Number of Optuna trials |
124
+ | `--epochs` | | Training epochs per trial |
125
+ | `--folds` | | Number of cross-validation folds |
126
+ | `--repeats` | | Repeated cross-validation runs |
127
+ | `--stratified` | | Use stratified folds |
128
+ | `--tune-metric` | `val_auroc` | Metric for trial selection |
129
+ | `--batch-size` | 32 | Batch size per trial |
130
+ | `--test-data` | | Held-out test set for final evaluation |
131
+ | `--amp` | | Enable automatic mixed precision |
132
+ | `--device` | `auto` | `auto`, `cuda`, `mps`, or `cpu` |
133
+ | `--smoke-test` | | Quick end-to-end test with synthetic data |
134
+
135
+ Run `cvic --help` / `tunic --help` for the full list of flags.
136
+
137
+ ## Search space
138
+
139
+ | Parameter | Range |
140
+ |---|---|
141
+ | Optimizer | AdamW, SGD |
142
+ | Learning rate | 1e-5 – 1e-1 (log) |
143
+ | Weight decay | 1e-6 – 1e-1 (log) |
144
+ | Label smoothing | 0 – 0.3 |
145
+ | Dropout rate | 0 – 0.5 |
146
+ | RandAugment magnitude | 1 – 15 |
147
+ | RandAugment num ops | 1 – 4 |
148
+ | Mixup alpha | 0 – 0.5 |
149
+ | CutMix alpha | 0 – 1.0 |
150
+
151
+ Override any part with a YAML file via `--search-space`.
152
+
153
+ ## License
154
+
155
+ MIT
cvic-0.1.0/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # cvic
2
+
3
+ [![tests](https://github.com/ljbuturovic/cvic/actions/workflows/test.yml/badge.svg)](https://github.com/ljbuturovic/cvic/actions/workflows/test.yml)
4
+ ![License](https://img.shields.io/badge/License-MIT-yellow.svg)
5
+
6
+ Local, automated hyperparameter search for image classifiers — from dataset to tuned model with one command, distributed across your local GPUs.
7
+
8
+ cvic uses off-the-shelf models and packages, so you won't get SOTA performance. But it can get surprisingly close, with almost zero effort. Useful as a baseline, or for experimentation with architectures and GPUs.
9
+
10
+ Built on [Ray Tune](https://docs.ray.io/en/latest/tune/index.html), [Optuna](https://optuna.org/), and [timm](https://github.com/huggingface/pytorch-image-models). Requires Python ≥ 3.12.
11
+
12
+ It ships two commands:
13
+
14
+ - **`tunic`** — hold-out hyperparameter tuning (single train/validation split).
15
+ - **`cvic`** — k-fold cross-validation hyperparameter search (for smaller datasets where a single split is noisy).
16
+
17
+ > This is the local subset of [krunic](https://github.com/ljbuturovic/krunic). The cloud launcher (SkyPilot/AWS) lives in krunic; cvic runs entirely on your own machine.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ pipx install cvic
23
+ ```
24
+
25
+ or with uv:
26
+
27
+ ```bash
28
+ uv tool install cvic
29
+ ```
30
+
31
+ ## Quick start
32
+
33
+ **Hold-out tuning:**
34
+ ```bash
35
+ tunic --data /path/to/dataset --model resnet50 --n_trials 30 --epochs 30 --output results.json
36
+ ```
37
+
38
+ **Cross-validation tuning:**
39
+ ```bash
40
+ cvic --data /path/to/dataset --model resnet50 --n-trials 30 --epochs 30 --folds 5
41
+ ```
42
+
43
+ **Train final model from tuning results:**
44
+ ```bash
45
+ tunic --final results.json --data /path/to/dataset --epochs 50 --amp
46
+ ```
47
+
48
+ **Smoke test (synthetic data, no dataset needed):**
49
+ ```bash
50
+ tunic --smoke-test
51
+ cvic --smoke-test
52
+ ```
53
+
54
+ ## Dataset format
55
+
56
+ The dataset format is auto-detected:
57
+
58
+ - **ImageFolder** — standard `split/class/image.ext` layout
59
+ - **WebDataset** — sharded TAR files; detected when `wds/dataset_info.json` exists
60
+
61
+ ## tunic — hold-out hyperparameter search
62
+
63
+ ```
64
+ tunic --data PATH --model MODEL [options]
65
+ ```
66
+
67
+ | Flag | Default | Description |
68
+ |---|---|---|
69
+ | `--data` | required | Dataset root (ImageFolder or WebDataset) |
70
+ | `--model` | required | Any timm model name |
71
+ | `--n_trials` | 80 | Number of Optuna trials |
72
+ | `--epochs` | 30 | Training epochs per trial (also used for `--final`) |
73
+ | `--tune-metric` | `val_auroc` | Metric for trial selection and pruning |
74
+ | `--training_fraction` | 1.0 | Fraction of training data (val always uses 1.0) |
75
+ | `--batch-size` | 32 | Batch size per trial |
76
+ | `--amp` | | Enable automatic mixed precision |
77
+ | `--resume` | | Warm-start from a previous experiment directory |
78
+ | `--final` | | Skip tuning; train final model from results JSON |
79
+ | `--combine` | | Train final model on train+val combined |
80
+ | `--final-model` | `tunic_final.pt` | Output path for final model weights |
81
+ | `--device` | `auto` | `auto`, `cuda`, `mps`, or `cpu` |
82
+ | `--smoke-test` | | Quick end-to-end test with synthetic data |
83
+
84
+ ## cvic — cross-validation hyperparameter search
85
+
86
+ ```
87
+ cvic --data PATH --model MODEL [options]
88
+ ```
89
+
90
+ | Flag | Default | Description |
91
+ |---|---|---|
92
+ | `--data` | required | Dataset root (ImageFolder or WebDataset) |
93
+ | `--model` | required | Any timm model name |
94
+ | `--n-trials` | | Number of Optuna trials |
95
+ | `--epochs` | | Training epochs per trial |
96
+ | `--folds` | | Number of cross-validation folds |
97
+ | `--repeats` | | Repeated cross-validation runs |
98
+ | `--stratified` | | Use stratified folds |
99
+ | `--tune-metric` | `val_auroc` | Metric for trial selection |
100
+ | `--batch-size` | 32 | Batch size per trial |
101
+ | `--test-data` | | Held-out test set for final evaluation |
102
+ | `--amp` | | Enable automatic mixed precision |
103
+ | `--device` | `auto` | `auto`, `cuda`, `mps`, or `cpu` |
104
+ | `--smoke-test` | | Quick end-to-end test with synthetic data |
105
+
106
+ Run `cvic --help` / `tunic --help` for the full list of flags.
107
+
108
+ ## Search space
109
+
110
+ | Parameter | Range |
111
+ |---|---|
112
+ | Optimizer | AdamW, SGD |
113
+ | Learning rate | 1e-5 – 1e-1 (log) |
114
+ | Weight decay | 1e-6 – 1e-1 (log) |
115
+ | Label smoothing | 0 – 0.3 |
116
+ | Dropout rate | 0 – 0.5 |
117
+ | RandAugment magnitude | 1 – 15 |
118
+ | RandAugment num ops | 1 – 4 |
119
+ | Mixup alpha | 0 – 0.5 |
120
+ | CutMix alpha | 0 – 1.0 |
121
+
122
+ Override any part with a YAML file via `--search-space`.
123
+
124
+ ## License
125
+
126
+ MIT
File without changes