{"id":13488718,"url":"https://github.com/georgosgeorgos/few-shot-diffusion-models","last_synced_at":"2025-03-28T01:37:31.653Z","repository":{"id":47117054,"uuid":"496004178","full_name":"georgosgeorgos/few-shot-diffusion-models","owner":"georgosgeorgos","description":"Few-Shot Diffusion Models","archived":false,"fork":false,"pushed_at":"2023-01-10T15:33:22.000Z","size":1579,"stargazers_count":100,"open_issues_count":10,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-31T00:40:10.548Z","etag":null,"topics":["conditional-generation","diffusion-models","few-shot-generation","generative-models","vision-transformers"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/georgosgeorgos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-24T22:17:45.000Z","updated_at":"2024-10-25T22:45:43.000Z","dependencies_parsed_at":"2023-02-08T19:16:05.544Z","dependency_job_id":null,"html_url":"https://github.com/georgosgeorgos/few-shot-diffusion-models","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgosgeorgos%2Ffew-shot-diffusion-models","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgosgeorgos%2Ffew-shot-diffusion-models/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgosgeorgos%2Ffew-shot-diffusion-models/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgosgeorgos%2Ffew-shot-diffusion-models/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/georgosgeorgos","download_url":"https://codeload.github.com/georgosgeorgos/few-shot-diffusion-models/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245952924,"owners_count":20699561,"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":["conditional-generation","diffusion-models","few-shot-generation","generative-models","vision-transformers"],"created_at":"2024-07-31T18:01:20.639Z","updated_at":"2025-03-28T01:37:31.640Z","avatar_url":"https://github.com/georgosgeorgos.png","language":"Python","funding_links":[],"categories":["Few-Shot"],"sub_categories":[],"readme":"# Few-Shot Diffusion Models (FSDM)\n\n* preprint: `Few-Shot Diffusion Models` - https://arxiv.org/abs/2205.15463\n\n*Denoising diffusion probabilistic models (DDPM) are powerful hierarchical latent variable models with remarkable sample generation quality and training stability. These properties can be attributed to parameter sharing in the generative hierarchy, as well as a parameter-free diffusion-based inference procedure. In this paper, we present Few-Shot Diffusion Models (FSDM), a framework for few-shot generation leveraging conditional DDPMs. FSDMs are trained to adapt the generative process conditioned on a small set of images from a given class by aggregating image patch information using a set-based Vision Transformer (ViT). At test time, the model is able to generate samples from previously unseen classes conditioned on as few as 5 samples from that class. We empirically show that FSDM can perform few-shot generation and transfer to new datasets taking full advantage of the conditional DDPM*.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/georgosgeorgos/few-shot-diffusion-models/blob/main/assets/fsdm.png\" width=\"900px\" alt=\"teaser\"\u003e \n\u003c/p\u003e\n\n## Set the env\n```python\nconda create -n fsdm python=3.6\n\ngit clone https://github.com/georgosgeorgos/few-shot-diffusion-models\n\ncd few-shot-diffusion-models\n\npip install -r requirements.txt\n```\n\n## Datasets\nWe train the models on small sets of dimension 2-20. \nTrain/val/test sets use disjoint classes by default.\n\nBinary:\n\n* `Omniglot` (back_eval) - (1 x 28 x 28) - 964/97/659\n\nRGB:\n\n* `CIFAR100` - (3 x 32 x 32) - 60/20/20\n* `CIFAR100mix` - (3 x 32 x 32) - 60/20/20\n* `MinImageNet` - (3 x 32 x 32) - 64/16/20\n* `CelebA` - (3 x 64 x 64) - 4444/635/1270\n\n## Training\n\nTrain a DDPM on CIFAR100\n\n```bash\nsh script/run.sh gpu_num ddpm_cifar100 \n```\n\nTrain a FSDM model on CIFAR100 dataset with ViT encoder, FiLM conditioning and MEAN aggregation\n\n```bash\nsh script/run.sh gpu_num vfsddpm_cifar100_vit_film_mean\n```\n\nTrain a MODEL on DATASET with ENCODER, CONDITIONING and AGGREGATION\n\n```bash\nsh script/run.sh gpu_num {dddpm, cddpm, sddpm, addpm, vfsddpm}_{omniglot, cifar100, cifar100mix, minimagenet, cub, celeba}_{vit, unet}_{mean, lag, cls, sum_patch_mean}\n```\n\n## Sampling\nSample a FSDM model on CIFAR100 for new classes after 100K iterations 1000 samples\n\n```bash\nsh script/sample_conditional.sh gpu_num vfsddpm_cifar100_vit_film_mean_outdistro {date} 100000 1000\n```\n\n\n## Metrics\nCompute FID, IS, Precision, Recall for a FSDM model on CIFAR100 new classes\n\n\n\n\n## Acknoledgments\n\nA lot of code and ideas borrowed from:\n\n* https://github.com/openai/guided-diffusion\n* https://github.com/lucidrains/vit-pytorch\n* https://github.com/CompVis/latent-diffusion\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgosgeorgos%2Ffew-shot-diffusion-models","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeorgosgeorgos%2Ffew-shot-diffusion-models","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgosgeorgos%2Ffew-shot-diffusion-models/lists"}