{"id":13584970,"url":"https://github.com/pkuliyi2015/sd-webui-stablesr","last_synced_at":"2025-04-09T04:04:50.088Z","repository":{"id":167606972,"uuid":"643193835","full_name":"pkuliyi2015/sd-webui-stablesr","owner":"pkuliyi2015","description":"StableSR for Stable Diffusion WebUI - Ultra High-quality Image Upscaler","archived":false,"fork":false,"pushed_at":"2024-08-06T04:42:44.000Z","size":96,"stargazers_count":1075,"open_issues_count":37,"forks_count":56,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-02T03:02:13.111Z","etag":null,"topics":["high-fidelity","stable-diffusion","stable-diffusion-webui","stable-diffusion-webui-plugin","stablesr","super-resolution","wavelet-decomposition"],"latest_commit_sha":null,"homepage":"https://iceclear.github.io/projects/stablesr/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pkuliyi2015.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-05-20T11:49:37.000Z","updated_at":"2025-04-02T02:40:29.000Z","dependencies_parsed_at":"2024-01-07T22:19:29.982Z","dependency_job_id":"cab58b9d-37af-4c66-9224-4c7e593397a0","html_url":"https://github.com/pkuliyi2015/sd-webui-stablesr","commit_stats":null,"previous_names":["pkuliyi2015/sd-webui-stablesr"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkuliyi2015%2Fsd-webui-stablesr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkuliyi2015%2Fsd-webui-stablesr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkuliyi2015%2Fsd-webui-stablesr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkuliyi2015%2Fsd-webui-stablesr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkuliyi2015","download_url":"https://codeload.github.com/pkuliyi2015/sd-webui-stablesr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247974715,"owners_count":21026742,"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":["high-fidelity","stable-diffusion","stable-diffusion-webui","stable-diffusion-webui-plugin","stablesr","super-resolution","wavelet-decomposition"],"created_at":"2024-08-01T15:04:38.165Z","updated_at":"2025-04-09T04:04:50.070Z","avatar_url":"https://github.com/pkuliyi2015.png","language":"Python","funding_links":[],"categories":["Python","GitHub projects"],"sub_categories":[],"readme":"# StableSR for Stable Diffusion WebUI\n\nLicensed under [S-Lab License 1.0](https://github.com/IceClear/StableSR/blob/main/LICENSE.txt)\n\nEnglish｜[中文](README_CN.md)\n\n- StableSR is a competitive super-resolution method originally proposed by Jianyi Wang et al.\n- This repository is a migration of the StableSR project to the Automatic1111 WebUI.\n\nRelevant Links\n\n\u003e Click to view high-quality official examples!\n\n- [Project Page](https://iceclear.github.io/projects/stablesr/)\n- [Official Repository](https://github.com/IceClear/StableSR)\n- [Paper on arXiv](https://arxiv.org/abs/2305.07015)\n- [Paper on IJCV](https://link.springer.com/article/10.1007/s11263-024-02168-7)\n\n\u003e If you find this project useful, please give me \u0026 Jianyi Wang a star! ⭐\n\n***\n\n## Important Update\n\n- 2023.07.01: We occasionally found that **proper negative prompts can significantly enhance the details of StableSR.**\n    - We use CFG Scale=7 with the following negative prompts: 3d, cartoon, anime, sketches, (worst quality:2), (low quality:2)\n    - Click [comparison1](https://imgsli.com/MTg5MjM1) to see the significant power of negative prompts.\n    - Postive prompts are not very useful, but it also helps. You can try (masterpiece:2), (best quality:2), (realistic:2),(very clear:2)\n    - With the above prompts, we are trying our best to approach close-source project GigaGAN's quality (while ours are still worse than their demo). Click [comparison2](https://imgsli.com/MTg5MzAx/) to see our current capability on 128x128-\u003e1024x1024 upscaling.\n- 2023.06.30: We are happy to release a new SD 2.1 768 version of StableSR! (Thanks to Jianyi Wang)\n    - It produces similar amount of details, but with **significantly less artifacts** and **better color**.\n    - It supports the resolution of 768 * 768. \n- To enjoy the new model:\n    - Use the SD 2.1 768 base model. It can be download from [HuggingFace](https://huggingface.co/stabilityai/stable-diffusion-2-1)\n    - The corresponding SR Module (~400MB): [Official Resource](https://huggingface.co/Iceclear/StableSR/blob/main/webui_768v_139.ckpt), [我的百度网盘-提取码8ju9](https://pan.baidu.com/s/17on7GA2RLvVzdDnBwA0N0g?pwd=8ju9)\n    - Now you can use a larger tile size in the Tiled Diffusion (96 * 96, the same as default settings), the speed can be slightly faster.\n    - Keep other things the same.\n- Janyi Wang keeps trying to train more powerful SR modules suitable for AIGC images. These models will be tuned on SD2.1 768 or SDXL later.\n\n***\n\n## Features\n\n1. **High-fidelity detailed image upscaling**:\n    - Being very detailed while keeping the face identity of your characters.\n    - Suitable for most images (Realistic or Anime, Photography or AIGC, SD 1.5 or Midjourney images...) [Official Examples](https://iceclear.github.io/projects/stablesr/)\n2. **Less VRAM consumption**\n    - I remove the VRAM-expensive modules in the official implementation.\n    - The remaining model is much smaller than ControlNet Tile model and requires less VRAM.\n    - When combined with Tiled Diffusion \u0026 VAE, you can do 4k image super-resolution with limited VRAM (e.g., \u003c 12 GB).\n    \u003e Please be aware that sdp may lead to OOM for some unknown reasons. You may use xformers instead.\n3. **Wavelet Color Fix**\n    - The official StableSR will significantly change the color of the generated image. The problem will be even more prominent when upscaling in tiles (Have been merged into official repo).\n    - I implement a powerful post-processing technique that effectively matches the color of the upscaled image to the original. See [Wavelet Color Fix Example](https://imgsli.com/MTgwNDg2/).\n\n***\n\n## Usage\n\n### 1. Installation\n\n⚪ Method 1: Official Market\n\n- Open Automatic1111 WebUI -\u003e Click Tab \"Extensions\" -\u003e Click Tab \"Available\" -\u003e Find \"StableSR\" -\u003e Click \"Install\"\n\n⚪ Method 2: URL Install\n\n- Open Automatic1111 WebUI -\u003e Click Tab \"Extensions\" -\u003e Click Tab \"Install from URL\" -\u003e type in https://github.com/pkuliyi2015/sd-webui-stablesr.git -\u003e Click \"Install\" \n\n![installation](https://github.com/pkuliyi2015/multidiffusion-img-demo/blob/master/installation.png?raw=true)\n\n### 2. Download the main components\nWe currently has two versions. They have similar amount of details, but the 768 has less artifacts.\n#### 🆕 SD2.1 768 Version\n- You MUST use the Stable Diffusion V2.1 768 **EMA** checkpoint (~5.21GB) from StabilityAI\n    - You can download it from [HuggingFace](https://huggingface.co/stabilityai/stable-diffusion-2-1)\n    - Put into stable-diffusion-webui/models/Stable-Diffusion/\n\n- Download the extracted StableSR module\n    - [Official Resource](https://huggingface.co/Iceclear/StableSR/blob/main/webui_768v_139.ckpt)\n    - Put the StableSR module (~400MB) into your stable-diffusion-webui/extensions/sd-webui-stablesr/models/\n\n****\n#### SD2.1 512 Version (Sharper, but more artifacts)\n- You MUST use the Stable Diffusion V2.1 512 **EMA** checkpoint (~5.21GB) from StabilityAI\n    - You can download it from [HuggingFace](https://huggingface.co/stabilityai/stable-diffusion-2-1-base)\n    - Put into stable-diffusion-webui/models/Stable-Diffusion/\n\n- Download the extracted StableSR module\n    - Official resources: [HuggingFace](https://huggingface.co/Iceclear/StableSR/resolve/main/weibu_models.zip) (~1.2 G). Note that this is a zip file containing both the StableSR module and the VQVAE.\n    - My resources: \u003c[GoogleDrive](https://drive.google.com/file/d/1tWjkZQhfj07sHDR4r9Ta5Fk4iMp1t3Qw/view?usp=sharing)\u003e \u003c[百度网盘-提取码aguq](https://pan.baidu.com/s/1Nq_6ciGgKnTu0W14QcKKWg?pwd=aguq)\u003e\n    - Put the StableSR module (~400MB) into your stable-diffusion-webui/extensions/sd-webui-stablesr/models/\n\n\u003e While we use SD2.1 checkpoint, you can still upscale ANY image (even from SD1.5 or NSFW). Your image won't be censored and the output quality won't be affected.\n\n### 3. Optional components\n\n- Install [Tiled Diffusion \u0026 VAE]((https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111)) extension\n    - The original StableSR easily gets OOM for large images \u003e 512.\n    - For better quality and less VRAM usage, we recommend Tiled Diffusion \u0026 VAE.\n- Use the Official VQGAN VAE\n    - Official resources: See the link in 2.\n    - My resources: \u003c[GoogleDrive](https://drive.google.com/file/d/1ARtDMia3_CbwNsGxxGcZ5UP75W4PeIEI/view?usp=share_link)\u003e \u003c[百度网盘-提取码83u9](https://pan.baidu.com/s/1YCYmGBethR9JZ8-eypoIiQ?pwd=83u9)\u003e\n    - Put the VQVAE (~700MB) into your stable-diffusion-webui/models/VAE\n\n### 4. Extension Usage\n\n- At the top of the WebUI, select the v2-1_512-ema-pruned checkpoint you downloaded.\n- Switch to img2img tag. Find the \"Scripts\" dropdown at the bottom of the page.\n    - Select the StableSR script.\n    - Click the refresh button and select the StableSR checkpoint you have downloaded.\n    - Choose a scale factor.\n- Euler a sampler is recommended. CFG Scale=7, Steps \u003e= 20.\n    - While StableSR can work without any prompts, we recently found that negative prompts can significantly improve details. Example negative prompts: 3d, cartoon, anime, sketches, (worst quality:2), (low quality:2)\n    - Click to see [comparison] with/without pos/neg prompts(https://imgsli.com/MTg5MjM1)\n- For output image size \u003e 512, we recommend using Tiled Diffusion \u0026 VAE, otherwise, the image quality may not be ideal, and the VRAM usage will be huge. \n- Here are the official Tiled Diffusion settings:\n    - Method = Mixture of Diffusers\n        - For StableSR 768 version, you can use Latent tile size = 96, Latent tile overlap = 48\n        - For StableSR 512 version, you can use Latent tile size = 64, Latent tile overlap = 32\n    - Latent tile batch size as large as possible before Out of Memory.\n    - Upscaler MUST be None (will not upscale here; instead, upscale in StableSR).\n- The following figure shows the recommended settings for 24GB VRAM.\n    - For a 6GB device, **just change Tiled Diffusion Latent tile batch size to 1, Tiled VAE Encoder Tile Size to 1024, Decoder Tile Size to 128.**\n    - SDP attention optimization may lead to OOM. Please use xformers in that case.\n    - You DON'T need to change other settings in Tiled Diffusion \u0026 Tiled VAE unless you have a very deep understanding. **These params are almost optimal for StableSR.**\n![recommended settings](https://github.com/pkuliyi2015/multidiffusion-img-demo/blob/master/recommended_settings_24GB.jpg?raw=true)\n\n    \n\n### 5. Options Explained\n\n- What is \"Pure Noise\"?\n    - Pure Noise refers to starting from a fully random noise tensor instead of your image. **This is the default behavior in the StableSR paper.**\n    - When enabling it, the script ignores your denoising strength and gives you much more detailed images, but also changes the color \u0026 sharpness significantly\n    - When disabling it, the script starts by adding some noise to your image. The result will be not fully detailed, even if you set denoising strength = 1 (but maybe aesthetically good). See [Comparison](https://imgsli.com/MTgwMTMx).\n    - If you disable Pure Noise, we recommend denoising strength=1\n- What is \"Color Fix\"?\n    - This is to mitigate the color shift problem from StableSR and the tiling process.\n    - AdaIN simply adjusts the color statistics between the original and the outcome images. This is the official algorithm but ineffective in many cases.\n    - Wavelet decomposes the original and the outcome images into low and high frequency, and then replace the outcome image's low-frequency part (colors) with the original image's. This is very powerful for uneven color shifting. The algorithm is from GIMP and Krita, which will take several seconds for each image.\n    - When enabling color fix, the original image will also show up in your preview window, but will NOT be saved automatically.\n\n### 6. Important Notice\n\n\u003e Why my results are different from the official examples?\n\n- It is not your or our fault.\n    - This extension has the same UNet model weights as the StableSR if installed correctly. \n    - If you install the optional VQVAE, the whole model weights will be the same as the official model with fusion weights=0.\n- However, your result will be **not as good as** the official results, because:\n    - Sampler Difference: \n        - The official repo does 100 or 200 steps of legacy DDPM sampling with a custom timestep scheduler, and samples without negative prompts.\n        - However, WebUI doesn't offer such a sampler, and it must sample with negative prompts. **This is the main difference.**\n    - VQVAE Decoder Difference: \n        - The official VQVAE Decoder takes some Encoder features as input. \n        - However, in practice, I found these features are astonishingly huge for large images. (\u003e10G for 4k images even in float16!) \n        - Hence, **I removed the CFW component in VAE Decoder**. As this lead to inferior fidelity in details, I will try to add it back later as an option.\n\n***\n## License\n\nThis project is licensed under:\n\n- [S-Lab License 1.0](https://github.com/IceClear/StableSR/blob/main/LICENSE.txt).\n\n[cc-by-nc-sa]: http://creativecommons.org/licenses/by-nc-sa/4.0/\n[cc-by-nc-sa-image]: https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png\n[cc-by-nc-sa-shield]: https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg\n\n### Disclaimer\n\n- All code in this extension is for research purposes only. \n- The commercial use of the code and checkpoint is **strictly prohibited**.\n\n### Important Notice for Outcome Images\n\n- Please note that the [S-Lab License 1.0](https://github.com/IceClear/StableSR/blob/main/LICENSE.txt) prohibits the commercial use of outcome images. \n- If you wish to *speed up* his process for commercial purposes, please contact him through email: iceclearwjy@gmail.com\n\n## Citation\nIf our work is useful for your research, please consider citing:\n\n    @article{wang2024exploiting,\n      author = {Wang, Jianyi and Yue, Zongsheng and Zhou, Shangchen and Chan, Kelvin C.K. and Loy, Chen Change},\n      title = {Exploiting Diffusion Prior for Real-World Image Super-Resolution},\n      article = {International Journal of Computer Vision},\n      year = {2024}\n    }\n\n## Acknowledgments\n\nI would like to thank Jianyi Wang et al. for the original StableSR method.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkuliyi2015%2Fsd-webui-stablesr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkuliyi2015%2Fsd-webui-stablesr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkuliyi2015%2Fsd-webui-stablesr/lists"}