A modular library for training, benchmarking, and experimenting with deep vision models.
Project description
About
refrakt_core is a deep learning research framework that re-implements key computer vision papers with high modularity, extensibility, and reproducibility. Designed for education, experimentation, and benchmarking, Refrakt enables rapid iteration on architectures, loss functions, and training routines โ all driven via configuration.
This project is part of a broader initiative to understand, unify, and visualize foundational and modern architectures through clean code, clear abstractions, and rigorous logging.
๐ Goals
- Faithfully reproduce influential CV papers
- Modularize training/evaluation pipelines using YAML + registry patterns
- Enable quick debugging and metric logging via TensorBoard and Weights & Biases (W&B)
- Serve as a platform for personal research, fine-tuning, or new model design
๐ 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
- LNN โ Lagrangian Neural 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
# Calling __main__.py
python -m refrakt_core.api --config refrakt_core/config/vit.yaml
# Calling `refrakt` as a command.
refrakt --config ./refrakt_core/config/resnet.yaml
# Override on-the-fly
python -m refrakt_core.api.train \
config.model.name=ResNet \
config.optimizer.lr=0.0005 \
config.trainer.epochs=20
CLI Usage
usage: refrakt [-h] --config CONFIG --mode {train,test,inference,pipeline}
[--log_dir LOG_DIR]
[--log_type [{tensorboard,wandb} ...]]
[--console]
[--model_path MODEL_PATH]
[--debug]
| Flag | Description |
|---|---|
--config |
Path to YAML config file |
--mode |
Execution mode: train, test, inference, or pipeline |
--log_dir |
Path to log directory (e.g., ./runs) |
--log_type |
Logging backend: tensorboard, wandb, or both |
--console |
Print logs to console as well |
--model_path |
Path to model weights/checkpoint for inference/test |
--debug |
Enable debug mode with extra verbosity |
๐ง Config Structure (YAML)
All components (model, trainer, loss, optimizer, scheduler) are defined in modular YAML files under refrakt_core/config/.
Example: vit.yaml
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]
dataloader:
params:
batch_size: 32
shuffle: true
num_workers: 4
drop_last: false
model:
name: vit
params:
in_channels: 1
num_classes: 10
image_size: 28
patch_size: 7
loss:
name: cross_entropy
params: {}
optimizer:
name: adamw
params:
lr: 0.0003
scheduler: null
trainer:
name: supervised
params:
save_dir: "./checkpoints"
model_name: "vit"
num_epochs: 1
device: cuda
๐ Logging & Monitoring
โ Supported
- TensorBoard (logs saved in
runs/) - Weights & Biases (auto-logged via config)
Setup
# TensorBoard
tensorboard --logdir=./logs/<model_name>/tensorboard/
# Weights & Biases
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
โ โโโ schema.py # Pydantic validation for configs
โ
โโโ 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/ # Decorator-based plugin system
โ
โโโ utils/ # Helper modules (encoders, decoders, data classes)
โ
โโโ transforms.py # Data augmentation logic
โโโ datasets.py # Dataset definitions and loader helpers
โโโ logging.py # Logger wrapper for stdout + W&B/TensorBoard
๐งฉ Extending Refrakt
Add a New Model
- Create the architecture in
models/your_model.py - Inherit from a base class in
models/templates/models.py - Register it using:
from refrakt_core.registry.model_registry import register_model
@register_model("your_model")
class YourModel(BaseClassifier):
...
- Add a YAML config:
config/your_model.yaml - Write a custom trainer if needed (
trainer/your_model.py)s
๐ Example Output
Once training begins, expect:
- Printed progress bar (via
tqdm) - Metrics like loss/accuracy printed and logged
./logs/<model_name>/withevents.out.tfeventsfor TensorBoard- W&B dashboard with training curves, if enabled
๐ฌ Contributing
-
Clone and install:
git clone ... pip install -r requirements-dev.txt pre-commit install
-
Follow formatting (
black,isort,pylint) -
Write tests for any new feature
-
Run:
pytest tests/
PRs and creating issues are absolutely welcome.
๐ญ Future Scope
| Milestone | Description |
|---|---|
| โ Stage 1 | Paper re-implementations in notebooks |
| โ Stage 2 | Modular training + model pipelines |
| ๐ Stage 3 | Convert to a 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 include:
- Mixed-modality support (e.g., image + text)
- More contrastive/self-supervised frameworks
- System-level benchmarks across GPUs
- Evaluation on downstream tasks (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
Release history Release notifications | RSS feed
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 refrakt_core-0.2.1.tar.gz.
File metadata
- Download URL: refrakt_core-0.2.1.tar.gz
- Upload date:
- Size: 66.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4649b7372d1a8b9eeb26b240a87e21ebbd002bb4fc8b7b2b506f1d6f6226eca2
|
|
| MD5 |
d6873deafc5f2045b338a4146e00b3dc
|
|
| BLAKE2b-256 |
70fb1d43b7ded8bb2063d24624dab096d98b92ce52da3773e64f5db5bdd66ed8
|
Provenance
The following attestation bundles were made for refrakt_core-0.2.1.tar.gz:
Publisher:
pypi-publish.yml on refrakt-hub/refrakt_core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
refrakt_core-0.2.1.tar.gz -
Subject digest:
4649b7372d1a8b9eeb26b240a87e21ebbd002bb4fc8b7b2b506f1d6f6226eca2 - Sigstore transparency entry: 232957842
- Sigstore integration time:
-
Permalink:
refrakt-hub/refrakt_core@95011a2e6d70bb7d6d4cd9f44d46e9c86a8d2c7a -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/refrakt-hub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@95011a2e6d70bb7d6d4cd9f44d46e9c86a8d2c7a -
Trigger Event:
release
-
Statement type:
File details
Details for the file refrakt_core-0.2.1-py3-none-any.whl.
File metadata
- Download URL: refrakt_core-0.2.1-py3-none-any.whl
- Upload date:
- Size: 98.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1408201cdbe5abc8fcf6d3b197882f68c1765525f7a6451913d108bc44a369c
|
|
| MD5 |
124899aa544f8d14b64f7536a3aefb82
|
|
| BLAKE2b-256 |
c120f1850d9f06c4d3c694033c2b38490956818386e9b14cd3ddb4485e6526b7
|
Provenance
The following attestation bundles were made for refrakt_core-0.2.1-py3-none-any.whl:
Publisher:
pypi-publish.yml on refrakt-hub/refrakt_core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
refrakt_core-0.2.1-py3-none-any.whl -
Subject digest:
d1408201cdbe5abc8fcf6d3b197882f68c1765525f7a6451913d108bc44a369c - Sigstore transparency entry: 232957851
- Sigstore integration time:
-
Permalink:
refrakt-hub/refrakt_core@95011a2e6d70bb7d6d4cd9f44d46e9c86a8d2c7a -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/refrakt-hub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@95011a2e6d70bb7d6d4cd9f44d46e9c86a8d2c7a -
Trigger Event:
release
-
Statement type: