{"id":13561479,"url":"https://github.com/cloneofsimo/minSDXL","last_synced_at":"2025-04-03T17:31:01.610Z","repository":{"id":186871126,"uuid":"675904473","full_name":"cloneofsimo/minSDXL","owner":"cloneofsimo","description":"Huggingface-compatible SDXL Unet implementation that is readily hackable","archived":false,"fork":false,"pushed_at":"2023-08-09T12:32:28.000Z","size":5077,"stargazers_count":415,"open_issues_count":4,"forks_count":33,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-30T06:05:36.841Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/cloneofsimo.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-08-08T02:16:51.000Z","updated_at":"2025-03-29T10:28:37.000Z","dependencies_parsed_at":"2024-01-14T03:45:41.946Z","dependency_job_id":"6702c1f4-8500-4ba4-8923-d8cebbcf2b16","html_url":"https://github.com/cloneofsimo/minSDXL","commit_stats":null,"previous_names":["cloneofsimo/minsdxl"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2FminSDXL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2FminSDXL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2FminSDXL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2FminSDXL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloneofsimo","download_url":"https://codeload.github.com/cloneofsimo/minSDXL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247046829,"owners_count":20874731,"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-08-01T13:00:57.196Z","updated_at":"2025-04-03T17:30:56.601Z","avatar_url":"https://github.com/cloneofsimo.png","language":"Jupyter Notebook","funding_links":["https://www.buymeacoffee.com/simoryu"],"categories":["Jupyter Notebook"],"sub_categories":[],"readme":"# Huggingface Diffusers Compatible SDXL Unet Rewrite \n\n*Find this useful? I'm accumulating coffee until they become a A100 gpu.*\n\n\u003ca href=\"https://www.buymeacoffee.com/simoryu\" target=\"_blank\"\u003e\u003cimg src=\"https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;\" \u003e\u003c/a\u003e\n\n\n## Why do this?\n\nWhile huggingface `diffusers` library is amazing, nowdays, its `UNet2DConditionModel`'s implementation has gotten extremely big. There are various configurations, branches during initialization, and many other \"important-yet-not-related\" stuff that make it hard to understand. (I am also partly to blame this, because LoRA with AttentionProcessor logic has also gotten rather huge part of the Unet implementation.) I would argue it got bigger than one researcher can now reasonably understand and maintain, let alone extend. This will of course have pros and cons, but for many researchers, this is not ideal. (Trust me, I use diffusers all the time and still get confused by the codebase.)\n\nSince SDXL will likely be used by many researchers, I think it is very important to have concise implementations of the models, so that SDXL can be easily understood and extended.\n\n`sdxl_rewrite.py` tries to remove all the unnecessary parts of the original implementation, and tries to make it as concise as possible.\n\n## Usage\n\nSDXL Rewrite tries to be directly compatible with the original `diffusers` library. You can use it like this:\n\n```python\nfrom sdxl_rewrite import UNet2DConditionModel\nunet_new = UNet2DConditionModel().cuda().half()\n\n# Load weights from the original model\nfrom diffusers import DiffusionPipeline\n\n\npipe = DiffusionPipeline.from_pretrained(\n        \"stabilityai/stable-diffusion-xl-base-1.0\",\n        torch_dtype=torch.float16,\n        use_safetensors=True,\n        variant=\"fp16\",\n).to(\"cuda\")\n\nunet_new.load_state_dict(pipe.unet.state_dict())\n\n# use the weights\npipe.unet = unet_new\n\n```\n\nObviously in practice you would never do this. You would normaly copy this codebase and modify it to your needs, like putting adapters, loras, other modalities, etc etc.\n\nHave a look at `example.ipynb` for bit more examples to use it directly with `diffusers` library.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloneofsimo%2FminSDXL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloneofsimo%2FminSDXL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloneofsimo%2FminSDXL/lists"}