{"id":15600994,"url":"https://github.com/lucidrains/bit-diffusion","last_synced_at":"2025-04-04T18:04:41.566Z","repository":{"id":56815126,"uuid":"525857215","full_name":"lucidrains/bit-diffusion","owner":"lucidrains","description":"Implementation of Bit Diffusion, Hinton's group's attempt at discrete denoising diffusion, in Pytorch","archived":false,"fork":false,"pushed_at":"2023-10-14T14:43:45.000Z","size":77,"stargazers_count":342,"open_issues_count":4,"forks_count":18,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-28T17:10:01.989Z","etag":null,"topics":["artificial-intelligence","deep-learning","denoising-diffusion","discrete"],"latest_commit_sha":null,"homepage":"","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/lucidrains.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2022-08-17T15:41:22.000Z","updated_at":"2025-02-27T23:58:04.000Z","dependencies_parsed_at":"2024-10-23T00:30:44.465Z","dependency_job_id":null,"html_url":"https://github.com/lucidrains/bit-diffusion","commit_stats":{"total_commits":36,"total_committers":4,"mean_commits":9.0,"dds":"0.16666666666666663","last_synced_commit":"e2c94c655959f80d3ca2a13f75114ac14694eda6"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fbit-diffusion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fbit-diffusion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fbit-diffusion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fbit-diffusion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucidrains","download_url":"https://codeload.github.com/lucidrains/bit-diffusion/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226213,"owners_count":20904465,"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":["artificial-intelligence","deep-learning","denoising-diffusion","discrete"],"created_at":"2024-10-03T02:11:13.826Z","updated_at":"2025-04-04T18:04:41.544Z","avatar_url":"https://github.com/lucidrains.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"./bit-diffusion.png\" width=\"450px\"\u003e\u003c/img\u003e\n\n## Bit Diffusion - Pytorch\n\nImplementation of \u003ca href=\"https://arxiv.org/abs/2208.04202\"\u003eBit Diffusion\u003c/a\u003e, Hinton's group's attempt at discrete denoising diffusion, in Pytorch\n\nIt seems like they missed the mark for text, but the research direction still seems promising. I think a clean repository will do the research community a lot of benefits for those branching off from here.\n\n## Install\n\n```bash\n$ pip install bit-diffusion\n```\n\n## Usage\n\n```python\nfrom bit_diffusion import Unet, Trainer, BitDiffusion\n\nmodel = Unet(\n    dim = 32,\n    channels = 3,\n    dim_mults = (1, 2, 4, 8),\n).cuda()\n\nbit_diffusion = BitDiffusion(\n    model,\n    image_size = 128,\n    timesteps = 100,\n    time_difference = 0.1,       # they found in the paper that at lower number of timesteps, a time difference during sampling of greater than 0 helps FID. as timesteps increases, this time difference can be set to 0 as it does not help\n    use_ddim = True              # use ddim\n).cuda()\n\ntrainer = Trainer(\n    bit_diffusion,\n    '/path/to/your/data',             # path to your folder of images\n    results_folder = './results',     # where to save results\n    num_samples = 16,                 # number of samples\n    train_batch_size = 4,             # training batch size\n    gradient_accumulate_every = 4,    # gradient accumulation\n    train_lr = 1e-4,                  # learning rate\n    save_and_sample_every = 1000,     # how often to save and sample\n    train_num_steps = 700000,         # total training steps\n    ema_decay = 0.995,                # exponential moving average decay\n)\n\ntrainer.train()\n```\n\nResults will be saved periodically to the `./results` folder\n\nIf you would like to experiment with the `Unet` and `BitDiffusion` class outside the `Trainer`\n\n```python\nimport torch\nfrom bit_diffusion import Unet, BitDiffusion\n\nmodel = Unet(\n    dim = 64,\n    dim_mults = (1, 2, 4, 8)\n)\n\nbit_diffusion = BitDiffusion(\n    model,\n    image_size = 128,\n    timesteps = 1000\n)\n\ntraining_images = torch.randn(8, 3, 128, 128) # images are normalized from 0 to 1\nloss = bit_diffusion(training_images)\nloss.backward()\n# after a lot of training\n\nsampled_images = bit_diffusion.sample(batch_size = 4)\nsampled_images.shape # (4, 3, 128, 128)\n```\n\n## Citations\n\n```bibtex\n@article{Chen2022AnalogBG,\n    title   = {Analog Bits: Generating Discrete Data using Diffusion Models with Self-Conditioning},\n    author  = {Ting Chen and Ruixiang Zhang and Geoffrey E. Hinton},\n    journal = {ArXiv},\n    year    = {2022},\n    volume  = {abs/2208.04202}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Fbit-diffusion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucidrains%2Fbit-diffusion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Fbit-diffusion/lists"}