{"id":29098403,"url":"https://github.com/mjalali/sparke-diffusers","last_synced_at":"2026-03-17T18:04:33.050Z","repository":{"id":298010699,"uuid":"998064074","full_name":"mjalali/sparke-diffusers","owner":"mjalali","description":"[arXiv] Official implementation of \"SPARKE: Scalable Prompt-Aware Diversity Guidance in Diffusion Models via RKE Score\" for enhancing diversity of diffusion models.","archived":false,"fork":false,"pushed_at":"2025-07-29T13:00:15.000Z","size":8816,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-05T00:25:29.979Z","etag":null,"topics":["diffusers","diffusion-","diversity","generative-model","stable-diffusion"],"latest_commit_sha":null,"homepage":"https://mjalali.github.io/SPARKE/","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/mjalali.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":"2025-06-07T19:38:37.000Z","updated_at":"2025-07-30T16:19:11.000Z","dependencies_parsed_at":"2025-06-25T18:49:17.442Z","dependency_job_id":null,"html_url":"https://github.com/mjalali/sparke-diffusers","commit_stats":null,"previous_names":["mjalali/spale-guidance","mjalali/sparke-guidance","mjalali/sparke-diffusers"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mjalali/sparke-diffusers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjalali%2Fsparke-diffusers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjalali%2Fsparke-diffusers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjalali%2Fsparke-diffusers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjalali%2Fsparke-diffusers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mjalali","download_url":"https://codeload.github.com/mjalali/sparke-diffusers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjalali%2Fsparke-diffusers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30628405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T17:32:55.572Z","status":"ssl_error","status_checked_at":"2026-03-17T17:32:38.732Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["diffusers","diffusion-","diversity","generative-model","stable-diffusion"],"created_at":"2025-06-28T15:01:04.484Z","updated_at":"2026-03-17T18:04:33.045Z","avatar_url":"https://github.com/mjalali.png","language":"Python","readme":"\u003cp align=\"center\"\u003e\n    \u003cbr\u003e\n    \u003cimg src=\"./sparke_diffusers_logo.png\" width=\"800\"/\u003e\n    \u003cbr\u003e\n\u003cp\u003e\n\n# SPARKE Diffusers: Improving the Diversity of Diffusion Models in Diffusers\n\n**SPARKE: Scalable Prompt-Aware Diversity Guidance in Diffusion Models via RKE Score**\n\n---\n\n## Overview\n\nThis repository contains the official implementation of **SPARKE**, a method for improving diversity in prompt-guided diffusion models using **Scalable Prompt-Aware Diversity Guidance in Diffusion Models via RKE Score**. SPARKE introduces conditional entropy-guided sampling that dynamically adapts to semantically similar prompts and supports scalable generation across modern text-to-image architectures.\n\n\u003e Project Webpage: [https://mjalali.github.io/SPARKE](https://mjalali.github.io/SPARKE)\n\n---\n\n## Abstract\n\nDiffusion models have demonstrated exceptional performance in high-fidelity image synthesis and prompt-based generation. However, achieving sufficient diversity—particularly within semantically similar prompts—remains a critical challenge. Prior methods use diversity metrics as guidance signals, but often neglect prompt awareness or computational scalability.\n\nIn this work, we propose **SPARKE**: _Scalable Prompt-Aware Diversity Guidance in Diffusion Models via RKE Score_. SPARKE leverages **conditional entropy** to guide the sampling process with respect to prompt-localized diversity. By employing **Conditional Latent RKE Score Guidance**, we reduce the computational complexity from $\\mathcal{O}(n^3)$ to $\\mathcal{O}(n)$, enabling efficient large-scale generation. We integrate SPARKE into several popular diffusion pipelines and demonstrate improved diversity without additional inference overhead.\n\n---\n\n## Supported Pipelines\n\nThe following `diffusers` pipelines have been extended with SPARKE guidance:\n\n| Pipeline Type                             | Implementation                                    |\n|------------------------------------------|---------------------------------------------------|\n| Stable Diffusion v1.5                    | `SPARKEGuidedStableDiffusionPipeline`             |\n| Stable Diffusion v2.1                    | `SPARKEGuidedStableDiffusionPipeline`             |\n| Stable Diffusion XL                      | `SPARKEGuidedStableDiffusionXLPipeline`           |\n| ControlNet (SD v1.5 + OpenPose)          | `SPARKEGuidedStableDiffusionControlNetPipeline`   |\n| ControlNet (SDXL + OpenPose)             | `SPARKEGuidedStableDiffusionXLControlNetPipeline` |\n| PixArt-Sigma (XL)                        | `SPARKEGuidedPixArtSigmaPipeline`                 |\n\nEach pipeline supports both entropy-based and kernel-based guidance (e.g., Vendi, RKE, Conditional RKE) in a prompt-aware and scalable fashion.\n\n---\n\n## Installation\n\n1. Clone this repository:\n```bash\ngit clone https://github.com/mjalali/sparke-diffusers.git\ncd sparke-diffusers/sparke_diffusers\npip install -r requirements.txt\n```\n\n## Usage\n\nYou can directly import and use the SPARKE-enabled pipelines:\n\n```python\n\npipe = get_diffusion_pipeline(name='sdxl')\n\nimage = pipe(\n    prompt=\"a photorealistic portrait of a man with freckles\",\n    guidance_scale=7.5,\n    criteria='vscore_clip',\n    algorithm='cond-rke',\n    criteria_guidance_scale=0.4,\n    num_inference_steps=50,\n    kernel='gaussian',\n    sigma_image=0.8,\n    sigma_text=0.35,\n    guidance_freq=10,\n    use_latents_for_guidance=True,\n    regularize=False,\n    regions_list=['face'],\n).images[0]\n\nimage.save(\"output.jpg\")\n```\n\n## Bibtex Citation\nTo cite this work, please use the following BibTeX entries:\n\nSPARKE Diversity Guidance:\n```bibtex\n@article{jalali2025sparke,\n    author = {Mohammad Jalali and Haoyu Lei and Amin Gohari and Farzan Farnia},\n    title = {SPARKE: Scalable Prompt-Aware Diversity Guidance in Diffusion Models via RKE Score},\n    journal = {arXiv preprint arXiv:2506.10173},\n    year = {2025},\n    url = {https://arxiv.org/abs/2506.10173},\n}\n```\n\nRKE Score:\n```bibtex\n@inproceedings{jalali2023rke,\n    author = {Jalali, Mohammad and Li, Cheuk Ting and Farnia, Farzan},\n    booktitle = {Advances in Neural Information Processing Systems},\n    pages = {9931--9943},\n    title = {An Information-Theoretic Evaluation of Generative Models in Learning Multi-modal Distributions},\n    url = {https://openreview.net/forum?id=PdZhf6PiAb},\n    volume = {36},\n    year = {2023}\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjalali%2Fsparke-diffusers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjalali%2Fsparke-diffusers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjalali%2Fsparke-diffusers/lists"}