{"id":30450158,"url":"https://github.com/cabralpinto/modular-diffusion","last_synced_at":"2025-08-23T13:25:22.242Z","repository":{"id":186093240,"uuid":"657103388","full_name":"cabralpinto/modular-diffusion","owner":"cabralpinto","description":"Python library for designing and training your own Diffusion Models with PyTorch","archived":false,"fork":false,"pushed_at":"2025-06-17T11:53:06.000Z","size":32652,"stargazers_count":287,"open_issues_count":12,"forks_count":14,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-08-22T15:08:05.448Z","etag":null,"topics":["audio-generation","deep-learning","diffusion-models","image-generation","machine-learning","modular-design","python","pytorch","text-generation","transformer","u-net"],"latest_commit_sha":null,"homepage":"https://cabralpinto.github.io/modular-diffusion/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cabralpinto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-06-22T10:22:19.000Z","updated_at":"2025-08-07T14:47:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"9e8a542c-542c-47d2-95c8-8087ae7a1b17","html_url":"https://github.com/cabralpinto/modular-diffusion","commit_stats":null,"previous_names":["cabralpinto/modular-diffusion"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cabralpinto/modular-diffusion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cabralpinto%2Fmodular-diffusion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cabralpinto%2Fmodular-diffusion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cabralpinto%2Fmodular-diffusion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cabralpinto%2Fmodular-diffusion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cabralpinto","download_url":"https://codeload.github.com/cabralpinto/modular-diffusion/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cabralpinto%2Fmodular-diffusion/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271749048,"owners_count":24814115,"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","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["audio-generation","deep-learning","diffusion-models","image-generation","machine-learning","modular-design","python","pytorch","text-generation","transformer","u-net"],"created_at":"2025-08-23T13:25:19.883Z","updated_at":"2025-08-23T13:25:22.224Z","avatar_url":"https://github.com/cabralpinto.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Modular Diffusion\n\n[![PyPI version](https://badge.fury.io/py/modular-diffusion.svg)](https://badge.fury.io/py/modular-diffusion)\n[![Documentation](https://img.shields.io/badge/docs-stable-blue.svg)](https://cabralpinto.github.io/modular-diffusion/)\n[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](https://lbesson.mit-license.org/)\n[![Discord](https://dcbadge.vercel.app/api/server/mYJWQATfTV?style=flat\u0026compact=true)](https://discord.gg/mYJWQATfTV)\n\n\u003e ⚠️ **This project is currently unmaintained.**  \n\u003e I'm no longer able to actively maintain this repository due to other commitments. If you’re interested in taking over as a maintainer and helping the project grow, please open an issue or reach out with a brief overview of your background and interest. \n\nModular Diffusion provides an easy-to-use modular API to design and train custom Diffusion Models with PyTorch. Whether you're an enthusiast exploring Diffusion Models or a hardcore ML researcher, **this framework is for you**.\n\n## Features\n\n- ⚙️ **Highly Modular Design**: Effortlessly swap different components of the diffusion process, including noise type, schedule type, denoising network, and loss function.\n- 📚 **Growing Library of Pre-built Modules**: Get started right away with our comprehensive selection of pre-built modules.\n- 🔨 **Custom Module Creation Made Easy**: Craft your own original modules by inheriting from a base class and implementing the required methods.\n- 🤝 **Integration with PyTorch**: Built on top of PyTorch, Modular Diffusion enables you to develop custom modules using a familiar syntax.\n- 🌈 **Broad Range of Applications**: From generating high-quality images to implementing non-autoregressive text synthesis pipelines, the possiblities are endless.\n\n## Installation\n\nModular Diffusion officially supports Python 3.10+ and is available on PyPI:\n\n```bash\npip install modular-diffusion\n```\n\nYou also need to install the correct [PyTorch distribution](https://pytorch.org/get-started/locally/) for your system.\n\n\u003e **Note**: Although Modular Diffusion works with later Python versions, we currently recommend using Python 3.10. This is because `torch.compile`, which significantly improves the speed of the models, is not currently available for versions above Python 3.10.\n\n## Usage\n\nWith Modular Diffusion, you can build and train a custom Diffusion Model in just a few lines. First, load and normalize your dataset. We are using the dog pictures from [AFHQ](https://paperswithcode.com/dataset/afhq).\n\n```python\nx, _ = zip(*ImageFolder(\"afhq\", ToTensor()))\nx = resize(x, [h, w], antialias=False)\nx = torch.stack(x) * 2 - 1\n```\n\nNext, build your custom model using either Modular Diffusion's prebuilt modules or [your custom modules](https://cabralpinto.github.io/modular-diffusion/guides/custom-modules/).\n\n```python\nmodel = diffusion.Model(\n   data=Identity(x, batch=128, shuffle=True),\n   schedule=Cosine(steps=1000),\n   noise=Gaussian(parameter=\"epsilon\", variance=\"fixed\"),\n   net=UNet(channels=(1, 64, 128, 256)),\n   loss=Simple(parameter=\"epsilon\"),\n)\n```\n\nNow, train and sample from the model.\n\n```python\nlosses = [*model.train(epochs=400)]\nz = model.sample(batch=10)\nz = z[torch.linspace(0, z.shape[0] - 1, 10).long()]\nz = rearrange(z, \"t b c h w -\u003e c (b h) (t w)\")\nsave_image((z + 1) / 2, \"output.png\")\n```\n\nFinally, marvel at the results. \n\n\u003cimg width=\"360\" alt=\"Modular Diffusion teaser\" src=\"https://github.com/cabralpinto/modular-diffusion/assets/47889626/2756f798-8037-460e-b827-255812f203b6\"\u003e\u0026nbsp;\n\nCheck out the [Getting Started Guide](https://cabralpinto.github.io/modular-diffusion/guides/getting-started/) to learn more and find more examples [here](https://github.com/cabralpinto/modular-diffusion/tree/main/examples).\n\n## Contributing\n\nWe appreciate your support and welcome your contributions! Please feel free to submit pull requests if you found a bug or typo you want to fix. If you want to contribute a new prebuilt module or feature, please start by opening an issue and discussing it with us. If you don't know where to begin, take a look at the [open issues](https://github.com/cabralpinto/modular-diffusion/issues). Please read our [Contributing Guide](https://github.com/cabralpinto/modular-diffusion/blob/main/CONTRIBUTING.md) for more details.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcabralpinto%2Fmodular-diffusion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcabralpinto%2Fmodular-diffusion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcabralpinto%2Fmodular-diffusion/lists"}