{"id":26003078,"url":"https://github.com/probabilists/azula","last_synced_at":"2025-04-05T07:01:20.357Z","repository":{"id":250812429,"uuid":"818179772","full_name":"probabilists/azula","owner":"probabilists","description":"Diffusion models in PyTorch","archived":false,"fork":false,"pushed_at":"2025-03-26T10:31:38.000Z","size":3805,"stargazers_count":99,"open_issues_count":3,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-29T06:01:33.386Z","etag":null,"topics":["deep-learning","diffusion-models","generative-model","torch"],"latest_commit_sha":null,"homepage":"https://azula.readthedocs.io","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/probabilists.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2024-06-21T09:14:37.000Z","updated_at":"2025-03-26T10:09:08.000Z","dependencies_parsed_at":"2024-07-30T07:57:59.828Z","dependency_job_id":"3bb5b2da-2bad-4b04-adb8-b9c0fe12eb4d","html_url":"https://github.com/probabilists/azula","commit_stats":null,"previous_names":["probabilists/azula"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probabilists%2Fazula","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probabilists%2Fazula/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probabilists%2Fazula/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probabilists%2Fazula/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/probabilists","download_url":"https://codeload.github.com/probabilists/azula/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299828,"owners_count":20916190,"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","diffusion-models","generative-model","torch"],"created_at":"2025-03-05T20:00:00.976Z","updated_at":"2025-04-05T07:01:20.290Z","avatar_url":"https://github.com/probabilists.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Azula's banner](https://raw.githubusercontent.com/probabilists/azula/master/docs/images/banner.svg)\n\n# Azula - Diffusion models in PyTorch\n\nAzula is a Python package that implements diffusion models in [PyTorch](https://pytorch.org). Its goal is to unify the different formalisms and notations of the generative diffusion models literature into a single, convenient and hackable interface.\n\n\u003e In the [Avatar](https://wikipedia.org/wiki/Avatar:_The_Last_Airbender) cartoon, [Azula](https://wikipedia.org/wiki/Azula) is a powerful fire and lightning bender ⚡️\n\n## Installation\n\nThe `azula` package is available on [PyPI](https://pypi.org/project/azula), which means it is installable via `pip`.\n\n```\npip install azula\n```\n\nAlternatively, if you need the latest features, you can install it from the repository.\n\n```\npip install git+https://github.com/probabilists/azula\n```\n\n## Getting started\n\nIn Azula's formalism, a diffusion model is the composition of three elements: a noise schedule, a denoiser and a sampler.\n\n* A noise schedule is a mapping from a time $t \\in [0, 1]$ to the signal scale $\\alpha_t$ and the noise scale $\\sigma_t$ in a perturbation kernel $p(X_t \\mid X) = \\mathcal{N}(X_t \\mid \\alpha_t X_t, \\sigma_t^2 I)$ from a \"clean\" random variable $X \\sim p(X)$ to a \"noisy\" random variable $X_t$.\n\n* A denoiser is a neural network trained to predict $X$ given $X_t$.\n\n* A sampler defines a series of transition kernels $q(X_s \\mid X_t)$ from $t$ to $s \u003c t$ based on a noise schedule and a denoiser. Simulating these transitions from $t = 1$ to $0$ samples approximately from $p(X)$.\n\nThis formalism is closely followed by Azula's API.\n\n```python\nfrom azula.denoise import PreconditionedDenoiser\nfrom azula.noise import VPSchedule\nfrom azula.sample import DDPMSampler\n\n# Choose the variance preserving (VP) noise schedule\nschedule = VPSchedule()\n\n# Initialize a denoiser\ndenoiser = PreconditionedDenoiser(\n    backbone=CustomNN(in_features=5, out_features=5),\n    schedule=schedule,\n)\n\n# Train to predict x given x_t\noptimizer = torch.optim.Adam(denoiser.parameters(), lr=1e-3)\n\nfor x in train_loader:\n    t = torch.rand((batch_size,))\n\n    loss = denoiser.loss(x, t)\n    loss.backward()\n\n    optimizer.step()\n    optimizer.zero_grad()\n\n# Generate 64 points in 1000 steps\nsampler = DDPMSampler(denoiser.eval(), steps=1000)\n\nx1 = sampler.init((64, 5))\nx0 = sampler(x1)\n```\n\nAlternatively, Azula's plugin interface allows to load pre-trained models and use them with the same convenient interface.\n\n```python\nimport sys\n\nsys.path.append(\"path/to/guided-diffusion\")\n\nfrom azula.plugins import adm\nfrom azula.sample import DDIMSampler\n\n# Download weights from openai/guided-diffusion\ndenoiser = adm.load_model(\"imagenet_256x256\")\n\n# Generate a batch of 4 images\nsampler = DDIMSampler(denoiser, steps=64).cuda()\n\nx1 = sampler.init((4, 3, 256, 256))\nx0 = sampler(x1)\n\nimages = torch.clip((x0 + 1) / 2, min=0, max=1)\n```\n\nFor more information, check out the documentation and tutorials at [azula.readthedocs.io](https://azula.readthedocs.io).\n\n## Contributing\n\nIf you have a question, an issue or would like to contribute, please read our [contributing guidelines](https://github.com/probabilists/azula/blob/master/CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprobabilists%2Fazula","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprobabilists%2Fazula","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprobabilists%2Fazula/lists"}