Skip to main content

Hyso: Custom CNN models, SE/CBAM blocks, callbacks, and augmentations

Project description

Hyso

Hyso is a PyTorch-based deep learning library designed for CNN + Bottleneck Residual + CBAM architectures. It simplifies building, training, and evaluating image classification models with integrated callbacks and data augmentation.

Project Structure

hyso/
│
├─ hyso/
│ ├─ models/
│  ├─ bcam_model.py # CNNWithBottleneckResidualCBAM  └─ bcam_fit.py # BCAMWithFit (fit + callbacks) │
│ ├─ augmentation/
│  └─ get_loaders.py # Data loader and augmentations │
│ ├─ callbacks/
│  └─ callbacks.py # EarlyStopping, ModelCheckpoint, LRSchedulerCallback │
│ └─ init.py
│
├─ setup.py # Installation script
└─ README.md # Project documentation


---

## Features

- CNN with **Bottleneck Residual + CBAM** blocks
- `fit()` and `callbacks()` integration for simplified training
- EarlyStopping, ModelCheckpoint, and LR Scheduler support
- Flexible data loading and augmentation via `get_loaders()`
- EMA support for smoother training (optional)

---

## Installation

### From PyPI (future)
```bash
pip install hyso

From GitHub

git clone https://github.com/yourusername/hyso.git cd hyso pip install .

Usage

from hyso.models.bcam_fit import BCAMWithFit
from hyso.augmentation.get_loaders import get_loaders

# ---------------- Dataset ----------------
train_loader, val_loader = get_loaders(
    train_path="path/to/train",
    val_path="path/to/val",
    batch_size=64,
    img_size=(32,32),
    augment="advanced",
    channels=3
)

# ---------------- Model ----------------
model = BCAMWithFit(input_channels=3, num_classes=10)

# ---------------- Training ----------------
model.fit(
    train_loader=train_loader,
    val_loader=val_loader,
    scheduler="StepLR",
    scheduler_params={"step_size":5,"gamma":0.5},
    early_stopping=5,
    checkpoint_path="best_bcam_model.pth",
    epochs=20
)

Callbacks

  • Hyso supports the following callbacks to improve training:

  • EarlyStopping: Stops training if validation loss stops improving.

  • ModelCheckpoint: Saves the best model weights.

  • LRSchedulerCallback: Automatically adjusts the learning rate based on the chosen scheduler.

Example integration:

model.callbacks(
    optimizer="Adam",
    scheduler="StepLR",
    scheduler_params={"step_size":5,"gamma":0.5},
    model_checkpoint=True,
    earlystop={"patience":5, "verbose":True}
)

Model Summary

To view a Keras-style summary of your model:

from torchsummary import summary
summary(model.model, input_size=(3, 32, 32))

Contributing

Pull requests, bug reports, and feature requests are welcome!

License

No license is set. Free to use.

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

hyso-0.1.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

hyso-0.1.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for hyso-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9cb617bab1027f05eab0990ba69b0542abec3ab2e5eb893eea754393931e8775
MD5 aa52450375798a8ec723a2781de7b01c
BLAKE2b-256 892ab23adbddeb69a3d6c69d04d9af7e2ae8ed0b5b06e929a6719b2d17af2dc0

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for hyso-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 398924bb312ddd0a7baa12f806e760c7d93c094b44f4ba22dd69f36a402ace56
MD5 46881adb6ceab53bee3da030154b787b
BLAKE2b-256 da027238b920422d570bb54d09885ef8d9d60cd5b154121934c7c3a562a47a2e

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