{"id":23177274,"url":"https://github.com/haoming02/sd-webui-diffusion-cg","last_synced_at":"2025-08-18T11:32:35.860Z","repository":{"id":207551381,"uuid":"718974657","full_name":"Haoming02/sd-webui-diffusion-cg","owner":"Haoming02","description":"An Extension for Automatic1111 Webui that performs color grading based on the latent tensor value range","archived":false,"fork":false,"pushed_at":"2024-05-06T07:48:11.000Z","size":4876,"stargazers_count":46,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-07T07:46:30.526Z","etag":null,"topics":["stable-diffusion-webui","stable-diffusion-webui-plugin"],"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/Haoming02.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-11-15T07:15:51.000Z","updated_at":"2024-05-06T07:48:14.000Z","dependencies_parsed_at":"2024-01-09T04:45:12.110Z","dependency_job_id":"4bf65b42-2684-404f-9db8-f01524254dbe","html_url":"https://github.com/Haoming02/sd-webui-diffusion-cg","commit_stats":null,"previous_names":["haoming02/sd-webui-diffusion-cg"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haoming02%2Fsd-webui-diffusion-cg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haoming02%2Fsd-webui-diffusion-cg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haoming02%2Fsd-webui-diffusion-cg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haoming02%2Fsd-webui-diffusion-cg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Haoming02","download_url":"https://codeload.github.com/Haoming02/sd-webui-diffusion-cg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230227307,"owners_count":18193286,"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":["stable-diffusion-webui","stable-diffusion-webui-plugin"],"created_at":"2024-12-18T06:32:35.618Z","updated_at":"2024-12-18T06:32:36.156Z","avatar_url":"https://github.com/Haoming02.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# SD Webui Diffusion Color Grading\nThis is an Extension for the [Automatic1111 Webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui), which performs *Color Grading* during the generation, producing a more **neutral** and **balanced**, but also **vibrant** and **contrasty** color.\n\n\u003e This is the fruition of the joint research between [TimothyAlexisVass](https://github.com/TimothyAlexisVass) with their findings, and me with my experience in developing [Vectorscope CC](https://github.com/Haoming02/sd-webui-vectorscope-cc)\n\n**Note:** This Extension is disabled during [ADetailer](https://github.com/Bing-su/adetailer) phase to prevent inconsistent colors\n\n## Features\n\nThis Extension comes with two main effects, **Recenter** and **Normalization**:\n\n#### Recenter\n\n\u003ch5 align=\"center\"\u003eAbstract\u003c/h5\u003e\n\n\u003cins\u003eTimothyAlexisVass\u003c/ins\u003e discovered that, the value of the latent noise Tensor often starts off-centered, and the mean of each channel tends to drift away from `0`. Therefore, I wrote a function to guide the mean back to `0`.\n\n\u003ch5 align=\"center\"\u003eEffects\u003c/h5\u003e\n\nWhen you enable the feature, the output images will not have a biased color tint, and all colors will distribute more evenly; Additionally, the brightness will be adjusted so that bright areas are not overblown and dark areas are not clipped, producing an effect similar to HDR photos.\n\n\u003ch5 align=\"center\"\u003eSamples\u003c/h5\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"examples\\rc_off.jpg\" width=384\u003e\n\u003cimg src=\"examples\\rc_on.jpg\" width=384\u003e\n\u003cbr\u003e\u003ccode\u003eOff | On\u003c/code\u003e\u003cbr\u003e\n\u003c/p\u003e\n\n#### Normalization\n\n\u003ch5 align=\"center\"\u003eAbstract\u003c/h5\u003e\n\nBy encoding images back into latent noise using VAE, \u003cins\u003eTimothyAlexisVass\u003c/ins\u003e discovered that the resulting values usually fall within a certain range, and thus theorized that if the final latent noise has a smaller value range than normal, then some precision is essentailly wasted. This gave me an idea to write a function that make the latent noise utilize the full depth.\n\n\u003ch5 align=\"center\"\u003eEffects\u003c/h5\u003e\n\nWhen you enable the feature, the latent noise will attempt to span across the full value range if possible, before getting decoded by the VAE. As a result, bright areas will get brighter and dark areas will get darker, and additional details may also be introduced in these areas.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"examples\\nml_off.jpg\" width=384\u003e\n\u003cimg src=\"examples\\nml_on.jpg\" width=384\u003e\n\u003cbr\u003e\u003ccode\u003eOff | On\u003c/code\u003e\u003cbr\u003e\n\u003c/p\u003e\n\n\u003e Both features increase the image file size when enabled, suggesting that they \"contain more informations\"\n\n#### Misc.\n\n- You can enable both features at the same time to generate some stunning images\n- This Extension supports both `SD 1.5` and `SDXL` checkpoints\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"examples\\xl_off.jpg\" width=384\u003e\n\u003cimg src=\"examples\\xl_on.jpg\" width=384\u003e\n\u003cbr\u003e\u003ccode\u003eOff | On\u003c/code\u003e\u003cbr\u003e\n\u003c/p\u003e\n\n## Settings\nIn the `Diffusion CG` section under the \u003cins\u003eStable Diffusion\u003c/ins\u003e category in the **Settings** tab, you can make either feature default to `enable`, as well as setting the Stable Diffusion architecture to start with.\n\n\u003chr\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eStructures of Stable Diffusion\u003c/summary\u003e\n\nThe `Tensor` of the latent noise has a dimention of `[batch, 4, height / 8, width / 8]`.\n\n- For **SD 1.5:** From my trial and error when developing [Vectorscope CC](https://github.com/Haoming02/sd-webui-vectorscope-cc), each of the 4 channels essentially represents the `-K`, `-M`, `C`, `Y` color for the **CMYK** color model.\n\n- For **SDXL:** According to \u003cins\u003eTimothyAlexisVass\u003c/ins\u003e's [Blogpost](https://huggingface.co/blog/TimothyAlexisVass/explaining-the-sdxl-latent-space), the first 3 channels represent the `Y'`, `-Cr`, `-Cb` color for the **Y'CbCr** color model, while the 4th channel is the pattern/structure.\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaoming02%2Fsd-webui-diffusion-cg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaoming02%2Fsd-webui-diffusion-cg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaoming02%2Fsd-webui-diffusion-cg/lists"}