Skip to main content

Unified CNN library for image classification and anchor-free object detection with Adaptive Feature Pyramid Attention (AFPA).

Project description

NeuroVisionX

A unified PyTorch library for image classification and anchor-free object detection, built around a single shared backbone and a custom attention module: AFPA (Adaptive Feature Pyramid Attention).

PyPI version License: MIT Python


Why NeuroVisionX

Most beginner-friendly libraries make you choose: a simple classifier or a heavy, hard-to-configure detector (YOLO/SSD-style with anchor boxes and many hyperparameters).

NeuroVisionX gives you both, from one backbone:

  • One backbone, two heads. Train a classifier, a detector, or both, without duplicating feature extraction code.
  • AFPA attention block. Lightweight channel+spatial attention with a learnable residual gate, so it starts as identity and "switches on" only when useful — more stable than dropping raw attention into a network from scratch.
  • Anchor-free detection head. Predicts object centers, sizes, and sub-pixel offsets directly (CenterNet/FCOS-style) — no anchor box tuning.
  • One Trainer class for both tasks, with sensible defaults.
  • Minimal dependencies: torch, torchvision, pillow. Nothing exotic.

Installation

pip install neurovisionx

For local development:

git clone https://github.com/sricodings/neurovisionx.git
cd neurovisionx
pip install -e ".[dev]"

Quick start

Classification

import neurovisionx as nv
from torch.utils.data import DataLoader

train_ds = nv.ImageFolderDataset("data/train", image_size=224)
train_loader = DataLoader(train_ds, batch_size=32, shuffle=True)

model = nv.NeuroVisionXNet(num_classes=len(train_ds.classes), mode="classify")
trainer = nv.Trainer(model, train_loader, task="classify")
trainer.fit(epochs=20)

Object detection

import neurovisionx as nv
from torch.utils.data import DataLoader

train_ds = nv.DetectionDataset("data/images", "data/annotations.json", image_size=512)
train_loader = DataLoader(train_ds, batch_size=8, shuffle=True,
                           collate_fn=nv.dataset.detection_collate_fn)

model = nv.NeuroVisionXNet(num_classes=5, mode="detect")
trainer = nv.Trainer(model, train_loader, task="detect")
trainer.fit(epochs=30)

detections = model.detect(image_tensor, score_thresh=0.4)

Annotation format (annotations.json) — simple COCO-lite JSON:

[
  {"image": "img1.jpg", "boxes": [[34, 12, 200, 180]], "labels": [0]},
  {"image": "img2.jpg", "boxes": [[10, 10, 50, 50], [60, 60, 120, 140]], "labels": [2, 4]}
]

Architecture overview

Input image
    │
    ▼
 Stem conv
    │
    ▼
 Stage 1 (downsample + AFPA) ─────────────┐
    │                                     │
    ▼                                     │
 Stage 2 (downsample + AFPA)  -> C3       │  multi-scale
    │                                     │  feature maps
    ▼                                     │
 Stage 3 (downsample + AFPA)  -> C4 ──┐   │
    │                                 │   │
    ▼                                 │   │
 Stage 4 (downsample + AFPA)  -> C5   │   │
    │                                 │   │
    ├──> Classifier head (GAP + FC)   │   │
    │                                 ▼   │
    └──> 1x1 conv + upsample ──> fuse with C4
                                       │
                                       ▼
                            Anchor-free detection head
                          (heatmap, size, offset maps)

Repository layout

neurovisionx/
├── neurovisionx/
│   ├── __init__.py        # public API
│   ├── layers.py           # ConvBNAct, AFPABlock (the novel attention module)
│   ├── backbone.py         # multi-stage CNN backbone
│   ├── detection_head.py   # anchor-free detection head
│   ├── model.py             # NeuroVisionXNet (combines backbone + heads)
│   ├── dataset.py           # ImageFolderDataset, DetectionDataset
│   ├── trainer.py           # Trainer (training loop, losses)
│   └── utils.py             # IoU, NMS, heatmap decoding, visualization
├── examples/
│   ├── train_classifier.py
│   └── train_detector.py
├── tests/
├── docs/
│   └── PUBLISHING_GUIDE.md
├── pyproject.toml
├── LICENSE
└── README.md

Roadmap (suggested, fill in as you build)

  • Pretrained backbone weights (ImageNet-style pretraining)
  • ONNX export for deployment
  • Mixed-precision training support
  • Data augmentation pipeline (mosaic, mixup, random crop)
  • Benchmark results vs ResNet/YOLO baselines on COCO subset
  • Sphinx-generated documentation site

Contributing

Pull requests are welcome. Please open an issue first to discuss major changes. Run pytest and black . before submitting.

Citing

If you use NeuroVisionX in research, please cite:

@software{neurovisionx2026,
  author = {YOUR NAME},
  title = {NeuroVisionX: Unified Classification and Anchor-Free Detection with Adaptive Feature Pyramid Attention},
  year = {2026},
  url = {https://github.com/YOUR_USERNAME/neurovisionx}
}

License

MIT License — see LICENSE.

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

neurovisionx-0.1.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

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

neurovisionx-0.1.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file neurovisionx-0.1.0.tar.gz.

File metadata

  • Download URL: neurovisionx-0.1.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for neurovisionx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9c7db45f274c4358c44d67b8843c7534f52e6c74dfc0590506d2c864350fe070
MD5 6eed0897fb0083a99a26141869a10375
BLAKE2b-256 aca58352a41ef0ea19ac3cc817a50ebc8477be74808d1c054e5dbce7ea1ea75a

See more details on using hashes here.

File details

Details for the file neurovisionx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: neurovisionx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for neurovisionx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9a2245164aa8eaace71e78368833afa03daf1ecda828ab1980d4d44ffaa3b20
MD5 5c1d24a5bca6d02edeb2151d4ca61c4c
BLAKE2b-256 395eccbaedcda6aedf02f5d226b1bd9994600d7d93a16caf0e26ed3379fb703e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page