NWF for computer vision: ConvVAE, ResNet encoders, Split-CIFAR incremental learning, continual learning on images.
Project description
nwf-vision
NWF for Computer Vision
nwf-vision provides encoders and examples for incremental learning, OOD detection, and active learning on images. Built on top of nwf-core, it uses its indices, metrics, and calibrators.
Features
- ConvVAEEncoder — convolutional VAE for images (CIFAR 32x32, MNIST)
- PretrainedVisionEncoder — ResNet18/34 with (z, sigma) head for NWF charges
- Split-CIFAR-10 example — incremental classification without catastrophic forgetting
- OOD detection example — CIFAR-10 (in) vs SVHN (out) using semantic potential
- Active learning example — uncertainty sampling vs random on CIFAR-10
- Support for NHWC and NCHW input layouts
Installation
pip install nwf-vision
Requires: nwf-core, torch, torchvision.
Encoders
ConvVAEEncoder
Convolutional VAE producing (z, sigma) for NWF charges. Suitable for small images (32x32).
from nwf.vision import ConvVAEEncoder
import numpy as np
enc = ConvVAEEncoder(input_shape=(3, 32, 32), latent_dim=64)
enc.fit(train_images, epochs=20)
z, sigma = enc.encode(images[:10])
input_shape— (C, H, W), e.g. (3, 32, 32) for CIFARlatent_dim— dimension of zhidden_dims— encoder channel sizes (default: 32, 64, 128)fit(train_data, epochs, batch_size, lr)— train VAEencode(x)— returns(z, sigma)as numpy arrays; accepts NHWC or NCHW
PretrainedVisionEncoder
ResNet backbone from torchvision with a head producing (z, sigma).
from nwf.vision import PretrainedVisionEncoder
enc = PretrainedVisionEncoder(
backbone="resnet18",
latent_dim=64,
pretrained=True,
trainable=False,
)
enc.fit(images, epochs=5)
z, sigma = enc.encode(images)
backbone— "resnet18" or "resnet34"pretrained— use ImageNet weightstrainable— fine-tune backbone or freeze it- Input: (N, 3, 224, 224) for ImageNet-style models
Example: Split-CIFAR-10
Incremental learning: 5 tasks, 2 classes each. Train ConvVAE once, add charges per task.
pip install nwf-core nwf-vision
python examples/split_cifar.py --epochs 5 --n-tasks 5
The example demonstrates adding new classes without retraining the encoder and without catastrophic forgetting.
Examples: OOD and Active Learning
python examples/ood_detection.py # CIFAR-10 vs SVHN, AUROC
python examples/active_learning.py # Uncertainty vs random sampling
Links
- Article (Habr): Нейровесовые Поля (NWF) — теория, continual learning
- Core: nwf-core
- Research: nwf-research
License
MIT
nwf-vision (Русский)
NWF для компьютерного зрения
nwf-vision предоставляет энкодеры и примеры для инкрементального обучения, OOD-детекции и активного обучения на изображениях.
Компоненты
- ConvVAEEncoder — свёрточный VAE для изображений (CIFAR 32x32, MNIST); выход
(z, sigma) - PretrainedVisionEncoder — ResNet18/34 с головой для (z, sigma); предобученные веса
- Split-CIFAR-10 — пример инкрементальной классификации без катастрофического забывания
- OOD detection — пример CIFAR-10 vs SVHN через потенциал
- Active learning — uncertainty sampling vs random
Установка
pip install nwf-vision
Пример
from nwf.vision import ConvVAEEncoder
from nwf import Charge, Field
enc = ConvVAEEncoder(input_shape=(3, 32, 32), latent_dim=64)
enc.fit(images, epochs=10)
z, sigma = enc.encode(images[:5])
field = Field()
for i in range(5):
field.add(Charge(z=z[i], sigma=sigma[i]), labels=[labels[i]])
Лицензия
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nwf_vision-0.1.2.tar.gz.
File metadata
- Download URL: nwf_vision-0.1.2.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c23714c7806a4afd4aa3c5548986c687f7c913c150ce7d9ca3d8f1fe425b9d9a
|
|
| MD5 |
e61236d0be2b949632f552b25c899566
|
|
| BLAKE2b-256 |
8c217e8dced22f0b1513f3eeece1a7cdd5ff5fbc363af30e46bcbfa1b2be9bc0
|
File details
Details for the file nwf_vision-0.1.2-py3-none-any.whl.
File metadata
- Download URL: nwf_vision-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f721d239ec1a0958eda7bca7c58d44e2052c42c9efb7acdec20e8fca2e724fe
|
|
| MD5 |
009dcdbd4372bd881bfa1b125d8084d2
|
|
| BLAKE2b-256 |
de0cd9c1a2f5032a28b2fcf559eedb3e86e9ed98ff831571c7ac5f778c01e4dc
|