Skip to main content

cvic

tests License

Local, automated hyperparameter search for image classifiers - from dataset to tuned model with one command, distributed across your local GPUs.

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.

Built on Ray Tune, Optuna, and timm. Requires Python ≥ 3.12.

It ships two commands:

  • cvic — k-fold cross-validation hyperparameter search
  • tunic — hold-out hyperparameter tuning (single train/validation split)

Install

pipx install cvic

or with uv:

uv tool install cvic

Run from source

The project is fully managed by uv with a committed uv.lock, so the exact dependency versions are reproducible across machines. You need an NVIDIA GPU with a reasonably recent driver to use CUDA; the PyTorch wheels bundle their own CUDA runtime, so no system CUDA toolkit installation is required and you do not pick a CUDA version — uv resolves the right wheel for your platform automatically.

git clone https://github.com/ljbuturovic/cvic.git
cd cvic
uv sync                       # creates .venv and installs the locked dependencies
source .venv/bin/activate     # now `cvic` and `tunic` are on your PATH

Verify the GPU is visible:

python -c "import torch; print(torch.cuda.is_available())"

Then run the commands directly (no uv run prefix needed once the venv is activated):

cvic --smoke-test
tunic --smoke-test

To run the test suite:

pytest tests/ -k "not test_smoke"

Quick start

Hold-out tuning:

tunic --data /path/to/dataset --model resnet50 --n_trials 30 --epochs 30 --output results.json

Cross-validation tuning:

cvic --data /path/to/dataset --model resnet50 --n-trials 30 --epochs 30 --folds 5

Train final model from tuning results:

tunic --final results.json --data /path/to/dataset --epochs 50 --amp

Smoke test (synthetic data, no dataset needed):

tunic --smoke-test
cvic --smoke-test

Dataset format

The dataset format is auto-detected:

  • ImageFolder — standard split/class/image.ext layout
  • WebDataset — sharded TAR files; detected when wds/dataset_info.json exists

tunic — hold-out hyperparameter search

tunic --data PATH --model MODEL [options]
Flag Default Description
--data required Dataset root (ImageFolder or WebDataset)
--model required Any timm model name
--n_trials 80 Number of Optuna trials
--epochs 30 Training epochs per trial (also used for --final)
--tune-metric val_auroc Metric for trial selection and pruning
--training_fraction 1.0 Fraction of training data (val always uses 1.0)
--batch-size 32 Batch size per trial
--amp Enable automatic mixed precision
--resume Warm-start from a previous experiment directory
--final Skip tuning; train final model from results JSON
--combine Train final model on train+val combined
--final-model tunic_final.pt Output path for final model weights
--device auto auto, cuda, mps, or cpu
--smoke-test Quick end-to-end test with synthetic data

cvic — cross-validation hyperparameter search

cvic --data PATH --model MODEL [options]
Flag Default Description
--data required Dataset root (ImageFolder or WebDataset)
--model required Any timm model name
--n-trials Number of Optuna trials
--epochs Training epochs per trial
--folds Number of cross-validation folds
--repeats Repeated cross-validation runs
--stratified Use stratified folds
--tune-metric val_auroc Metric for trial selection
--batch-size 32 Batch size per trial
--test-data Held-out test set for final evaluation
--amp Enable automatic mixed precision
--device auto auto, cuda, mps, or cpu
--smoke-test Quick end-to-end test with synthetic data

Run cvic --help / tunic --help for the full list of flags.

Search space

Parameter Range
Optimizer AdamW, SGD
Learning rate 1e-5 – 1e-1 (log)
Weight decay 1e-6 – 1e-1 (log)
Label smoothing 0 – 0.3
Dropout rate 0 – 0.5
RandAugment magnitude 1 – 15
RandAugment num ops 1 – 4
Mixup alpha 0 – 0.5
CutMix alpha 0 – 1.0

Override any part with a YAML file via --search-space.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cvic-1.2.2.tar.gz (189.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cvic-1.2.2-py3-none-any.whl (45.1 kB view details)

Uploaded Python 3

File details

Details for the file cvic-1.2.2.tar.gz.

File metadata

  • Download URL: cvic-1.2.2.tar.gz
  • Upload date:
  • Size: 189.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for cvic-1.2.2.tar.gz
Algorithm Hash digest
SHA256 7d36095971317696b3050a4536dcc09f9fdd0a5fc4d5ae065717204ed0d1ada1
MD5 11c83dd0fc1165e290c5438d676cedb3
BLAKE2b-256 29812c55acc7dfa8e8fd622ceed82d943086481a74969fb30a45d1e9c02b41f7

See more details on using hashes here.

File details

Details for the file cvic-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: cvic-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 45.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for cvic-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6dcb129e1dd79502ca63b7630792fc5d8e2e034a0a5f9388d5910c477dcb8c23
MD5 238e11e6f1929cc579986b7639b5a05e
BLAKE2b-256 d4c6c58c6b78043cf0fd3c848f47b2ed56ae9daf2aa13242ab36ed6f368f1371

See more details on using hashes here.

Release history Release notifications | RSS feed

1.2.4

2 files

This release

1.2.2 This release

2 files

1.2.1

2 files

1.1.0

2 files

1.0.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page