{"id":13477907,"url":"https://github.com/Gadersd/stable-diffusion-burn","last_synced_at":"2025-03-27T06:31:05.596Z","repository":{"id":186422462,"uuid":"674771826","full_name":"Gadersd/stable-diffusion-burn","owner":"Gadersd","description":"Stable Diffusion v1.4 ported to Rust's burn framework","archived":false,"fork":false,"pushed_at":"2024-10-05T18:20:45.000Z","size":4031,"stargazers_count":313,"open_issues_count":11,"forks_count":15,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-10-30T10:41:37.519Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/Gadersd.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":"2023-08-04T18:28:05.000Z","updated_at":"2024-10-16T01:12:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"90baa37e-e7bd-49b7-8130-160915bc86bc","html_url":"https://github.com/Gadersd/stable-diffusion-burn","commit_stats":null,"previous_names":["gadersd/stable-diffusion-burn"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gadersd%2Fstable-diffusion-burn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gadersd%2Fstable-diffusion-burn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gadersd%2Fstable-diffusion-burn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gadersd%2Fstable-diffusion-burn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gadersd","download_url":"https://codeload.github.com/Gadersd/stable-diffusion-burn/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245797374,"owners_count":20673839,"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":[],"created_at":"2024-07-31T16:01:49.567Z","updated_at":"2025-03-27T06:31:04.111Z","avatar_url":"https://github.com/Gadersd.png","language":"Rust","funding_links":[],"categories":["Rust","Summary","Frameworks","Machine Learning"],"sub_categories":[],"readme":"# Stable-Diffusion-Burn\n\nStable-Diffusion-Burn is a Rust-based project which ports the V1 stable diffusion model into the deep learning framework, Burn. This repository is licensed under the MIT Licence.\n\n## How To Use\n\n### Step 0: Install libtorch v2.4.1\n\n### Step 1: Download the Model and Set Environment Variables\n\nStart by downloading the SDv1-4 model provided on HuggingFace.\n\n```bash\nwget https://huggingface.co/Gadersd/Stable-Diffusion-Burn/resolve/main/SDv1-4.mpk\n```\n\n### Step 2: Run the Sample Binary\n\nInvoke the sample binary provided in the rust code. By default, torch is used. The WGPU backend is unstable for SD but may work well in the future as burn-wpu is optimized.\n\n```bash\n# torch (at least 6 GB VRAM, possibly less)\n# Arguments: \u003cmodel_type(burn or dump)\u003e \u003cmodel_name\u003e \u003cunconditional_guidance_scale\u003e \u003cn_diffusion_steps\u003e \u003cprompt\u003e \u003coutput_image_name\u003e [cuda, mps, cpu]\n\n# Cuda\ncargo run --release --bin sample burn SDv1-4 7.5 20 \"An ancient mossy stone.\" img cuda\n\n# Mps(Mac)\ncargo run --release --bin sample burn SDv1-4 7.5 20 \"An ancient mossy stone.\" img mps\n\n# wgpu (UNSTABLE)\n# Arguments: \u003cmodel_type(burn or dump)\u003e \u003cmodel\u003e \u003cunconditional_guidance_scale\u003e \u003cn_diffusion_steps\u003e \u003cprompt\u003e \u003coutput_image\u003e\ncargo run --release --features wgpu-backend --bin sample burn SDv1-4 7.5 20 \"An ancient mossy stone.\" img\n```\n\nThis command will generate an image according to the provided prompt, which will be saved as 'img0.png'.\n\n![An image of an ancient mossy stone](img0.png)\n\n### Optional: Extract and Convert a Fine-Tuned Model\n\nIf users are interested in using a fine-tuned version of stable diffusion, the Python scripts provided in this project can be used to transform a weight dump into a Burn model file. This does not work on Windows.\n\n```bash\n# Step into the Python directory\ncd python\n\n# Download the model, this is just the base v1.4 model as an example\nwget https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt\n\n# Install tinygrad\npip install -r requirements.txt\n\n# Extract the weights\nCPU=1 python3 dump.py sd-v1-4.ckpt\n\n# Move the extracted weight folder out\nmv params ..\n\n# Step out of the Python directory\ncd ..\n\n# Convert the weights into a usable form\ncargo run --release --bin convert params SDv1-4\n```\n\nThe binaries 'convert' and 'sample' are contained in Rust. Convert works on CPU whereas sample needs CUDA.\n\nRemember, `convert` should be used if you're planning on using the fine-tuned version of the stable diffusion. \n\n## License\n\nThis project is licensed under MIT license.\n\nWe wish you a productive time using this project. Enjoy!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGadersd%2Fstable-diffusion-burn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGadersd%2Fstable-diffusion-burn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGadersd%2Fstable-diffusion-burn/lists"}