{"id":13738221,"url":"https://github.com/Atharva-Phatak/torchflare","last_synced_at":"2025-05-08T16:33:00.240Z","repository":{"id":37054243,"uuid":"358633531","full_name":"Atharva-Phatak/torchflare","owner":"Atharva-Phatak","description":"TorchFlare is a simple, beginner-friendly, and easy-to-use PyTorch Framework train your models effortlessly.","archived":false,"fork":false,"pushed_at":"2025-05-05T18:27:05.000Z","size":18963,"stargazers_count":84,"open_issues_count":10,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-05T19:47:08.661Z","etag":null,"topics":["deep-learning","deep-neural-networks","gans","generative-adversarial-network","image-classfication","image-classification","image-processing","image-segmentation","infrastructure","kaggle","machine-learning","natural-language-processing","python","pytorch","pytorch-model","self-supervised-learning","text-classification"],"latest_commit_sha":null,"homepage":"https://torchflare.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Atharva-Phatak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.MD","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-04-16T14:55:28.000Z","updated_at":"2025-01-30T05:28:56.000Z","dependencies_parsed_at":"2023-09-24T07:17:44.673Z","dependency_job_id":"8c23a512-fe2c-49e1-880b-868d07397727","html_url":"https://github.com/Atharva-Phatak/torchflare","commit_stats":{"total_commits":234,"total_committers":10,"mean_commits":23.4,"dds":0.06837606837606836,"last_synced_commit":"67c261c6f0d4863aaacff5c2ab034dbbb0394a39"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atharva-Phatak%2Ftorchflare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atharva-Phatak%2Ftorchflare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atharva-Phatak%2Ftorchflare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atharva-Phatak%2Ftorchflare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Atharva-Phatak","download_url":"https://codeload.github.com/Atharva-Phatak/torchflare/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253105405,"owners_count":21855019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","deep-neural-networks","gans","generative-adversarial-network","image-classfication","image-classification","image-processing","image-segmentation","infrastructure","kaggle","machine-learning","natural-language-processing","python","pytorch","pytorch-model","self-supervised-learning","text-classification"],"created_at":"2024-08-03T03:02:14.907Z","updated_at":"2025-05-08T16:32:59.441Z","avatar_url":"https://github.com/Atharva-Phatak.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"![image](https://raw.githubusercontent.com/Atharva-Phatak/torchflare/main/docs/source/_static/TorchFlare_official.png)\n\n![PyPI](https://img.shields.io/pypi/v/torchflare?color=success)\n![API](https://img.shields.io/badge/API-stable-success)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/Atharva-Phatak/torchflare?color=success)\n[![CodeFactor](https://www.codefactor.io/repository/github/atharva-phatak/torchflare/badge?s=8b602116b87a38ed9dbf6295933839ff7c85ac81)](https://www.codefactor.io/repository/github/atharva-phatak/torchflare)\n[![Test](https://github.com/Atharva-Phatak/torchflare/actions/workflows/test.yml/badge.svg)](https://github.com/Atharva-Phatak/torchflare/actions/workflows/test.yml)\n[![Documentation Status](https://readthedocs.org/projects/torchflare/badge/?version=latest)](https://torchflare.readthedocs.io/en/latest/?badge=latest)\n[![Publish-PyPI](https://github.com/Atharva-Phatak/torchflare/actions/workflows/publish.yml/badge.svg)](https://github.com/Atharva-Phatak/torchflare/actions/workflows/publish.yml)\n[![DeepSource](https://deepsource.io/gh/Atharva-Phatak/torchflare.svg/?label=active+issues\u0026token=_u890jqK5XjPmNlJCyQkxwmG)](https://deepsource.io/gh/Atharva-Phatak/torchflare/?ref=repository-badge)\n[![DeepSource](https://deepsource.io/gh/Atharva-Phatak/torchflare.svg/?label=resolved+issues\u0026token=_u890jqK5XjPmNlJCyQkxwmG)](https://deepsource.io/gh/Atharva-Phatak/torchflare/?ref=repository-badge)\n[![codecov](https://codecov.io/gh/Atharva-Phatak/torchflare/branch/main/graph/badge.svg?token=HSG3FP6NNB)](https://codecov.io/gh/Atharva-Phatak/torchflare)\n[![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/)\n[![GitHub license](https://img.shields.io/github/license/Atharva-Phatak/torchflare?color=success)](https://github.com/Atharva-Phatak/torchflare/blob/main/LICENSE)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n\n\n\n# ***TorchFlare***\n\n***TorchFlare*** is a simple, beginner-friendly and an easy-to-use PyTorch Framework to train your models with ease.\nIt provides an almost Keras-like experience for training\nyour models with all the callbacks, metrics, etc\n\n\n### ***Features***\n* _A high-level module for Keras-like training._\n* _Flexibility to write custom training and validation loops for advanced use cases._\n* _Off-the-shelf Pytorch style Datasets/Dataloaders for standard tasks such as **Image classification, Image segmentation,\n  Text Classification**, etc_\n* _**Callbacks** for model checkpoints, early stopping, and much more!_\n* _**TorchFlare** uses powerful [torchmetrics](https://github.com/PyTorchLightning/metrics) in the backend for metric computations!_\n* _**Reduction** of the boiler plate code required for training your models._\n* _Create **interactive UI** for model prototyping and POC_\n***\n\nCurrently, **TorchFlare** supports ***CPU*** and ***GPU*** training. DDP and TPU support will be coming soon!\n\n***\n### ***Installation***\n\n    pip install torchflare\n\n***\n### ***Documentation***\n\nThe Documentation is available [here](https://torchflare.readthedocs.io/en/latest/)\n\n\n\n***\n### ***Getting Started***\n\nThe core idea around TorchFlare is the [Experiment](/torchflare/experiments/experiment.py)\nclass. It handles all the internal stuff like boiler plate code for training,\ncalling callbacks,metrics,etc. The only thing you need to focus on is creating you PyTorch Model.\n\nAlso, there are off-the-shelf pytorch style datasets/dataloaders available for standard tasks, so that you don't\nhave to worry about creating Pytorch Datasets/Dataloaders.\n\nHere is an easy-to-understand example to show how Experiment class works.\n\n``` python\nimport torch\nimport torchmetrics\nimport torch.nn as nn\nfrom torchflare.experiments import Experiment, ModelConfig\nimport torchflare.callbacks as cbs\n\n# Some dummy dataloaders\ntrain_dl = SomeTrainingDataloader()\nvalid_dl = SomeValidationDataloader()\ntest_dl = SomeTestingDataloader()\n```\nCreate a pytorch Model\n\n``` python\nclass Net(nn.Module):\n    def __init__(self, n_classes, p_dropout):\n        super().__init__()\n        self.conv1 = nn.Conv2d(1, 10, kernel_size=5)\n        self.conv2 = nn.Conv2d(10, 20, kernel_size=5)\n        self.conv2_drop = nn.Dropout2d(p=p_dropout)\n        self.fc1 = nn.Linear(320, 50)\n        self.fc2 = nn.Linear(50, n_classes)\n\n    def forward(self, x):\n        x = F.relu(F.max_pool2d(self.conv1(x), 2))\n        x = F.relu(F.max_pool2d(self.conv2_drop(self.conv2(x)), 2))\n        x = x.view(-1, 320)\n        x = F.relu(self.fc1(x))\n        x = F.dropout(x, training=self.training)\n        x = self.fc2(x)\n        return x\n```\n\nDefine callbacks and metrics\n``` python\nmetric_list = [\n    torchmetrics.Accuracy(num_classes=num_classes)\n]\n\ncallbacks = [\n    cbs.EarlyStopping(monitor=\"val_accuracy\", mode=\"max\"),\n    cbs.ModelCheckpoint(monitor=\"val_accuracy\"),\n    cbs.ReduceLROnPlateau(mode=\"max\", patience=2),\n]\n```\nDefine Model Configuration\n``` python\n#Defining Model Config for experiment.\nconfig = ModelConfig(\n    nn_module=Net,\n    module_params={\"n_classes\": 10, \"p_dropout\": 0.3},\n    optimizer=\"Adam\",\n    optimizer_params={\"lr\": 3e-4},\n    criterion=\"cross_entropy\",\n)\n```\n\nDefine your experiment\n``` python\n# Set some constants for training\nexp = Experiment(\n    num_epochs=5,\n    fp16=False,\n    device=\"cuda\",\n    seed=42,\n)\n\nexp.compile_experiment(\n    model_config=config,\n    callbacks=callbacks,\n    metrics=metric_list,\n    main_metrics=\"accuracy\",\n)\n# Run your experiment with training dataloader and validation dataloader.\nexp.fit_loader(train_dl=train_dl, valid_dl=valid_dl)\n```\n\nFor inference, you can use infer method, which yields output per batch. You can use it as follows\n``` python\noutputs = []\nfor op in exp.predict_on_loader(\n    test_loader=test_dl, path_to_model=\"./models/model.bin\", device=\"cuda\"\n):\n    op = some_post_process_function(op)\n    outputs.extend(op)\n```\n\nIf you want to access your experiments history or get as a dataframe. You can do it as follows.\n``` python\nhistory = exp.history  # This will return a dict\nexp.get_logs()  # This will return a dataframe constructed from model-history.\n```\n***\n### ***Examples***\n\n* [Image Classification](https://github.com/Atharva-Phatak/torchflare/blob/main/examples/Basic-Tutorials/image_classification.py) using TorchFlare on MNIST dataset.\n* [Text Classification](https://github.com/Atharva-Phatak/torchflare/blob/main/examples/Basic-Tutorials/text_classification.py) using Tiny Bert on IMDB dataset\n* [Variational Auto-encoders](https://github.com/Atharva-Phatak/torchflare/tree/main/examples/Advanced-Tutorials/autoencoders) to generate MNIST dataset.\n* Train [DCGANS](https://github.com/Atharva-Phatak/torchflare/blob/main/examples/Advanced-Tutorials/gans/dcgan.py) to generate MNIST data.\n* [Self Supervised learning](https://github.com/Atharva-Phatak/torchflare/blob/main/examples/Advanced-Tutorials/self-supervision/ssl_byol.py) using [Bootstrap your own latent(BYOL)](https://arxiv.org/abs/2006.07733)\n\n***\n### ***Contributions***\nTo contribute please refer to [Contributing Guide](https://github.com/Atharva-Phatak/torchflare/blob/main/.github/CONTRIBUTING.MD)\n\n***\n### ***Current Contributors***\n\n\u003ca href=\"https://github.com/Atharva-Phatak/torchflare/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=Atharva-Phatak/torchflare\" /\u003e\n\u003c/a\u003e\n\n***\n\n### ***Author***\n\n* **Atharva Phatak** - [Atharva-Phatak](https://github.com/Atharva-Phatak)\n\n\n### Citation\n\nPlease use this bibtex if you want to cite this repository in your publications:\n\n    @misc{TorchFlare,\n        author = {Atharva Phatak},\n        title = {TorchFlare: Easy model training and experimentation.},\n        year = {2020},\n        publisher = {GitHub},\n        journal = {GitHub repository},\n        howpublished = {\\url{https://github.com/Atharva-Phatak/torchflare}},\n    }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAtharva-Phatak%2Ftorchflare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAtharva-Phatak%2Ftorchflare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAtharva-Phatak%2Ftorchflare/lists"}