Skip to main content

Run production-ready ML, DL, and fusion pipelines at scale โ€” without writing a single line of code. Refrakt makes research effortless.

Reason this release was yanked:

incorrect release

Project description

About

refrakt_core is a modular deep learning and machine learning research framework for computer vision, designed for rapid experimentation, extensibility, and reproducibility. It now features a robust, thread-safe registry system, dynamic dataset handling, advanced image resizing, flexible hyperparameter overrides, and comprehensive logging and testing. Refrakt supports both classic and modern CV/ML papers, and enables seamless ML/DL/fusion pipelines.

This project aims to unify, extend, and visualize foundational and modern architectures through clean code, clear abstractions, and rigorous logging.

๐Ÿš€ Key Features

  • Safe Registry System: Thread-safe, import-safe, decorator-based registration for models, datasets, losses, trainers, and transforms. Backward compatible with legacy code.
  • Dynamic Dataset Loader: Load datasets from custom zip files or torchvision, with automatic format detection (GAN, supervised, contrastive) and size validation.
  • Standard Image Resizer/Transforms: Multiple resize strategies (maintain aspect, crop, stretch), size validation, and tensor/PIL support.
  • Hyperparameter Overrides: Override any config parameter from the command line or programmatically for fast experimentation.
  • Improved Logging: Context-aware logging with better error handling, supporting both TensorBoard and Weights & Biases (W&B).
  • Comprehensive Testing: Smoke, sanity, unit, and integration tests for all major features.
  • ML/DL/Fusion Pipelines: Support for pure-ML, pure-DL, and hybrid fusion pipelines (e.g., deep feature extraction + ML fusion head).
  • Modular YAML Configs: All components (model, trainer, loss, optimizer, scheduler, feature engineering) are defined in modular YAML files.

๐Ÿ“š Implemented Papers

  • Vision Transformer (ViT) โ€“ An Image is Worth 16x16 Words
  • ResNet โ€“ Deep Residual Learning for Image Recognition
  • Autoencoders โ€“ Learning Representations via Reconstruction
  • Swin Transformer โ€“ Hierarchical Vision Transformer with Shifted Windows
  • Attention is All You Need
  • ConvNeXt โ€“ A ConvNet for the 2020s
  • SRGAN โ€“ Photo-Realistic Single Image Super-Resolution with GANs
  • SimCLR โ€“ A Simple Framework for Contrastive Learning
  • DINO โ€“ Self-Supervised Vision Transformers
  • MAE โ€“ Masked Autoencoders
  • MSN โ€“ Masked Siamese Networks

โš™๏ธ Setup

git clone https://github.com/refrakt-hub/refrakt_core.git
cd refrakt_core

# Create and activate a virtual environment
conda create -n refrakt python=3.10 -y
conda activate refrakt

# Install dependencies
pip install -r requirements.txt

๐Ÿงช Running Experiments

# Run with a config file
ython -m refrakt_core.api --config refrakt_core/config/vit.yaml

# Or using the CLI
refrakt --config ./refrakt_core/config/resnet.yaml

# Override hyperparameters on-the-fly
python -m refrakt_core.api.train \
    config.model.name=ResNet \
    config.optimizer.lr=0.0005 \
    config.trainer.epochs=20

Supported CLI Flags

Flag Description
--config Path to YAML config file
--log_type Logging backend: tensorboard, wandb, or both
--debug Enable debug mode with extra verbosity

๐Ÿ”ง Config Structure (YAML)

All components are defined in modular YAML files under refrakt_core/config/.

dataset:
  name: MNIST
  params:
    root: ./data
    train: true
    download: true
  transform:
    - name: Resize
      params: { size: [28, 28] }
    - name: ToTensor
    - name: Normalize
      params:
        mean: [0.1307]
        std: [0.3081]

model:
  name: vit
  params:
    in_channels: 1
    num_classes: 10
    image_size: 28
    patch_size: 7

trainer:
  name: supervised
  params:
    save_dir: "./checkpoints"
    model_name: "vit"
    num_epochs: 1
    device: cuda

๐Ÿงฉ Major Components & Patterns

1. Safe Registry System

Register models, datasets, losses, trainers, and transforms using decorators:

from refrakt_core.registry.safe_registry import register_model, get_model

@register_model("my_model")
class MyModel(torch.nn.Module):
    ...

model_cls = get_model("my_model")
model = model_cls()

2. Dynamic Dataset Loader

Load datasets from zip files or torchvision, with format detection:

from refrakt_core.loaders.dataset_loader import load_dataset
train_dataset, val_dataset = load_dataset("path/to/dataset.zip")
train_dataset, val_dataset = load_dataset("mnist")

3. Standard Image Resizer/Transforms

from refrakt_core.resizers.standard_transforms import create_standard_transform
transform = create_standard_transform(target_size=(224, 224), resize_strategy="maintain_aspect")

4. Hyperparameter Overrides

Override any config value from the command line or programmatically:

python train.py --config config.yaml model.name=ResNet optimizer.lr=0.001

5. ML/DL/Fusion Pipelines

Supports pure-ML, pure-DL, and hybrid fusion pipelines (deep features + ML head):

from refrakt_core.api.builders.model_builder import build_model
model = build_model(cfg=config, modules=modules, device="cuda", overrides=["model.params.lr=0.0005"])

๐Ÿ“ˆ Logging & Monitoring

  • TensorBoard: logs in logs/<model_name>/tensorboard/
  • Weights & Biases: auto-logged if enabled in config
tensorboard --logdir=./logs/<model_name>/tensorboard/
export WANDB_API_KEY=your_key_here

๐Ÿงฑ Project Structure

refrakt_core/
โ”œโ”€โ”€ api/                  # CLI: train.py, test.py, inference.py
โ”‚   โ””โ”€โ”€ builders/         # Builders for models, losses, optimizers, datasets
โ”œโ”€โ”€ config/               # YAML configurations for each experiment
โ”œโ”€โ”€ losses/               # Contrastive, GAN, MAE, VAE, etc.
โ”œโ”€โ”€ models/               # Vision architectures (ViT, ResNet, MAE, etc.)
โ”‚   โ””โ”€โ”€ templates/        # Base model templates and abstractions
โ”œโ”€โ”€ trainer/              # Task-specific training logic (SimCLR, SRGAN, etc.)
โ”œโ”€โ”€ registry/             # Safe, decorator-based plugin system
โ”œโ”€โ”€ utils/                # Helper modules (encoders, decoders, data classes)
โ”œโ”€โ”€ resizers/             # Image resizing and standard transforms
โ”œโ”€โ”€ loaders/              # Dynamic and standard dataset loaders
โ”œโ”€โ”€ transforms.py         # Data augmentation logic
โ”œโ”€โ”€ datasets.py           # Dataset definitions and loader helpers
โ”œโ”€โ”€ logging_config.py     # Logger wrapper for stdout + W&B/TensorBoard

๐Ÿงช Testing

Run all tests:

pytest tests/

๐Ÿงฉ Extending Refrakt

Add a New Model

  1. Create the architecture in models/your_model.py
  2. Inherit from a base class in models/templates/models.py
  3. Register it using:
from refrakt_core.registry.model_registry import register_model

@register_model("your_model")
class YourModel(BaseClassifier):
    ...
  1. Add a YAML config: config/your_model.yaml
  2. Write a custom trainer if needed (trainer/your_model.py)

Add a Custom Dataset Loader or Transform

  • Implement in loaders/ or resizers/
  • Register with the safe registry

๐Ÿ” Example Output

  • Progress bar (via tqdm)
  • Metrics printed and logged
  • ./logs/<model_name>/ with TensorBoard events
  • W&B dashboard if enabled

๐Ÿ“ฌ Contributing

  1. Clone and install:
    git clone ...
    pip install -r requirements-dev.txt
    pre-commit install
    
  2. Follow formatting (black, isort, pylint)
  3. Write tests for any new feature
  4. Run:
    pytest tests/
    

PRs and issues are welcome!

๐Ÿ”ญ Future Scope

Milestone Description
โœ… Stage 1 Paper re-implementations in notebooks
โœ… Stage 2 Modular training + model pipelines
โœ… Stage 3 Python library (refrakt train, etc.)
๐Ÿ”œ Stage 4 Web app: visual dashboards, interactive inference
๐Ÿ”œ Stage 5 No-code/low-code config engine for multimodal pipelines
๐Ÿ”œ Stage 6 Explainability: saliency maps, attention visualizations

Planned additions:

  • Mixed-modality support (image + text)
  • More contrastive/self-supervised frameworks
  • System-level benchmarks across GPUs
  • Downstream task evaluation (detection, segmentation)

๐Ÿ“„ License

This repository is licensed under the MIT License. See LICENSE for full details.

๐Ÿ‘ค Maintainer

Akshath Mangudi If you find issues, raise them. If you learn from this, share it. Built with love and curiosity :)

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

refrakt_core-0.3.0.tar.gz (163.4 kB view details)

Uploaded Source

Built Distribution

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

refrakt_core-0.3.0-py3-none-any.whl (251.4 kB view details)

Uploaded Python 3

File details

Details for the file refrakt_core-0.3.0.tar.gz.

File metadata

  • Download URL: refrakt_core-0.3.0.tar.gz
  • Upload date:
  • Size: 163.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for refrakt_core-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6d64ab9b195168e552ad411d3a9531ff1ba742ef8be0c838688106ce7eb81dfc
MD5 a48070068d4ea58d7427342e2049654f
BLAKE2b-256 acd4cec5b073271cd5272d89319cb8aecf13a5590578c221ef4f513ffec81376

See more details on using hashes here.

Provenance

The following attestation bundles were made for refrakt_core-0.3.0.tar.gz:

Publisher: pypi-publish.yml on refrakt-hub/refrakt_core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file refrakt_core-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: refrakt_core-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 251.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for refrakt_core-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 199c506e4dcac9ab7f14ef3f616d9e99d0a5c9de7a9ed282069605aecd7419da
MD5 9bf38d0afcfd5a114a678b95836b636a
BLAKE2b-256 43233fff4b3ab67d32236496d7d9c53041b3c9e5fdbf80a69042df55d1bdfae6

See more details on using hashes here.

Provenance

The following attestation bundles were made for refrakt_core-0.3.0-py3-none-any.whl:

Publisher: pypi-publish.yml on refrakt-hub/refrakt_core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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