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.0.0.tar.gz (181.3 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.0.0-py3-none-any.whl (43.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cvic-1.0.0.tar.gz
Algorithm Hash digest
SHA256 23169f60a0a82b66d84d08a2898aac47f2613c96e4c7b854d2552c1902192c47
MD5 0d426248c208234a44ab297e49b1a7b1
BLAKE2b-256 8e90ccf2368c3eca902c051c1feb60f3a570b1a148100a06d36d8bf5ecfefc6d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cvic-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a68c2eecaca6575a61edeb4383c7e7977663e0b6b2472ea46810b1d3f0d935f9
MD5 7115cc23586344b60a5deaa2321b6a30
BLAKE2b-256 b6c525cf84b3ba188c8892951744c8d8c5a6015b51074dd3c063e2d6ca514a89

See more details on using hashes here.

Release history Release notifications | RSS feed

1.2.4

2 files

1.2.2

2 files

1.2.1

2 files

1.1.0

2 files

This release

1.0.0 This release

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