{"id":22675633,"url":"https://github.com/zentrocdot/lazyimageupscaler","last_synced_at":"2026-02-14T13:02:23.173Z","repository":{"id":262441982,"uuid":"887248536","full_name":"zentrocdot/LazyImageUpscaler","owner":"zentrocdot","description":"LazyUpscalerGui","archived":false,"fork":false,"pushed_at":"2024-12-07T11:45:40.000Z","size":9833,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-04T13:43:32.727Z","etag":null,"topics":["ai","artificial-intelligence","gradio","image","images","opencv","pil","python3","skimage","stable-diffusion","upscale","upscaler"],"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/zentrocdot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2024-11-12T12:25:12.000Z","updated_at":"2025-01-02T01:52:07.000Z","dependencies_parsed_at":"2024-12-03T05:19:06.711Z","dependency_job_id":"dccf3111-285d-455a-9bb9-f0e7f34e0b60","html_url":"https://github.com/zentrocdot/LazyImageUpscaler","commit_stats":null,"previous_names":["zentrocdot/lazyupscalergui","zentrocdot/lazyimageupscaler"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zentrocdot%2FLazyImageUpscaler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zentrocdot%2FLazyImageUpscaler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zentrocdot%2FLazyImageUpscaler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zentrocdot%2FLazyImageUpscaler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zentrocdot","download_url":"https://codeload.github.com/zentrocdot/LazyImageUpscaler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246187218,"owners_count":20737459,"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":["ai","artificial-intelligence","gradio","image","images","opencv","pil","python3","skimage","stable-diffusion","upscale","upscaler"],"created_at":"2024-12-09T17:58:08.602Z","updated_at":"2026-02-14T13:02:23.167Z","avatar_url":"https://github.com/zentrocdot.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lazy Image Upscaler [![LazyImageUpscaler - Version 0.0.1.2](https://img.shields.io/badge/LazyImageUpscaler-Version_0.0.0.1-2ea44f)]()\n\n[![Python - 3.10.14](https://img.shields.io/badge/Python-3.10.14-3399ff)](https://www.python.org/downloads/release/python-31014/)\n[![pip - 24.3.1](https://img.shields.io/badge/pip-24.3.1-cc66ff)](https://pypi.org/)\n[![Gradio - 5.6.0](https://img.shields.io/badge/Gradio-5.6.0-ff9933)](https://www.gradio.app/)\n\n\u003e [!IMPORTANT]  \n\u003e \u003cp align=\"justify\"\u003e🚧 This documentation is still under construction. The\n\u003e documentation will developed up to the point the application works as expected.\n\u003e The last version of the application needs also some fine-tuning after publishing\n\u003e here.\u003c/p\u003e\n \n\u003cb\u003e\u003cp align=\"justify\"\u003eIf you like what I present here, or if it helps you, or if it is\nuseful, you are welcome to [donate](#Donation) a small contribution. It motivates me a lot\nand speeds up my work a much.\u003c/p\u003e\u003c/b\u003e\n\n## Preface\n\n\u003cp align=\"justify\"\u003eThe \u003ci\u003eLazy Image Upscaler\u003c/i\u003e is a web user interface\nfor the upscaling of images written using the programming language Python.\nA bunch of Internet browsers can be used to run the \u003ci\u003eLazy Image Upscaler\u003c/i\u003e.\nAt the moment the \u003ci\u003eLazy Image Upscaler\u003c/i\u003e offers six possibilities to upscale\nan image.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eOne can use for the upscaling of images standard methods from\nOpenCV, PIL and scikit-image whereas scikit-image is a little bit exotic. Some \nreferences states that this is not working well. My experience is different to this\nstatement. From my point of view the results using these standard methods are\nsufficient for most cases. The fourth and fifth method are using pretrained models \nand Machine Learning approaches. To be able to work with the web user interface, at \nleast minimum one of such a pretrained model is required for the fourth and fifth \nmethod. At OpenCV one can find the links to GitHub for downloading such pretrained\nmodels for the fourth method. The fifth method is also using pretrained model which\ncan be found at Hugging Face. The last method is using Stable Diffusion. I implemented\nthe possibility to use a 2 times and 4 times latent upscaler for upscaling. And I added\na pipeline for upscaling which can use SD 1.5 together with the 2 time latent upscaler.\nBoth upscaler models as well as the SD 1.5 needs to be downloaded and installed in the\ndirectory tree of the repository.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eAs I am still making small changes to the layout, it cannot be \nsaid that the illustrations reflect the latest version of the application.\u003c/p\u003e\n\n## Motivation\n\n\u003cp align=\"justify\"\u003eI used the web user interface \u003ci\u003eEasy Diffusion\u003c/i\u003e and I am using\ncurrently the web user interface \u003ci\u003eAUTOMATIC1111\u003c/i\u003e. One integrated feature of both\nweb user interfaces  is the possibility for upscaling of images. This is a function \nthat is in general required in nowadays AI image generation. Depending on the existing\nhardware equipment, the generation of AI images with a higher resolution is limited.\nThe VRAM  memory of the GPU on the graphic card in use is the limiting factor here.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eUsing a web user interface such as \u003ci\u003eAUTOMATIC1111\u003c/i\u003e to upscale \nimages is complex, time-consuming and energy-intensive.  The time required for a\nconventional computer system should not be underestimated, even if energy consumption\nis not an issue. For example, parameters have to be selected appropriately to achieve\nthe desired result. These points raised the question of whether it is possible to scale\nup images appropriately, quickly and reliably independently of user interfaces such as\n\u003ci\u003eAUTOMATIC1111\u003c/i\u003e. This application provides an answer to this question.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eIt is important to note that it is important to preserve the original \n\u003ci\u003eExif metadata\u003c/i\u003e when upscaling. This is not possible by default with \u003ci\u003eAUTOMATIC1111\n\u003c/i\u003e.\u003c/p\u003e\n\n\u003e [!NOTE]  \n\u003e \u003cp align=\"justify\"\u003eI assume in all descriptions that a computer system with\n\u003e \u003ci\u003eLinux\u003c/i\u003e as operating system is used. Basic knowledge of installing software\n\u003e on such a computer system is a prerequisite, as is the use of terminal emulators.\u003c/p\u003e\n\n## Introduction\n\n\u003cp align=\"justify\"\u003eThe Lazy Image Upscaler offers the possibility to upscale images.\nBase don the fact that the application is intendet for use with AI generated images\nthe upscaling factor is an integer. Floating point numbers cannot be used for upscaling.  \n\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eThe tabs of the web UI are arranged according to logic of the\nimplemented methods for upscaling (see Figure 1):\u003c/p\u003e\n\n* Tab 1 to Tab 3\n  + Standard methods (numerical interpolation methods) on base of OpenCV, PIL and scikit-image\n* Tab 4 to Tab 5 \n  + Methods using pretrained models from Machine Learning on base of OpenCV and super-image\n* Tab 6 \n  + Methods based on a Stable Diffusion model and Stable Diffusion upscaler models\n\n## Brief Introduction of the State of the Art\n\n\u003cp align=\"justify\"\u003eGraphical software tools like \u003ci\u003eRawTherapee\u003c/i\u003e and \n\u003ci\u003eGIMP\u003c/i\u003e can be used to upscale images. During some tests I carried out,\nI noticed that the images become sometimes somewhat blurred when they are\nupscaled. However, one can only recognise this if one make a direct comparison\nwith the original image.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eAnother way for the upscaling of image is using Artificial\nInteligence. A distinction can be made between two approaches. Direct use of\npretrained models from machine learning. It is also possible to use special\ndiffusion models such as the Stable Diffusion models for upscaling.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eEvery programming language has its own way to handle\ndownscaling or upscaling of images. In the context of this application, I will\nlimit myself to the possibilities offered by \u003ci\u003eBash\u003c/i\u003e in combination with \n\u003ci\u003ePython\u003c/i\u003e.\u003c/p\u003e\n\n## Presumption\n\n\u003cp align=\"justify\"\u003eUse a computer system with a Linux version as operating system\nwhich is state of the art. Install Python 3.10 or higher if you want to use the\nLazy Image Upscaler. Some third-party modules are also required. Prtrained models \nas well as diffusion models can be installed later.\u003c/p\u003e\n\n\u003e [!Note]  \n\u003e \u003cp align=\"justify\"\u003eThe installed Python version must bei 3.10 or higher.\n\u003e Otherwise the application will not working. The in the code used Match\n\u003e Case statement was introduced in Python 3.10.\u003c/p\u003e\n\n## Installation of The Web UI\n\n\u003cp align=\"justify\"\u003eClone the repository to a local location of of your choice.\nTherefore move to the locoation of your choice. Then run the following command:\u003c/p\u003e\n\n```bash\ngit clone https://github.com/zentrocdot/LazyImageUpscaler.git\n```\n\u003cp align=\"justify\"\u003eAfterwards you are ready to use the application.\nAs alternative you can also download the zip-file with the repository.\u003c/p\u003e\n\n```bash\nLazyImageUpscaler-main.zip\n```\n\n\u003cp align=\"justify\"\u003eExtract the zip-file to a location of your choice. Preserve\nthe directory structure. Then it is propsed to rename the main directory which is\u003c/p\u003e\n\n```bash\nLazyImageUpscaler-main\n```\nto\n\n```bash\nLazyImageUpscaler\n```\n\n\u003cp align=\"justify\"\u003eIn both cases you are ready to use the application.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eThe base modules will work out of the box after installation.\nThe modules which are using pretrained models and the diffusion models will work\nafter download of these models. How to do this is described later.\u003c/p\u003e\n\n## Installation of the Required Python Dependencies\n\n\u003cp align=\"justify\"\u003eFollowing Python requirements have to be fulfilled,\nthat the Lazy Image upscaler is working:\u003c/p\u003e\n\n* gradio\n* numpy\n* PIL\n* opencv\n* skimage\n* piexif\n* SSIM_PIL\n* super_image\n* diffusers\n* torch\n\n\u003cp align=\"justify\"\u003eInstall the Python dependencies using pip (pip3). Do not\ninstall the modules as sudo.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eFirst update pip. It could be that you have to update \npip also in between.\u003c/p\u003e\n\n```bash\npip3 install --upgrade pip\n```\n\u003cp align=\"justify\"\u003eAfterwards you can install most of the dependencies.\u003c/p\u003e\n\n```bash\npip3 install gradio\npip3 install opencv-contrib-python\npip3 install numpy\npip3 install pillow\npip3 install piexif\npip3 install SSIM_PIL\npip3 install diffusers\npip3 install torch\n```\n\n\u003cp align=\"justify\"\u003eFor scikit-image you have to perform following steps.\u003c/p\u003e\n\n```bash\n# Update pip\npython -m pip install -U pip\n# Install scikit-image\npython -m pip install -U scikit-image\n```\n\n\u003cp align=\"justify\"\u003eEverything will be installed to a local location,\nwhich ma look like:\u003c/p\u003e\n\n\u003ccode\u003e./.local/lib/python3.10/site-packages\u003c/code\u003e \n\n\u003cp align=\"justify\"\u003eThe local installation can be found in the hidden\ndirectory \u003ccode\u003e.local\u003c/code\u003e in the user's main directory. Changes\nhere may result in problems while running the application.\u003c/p\u003e\n\n\u003e [!TIP]  \n\u003e \u003cp align=\"justify\"\u003eIf you do not want to install \u003ci\u003etorch\u003c/i\u003e or\n\u003e \u003ci\u003ediffusers\u003c/i\u003e, disable super-image and Stable Diffusion in the\n\u003e config file.\u003c/p\u003e\n\n## Start\n\n\u003cp align=\"justify\"\u003eUse \u003ccode\u003estart_webui.bash\u003c/code\u003e in the main directory\nto start the local server. If there is a problem one can move into the\nsubdirectory scripts. From there \u003ccode\u003elazy_image_upscaler.py\u003c/code\u003e can\nbe started.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eOpen a webbrowser and open localhost on\u003c/p\u003e\n\n\u003cpre\u003ehttp://127.0.0.1:7865\u003c/pre\u003e\n\n\u003cp align=\"justify\"\u003eIf everything was okay so far, the web UI starts \nin the browser window.\u003c/p\u003e\n\n## Control of the Web User Interface\n\n\u003cp align=\"justify\"\u003eYou can control the size of the visible area of\nthe window where the application is shown using keyboard shortcuts. \nZoom in can be done by \u003ckbd\u003eCTRl++\u003c/kbd\u003e and zoom out can be done by\n\u003ckbd\u003eCTRl+-\u003c/kbd\u003e.\u003c/p\u003e\n\n## Configuration of the Interface\n\n\u003cp align=\"justify\"\u003eIn the directory \u003ccode\u003e/configs\u003c/code\u003ethere is a \nconfiguration file that can be used to make various settings\u003c/p\u003e\n\n```bash\n# Lazy Image Upscaler configuration file\n# --------------------------------------\n\n# Output related parameter.\nisRawImage = False\nisExifImage = True\nisChopsImage = False\n\n# Image related parameter\nJpgQuality = 70\n\n# Tab related parameter.\nisOpencvTab = True\nisPilTab = True\nisScikitTab = True\nisSuperResolutionTab = True\nisSuperImageTab = True\nisStableDiffusionTab = True\n\n# Safetensor related parameter.\nSafeTensor = False \n\nScikit related parameter.\nAntiAliasing = False\n```\n\n\u003cp align=\"justify\"\u003eBy setting the corresponding value \nto False, individual Tabs can be deactivated in the \nuser interface.\u003c/p\u003e\n\n## Implemented Methods\n\n### Numerical Interpolation Methods\n\n#### OpenCV Interpolation Methods Related to the First Tab [![OpenCV - resize()](https://img.shields.io/badge/OpenCV-resize-cc3300)](https://docs.opencv.org/4.10.0/da/d54/group__imgproc__transform.html)\n\n\u003cp align=\"justify\"\u003eOpenCV can be used for upscaling images. The in OpenCV\nimplemented interpolation methods for resizing are:\u003c/p\u003e\n\n* INTER_NEAREST\n* INTER_LINEAR\n* INTER_AREA\n* INTER_CUBIC\n* INTER_LANCZOS4\n* INTER_LINEAR_EXACT\n* INTER_NEAREST_EXACT\n\n\u003cp align=\"justify\"\u003eThe interpolation methods can by selected over a drop-down menu.\u003c/p\u003e\n\n#### PIL Interpolation Methods Related to the Second Tab [![PIL - resize()](https://img.shields.io/badge/PIL-resize-009933)](https://pillow.readthedocs.io/en/stable/reference/Image.html)\n\n\u003cp align=\"justify\"\u003eIn addition to OpenCV, pillow or PIL can also be\nused for upscaling of images. The in pillow implemented interpolation\nmethods are:\u003c/p\u003e\n\n* NEAREST\n* BOX\n* BILINEAR\n* HAMMING\n* BICUBIC\n* LANCZOS\n\n\u003cp align=\"justify\"\u003eThe interpolation methods can by selected over a drop-down menu.\u003c/p\u003e\n\n#### skimage Interpolation Methods Related to the Second Tab [![skimage - resize](https://img.shields.io/badge/skimage-resize-ff6600)](https://scikit-image.org/docs/stable/api/skimage.transform.html#skimage.transform.resize)\n\n* NEAREST-NEIGHBOR\n* BI-LINEAR\n* BI-QUDRATIC\n* BI-CUBIC\n* BI-QUARTIC\n* BI-QUINTIC\n\n### Machine Learning Methods\n\n#### Pretrained Models (OpenCV)\n\n\u003cp align=\"justify\"\u003ePretrained models which can be used are:\u003c/p\u003e\n\n* EDSR\n* ESPCN\n* FSRCNN\n* LAPSRN\n\n#### Pretrained Models (super-image)\n\n\u003cp align=\"justify\"\u003ePredefined in the directory structure are:\u003c/p\u003e\n\n+ a2n\n+ awsrn-bam\n+ carn\n+ carn-bam\n+ drln \n+ drln-bam\n+ edsr\n+ edsr-base\n+ han\n+ mdsr\n+ mdsr-bam\n+ msrn\n+ msrn-bam\n+ pan\n+ pan-bam\n+ rcan-bam\n\n### Stable Diffusion Methods\n\n\u003cp align=\"justify\"\u003e Stable Diffusion model and Upscalers are:\u003c/p\u003e\n\n+ stable-diffusion-v1-5\n+ sd-x2-latent-upscaler\n+ stable-diffusion-x4-upscaler \n\n## Web UI\n\n\u003cp align=\"justify\"\u003eThe web UI is simple to use. One can select the pretrained model from a dropdown list. Per drag and drop or per upload the image can be loaded. Using the Upscale Image button scales the image up. Download Image downloads the image to the local storage.\u003c/p\u003e\n\n\u003ca target=\"_blank\" href=\"\"\u003e\u003cimg src=\"./images/lazyimageupscaler_00.png\" alt=\"button panel\"\u003e\u003c/a\u003e\n\u003cp\u003e\u003ci\u003eFigure 1: Web userinterface in a web browser without image\u003c/i\u003e\u003c/p\u003e\n\n\u003ca target=\"_blank\" href=\"\"\u003e\u003cimg src=\"./images/lazyimageupscaler_01.png\" alt=\"button panel\"\u003e\u003c/a\u003e\n\u003cp\u003e\u003ci\u003eFigure 2: Web userinterface in a web browser with image and upscaled image\u003c/i\u003e\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eThe web user interface is organised in several logical parts.\nThere is a header and a footer. Both are not of interest for the functioanlity of the web UI.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eDirectly below the header are buttons that provide basic functions. Below this\nare buttons for the parameters that need to be set.\n\u003c/p\u003e\n\nIn the centre there is an area on the left-hand side for entering an image and on the right-hand side for outputting an image.\n\n## Download Upscaled Images and Name Convention\n\n\u003cp align=\"justify\"\u003eWhen a download is done image names looks like:\u003c/p\u003e\n\n2024-11-13_16:32:48.931703.jpg\n\n\u003cp align=\"justify\"\u003eTo make sure that each image is unique I am using the date, the time and the remaining microseconds as filename. The formatstring is:\u003c/p\u003e\n\n\u003cpre\u003e\"%Y-%m-%d_%H:%M:%S.%f\"\u003c/pre\u003e\n\n\u003cp align=\"justify\"\u003eThe downloaded images can be found in the folder \u003ccode\u003eoutputs\u003c/code\u003e.\u003c/p\u003e\n\n## Additional Implemented Features\n\n### Implemented Features\n\n\u003cp align=\"justify\"\u003eIn addition to upscaling images, rudimentary\nimage editing is also possible with the application. These features\nare:\u003c/p\u003e\n\n+ Horizontal Flip\n+ Vertical Flip\n+ Rotate Left\n+ Rotate Right\n+ Inversion\n+ Grayscale\n+ Brightness\n+ Contrast\n+ Sharpening\n+ Smoothing\n+ Gamma\n+ Denoising\n+ Sepia Filter\n+ Color Filter\n\n### Horizontal and Vertical Flip\n\n\u003cp align=\"justify\"\u003eHorizontal Flip and Vertical Flip are mirroring an image in horizontal and vertical direction.\u003c/p\u003e\n\n### Rotate Left and Right\n\n\u003cp align=\"justify\"\u003eRotate Left and Rotate Right are rotating an image in clockwise and anti-clockwise by an angle of 90°\n\u003c/p\u003e\n\n### Inversion\n\n\u003cp align=\"justify\"\u003eInversion is inverting an image.\u003c/p\u003e\n\n### Grayscale\n\n\u003cp align=\"justify\"\u003eGrayscale creates an image in grayscale from the original.\u003c/p\u003e\n\n### Brightness\n\n\u003cp align=\"justify\"\u003eto-do ...\u003c/p\u003e\n### Contrast\n\n\u003cp align=\"justify\"\u003eto-do ...\u003c/p\u003e\n\n### Sharpening\n\n\u003cp align=\"justify\"\u003eto-do ...\u003c/p\u003e\n\n### Smoothing\n\n\u003cp align=\"justify\"\u003eto-do ...\u003c/p\u003e\n\n### Gamma\n\n\u003cp align=\"justify\"\u003eGamma is a classical Gamma correction.\u003c/p\u003e\n\n### Denoising\n\n\u003cp align=\"justify\"\u003eto-do ...\u003c/p\u003e\n \n### Sepia Filter\n\n\u003cp align=\"justify\"\u003eThe sepia filter looks like:\u003c/p\u003e\n\n\u003ccode\u003e\n    sepia_matrix = [[0.393, 0.769, 0.189],\n                    [0.349, 0.686, 0.168],\n                    [0.272, 0.534, 0.131]]\n\n    correct_matrix = [[0.607, -0.769, -0.189],\n                      [-0.349, 0.314, -0.168],\n                      [-0.349, -0.534, 0.869]]\n\u003c/code\u003e\n\n\u003ccode\u003e sepia_filter = sepia_matrix + scalar * correct_matrix \u003c/code\u003e\n\n\u003cp align=\"justify\"\u003eValid values are in a range [0,1]\u003c/p\u003e\n\n### Color Filter\n\n\u003cp align=\"justify\"\u003eThe color filter is using a HSV color model.\nHSV is the abbreviation for Hue-Saturation-Value. This color model \nis different to the well known RGB or BGR color which is often used. \nmodels. The HSV color model is using Hue, Saturation and Value for\nthe description of the colors as the abbreviation states.\u003c/p\u003e \n \n\u003cp align=\"justify\"\u003eTo use the color filter one needs some parameters.\nThese parameters/values are:\u003c/p\u003e\n\n- Hue\n- Saturation\n- Value\n\n\u003cp align=\"justify\"\u003eBy default this vaules are set to:\u003c/p\u003e\n\n\u003ccode\u003e(0.75,1.5,0.5)\u003c/code\u003e\n\n\u003cp align=\"justify\"\u003eThe values have to be given as a tuple (triple).\nIf not no image is modified and a warning is shown.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eSimply spoken, the Color filter is able, to modify or\nshift the colors. The colors range from red (0) to magenta (1). To check this out use:\u003c/p\u003e\n\n\u003ccode\u003e(0.5,1,1)\u003c/code\u003e\n\n\u003cp align=\"justify\"\u003eIf Saturation is 1 and Value is also one, the color is shifted to green/cyan value.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eThe following values can be taken as a guide.\u003c/p\u003e\n\n* Red 0.0 - 0.17\n* Yellow 0.17 - 0.33\n* Green 0.33 - 0.5\n* Cyan 0.5 - 0.67\n* blue 0.67 - 0.83\n* Magenta 0.83 - 1.0\n* 1.0 (image colors remains unchanged)\n\n\u003cp align=\"justify\"\u003eValues outside the interval [0,1] will lead to colour distortion and false colours\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eA value for the Saturation 0f 0.0 will give a grayscale image.\u003c/p\u003e\n\n\u003ccode\u003e(1,0,1)\u003c/code\u003e\n\n\u003cp align=\"justify\"\u003eA value for the Value 0f 0.0 will give a pure black image.\u003c/p\u003e\n\n\u003ccode\u003e(1,1,0)\u003c/code\u003e\n\n\u003cp align=\"justify\"\u003eValues outside the interval [0,1] will lead to colour distortion and false colours for Saturation and Value.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eOther color models next to HSV e.g. are:\u003c/p\u003e\n\n- RGB (red, green, blue) \n- BGR (blue, green, red)\n- CMYK (cyan, magenta, yellow, black)\n- HSL (hue, saturation, lightness)\n- YIQ (luminance, in-phase, quadrature)\n\n### Comments on the Special Features\n\n#### Horizontal and Vertical Flip\n\n\u003cp align=\"justify\"\u003eThe horizontal and vertical flip of an image goes hand in hand with a loss of quality.\u003c/p\u003e\n\n## Test Environment\n\n\u003cp align=\"justify\"\u003eI developed and tested the Python script with following specification:\u003c/p\u003e\n\n* Linux Mint 21.3 (Virginia)\n* Python 3.10.14\n* OpenCV 4.10.0\n* PIL 11.0.0\n* Gradio 5.6.0\n* Torch 2.4.1+cu121\n* Numpy  2.1.3\n* Chromium Browser, Firefox and Google Chrome\n* Monitor with a resolution of 1366 x 768 pixel\n\n## Time Consumption\n\nThe numerical approaches are the fastest. The AI approach is the one which takes the most time.\n\n## Power consumption\n\nThe numerical approaches use the CPU and not the GPU, so this approach saves energy. Machine Learning\nand AI use the GPU extensivly and have a high power consumption.\n\n## Limitations\n\n\u003cp align=\"justify\"\u003eIn the Machine Learning Tabs and in the AI Tab there are input images \nlarger than 512 x 512 pixel problematic.\u003c/p\u003e\n\n## Known Problems\n\n\u003cp align=\"justify\"\u003eThe critical parts of the software are the parts that use the GPU. In this\nsense, three upscaling approaches are critical. Two approaches are using pretrained models from\nMachine Learning and one is the well know AI approach.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eCommon errors if on talks about the GPU usages are.\u003c/p\u003e\n\n* RuntimeError\n* OutOfMemorError \n\n## Super Image [![super-image - pypi](https://img.shields.io/badge/super--image-pypi-5dade2)](https://pypi.org/project/super-image/)\n\n\u003cp align=\"justify\"\u003eto-do ....\u003c/p\u003e \n\n## Super Resolution [![Super Resolution - pypi](https://img.shields.io/badge/Super_Resolution-pypi-5dade2)](https://learnopencv.com/super-resolution-in-opencv/)\n\n\u003cp align=\"justify\"\u003eto-do ....\u003c/p\u003e \n\n## Stable Diffusion Upscaler Model\n\n\u003e [!IMPORTANT]\n\u003e Execute only one instance of Stable Diffusion on the GPU. Otherwise upscaling will fail.\n\n### Implemented Approaches\n\n\u003ca target=\"_blank\" href=\"\"\u003e\u003cimg style=\"width:646px;\" src=\"./images/pipe0.png\" alt=\"button panel\"\u003e\u003c/a\u003e\n\u003cp\u003e\u003ci\u003eFigure 2: Web userinterface in a web browser\u003c/i\u003e\u003c/p\u003e\n\n\n\u003ca target=\"_blank\" href=\"\"\u003e\u003cimg style=\"width:500px;\" src=\"./images/pipe1.png\" alt=\"button panel\"\u003e\u003c/a\u003e\n\u003cp\u003e\u003ci\u003eFigure 3: Web userinterface in a web browser\u003c/i\u003e\u003c/p\u003e\n\n## Pretrained Model Installation\n\n#### stable-diffusion-x4-upscaler\n\n\u003cp align=\"justify\"\u003eMove to directory LazyImageUpscaler/stabilityai. Perform following steps.\u003c/p\u003e \n\n```bash\n# Make sure you have git-lfs installed (https://git-lfs.com).\ngit lfs install\n```\n\n```bash\n# Clone the repository.\ngit clone https://huggingface.co/stabilityai/stable-diffusion-x4-upscaler\n```\n\n```bash\n# If you want to clone without large files - just their pointers.\nGIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/stabilityai/stable-diffusion-x4-upscaler\n```\n\n#### sd-x2-latent-upscaler\n\n\u003cp align=\"justify\"\u003eMove to directory LazyImageUpscaler/stabilityai. Perform following steps.\u003c/p\u003e \n\n```bash\n# Make sure you have git-lfs installed (https://git-lfs.com).\ngit lfs install\n```\n\n```bash\n# Clone the repository.\ngit clone https://huggingface.co/stabilityai/sd-x2-latent-upscaler\n```\n\n```bash\n# If you want to clone without large files - just their pointers.\nGIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/stabilityai/sd-x2-latent-upscaler\n```\n\n#### stable-diffusion-v1-5\n\n\u003cp align=\"justify\"\u003eMove to directory LazyImageUpscaler/stabilityai. Perform following steps.\u003c/p\u003e \n\n```bash\n# Make sure you have git-lfs installed (https://git-lfs.com).\ngit lfs install\n```\n\n```bash\n# Clone the repository.\ngit clone https://huggingface.co/stabilityai/stable-diffusion-v1-5\n```\n\n```bash\n# If you want to clone without large files - just their pointers.\nGIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5\n```\n\n## Repository \u0026 Directory Structure\n\n\u003cp align=\"justify\"\u003eThe repository and directory structure of the \u003ci\u003eLazy Image Upscaler\u003c/i\u003e\nis looking as follows:\u003c/p\u003e \n\n```bash\n    └── LazyImageUpscaler\n        │    └── start_webui.bash\n        ├── scripts\n        │    └── LazyImageUpscaler.py\n        ├── configs\n        │    └── LazyImageUpscaler.config\n        ├── tools      \n        │    ├── get_edsr.py\n        │    ├── get_escpn.py\n        │    ├── get_fsrcnn.py\n        │    ├── get_lapsrn.py\n        │    └── remove-metadata.bash \n        ├── test-images\n        │    ├── vulture.jpg\n        │    ⫶\n        │    └── shedevil.jpg \n        ├── outputs\n        ├── super-resolution\n        │     ├── EDSR_x2.pb\n        │     ├── EDSR_x4.pb  \n        │     ├── ESPCN_x2.pb\n        │     ├── ESPCN_x4.pb\n        │     ├── FSRCNN_x2.pb\n        │     ├── FSRCNN_x4.pb\n        │     ├── LapSRN_x2.pb\n        │     └── LapSRN_x4.pb\n        ├── super-image\n        │    ├── carn\n        │         ├── pytorch_model_2x.pt\n        │         └── pytorch_model_4x.pt\n        │    ├── edsr\n        │         ├── pytorch_model_2x.pt\n        │         └── pytorch_model_4x.pt\n        │    └── pan\n        │         ├── pytorch_model_2x.pt\n        │         └── pytorch_model_4x.pt\n        └── stabilityai\n             ├── stable-diffusion-x4-upscaler\n             ├── sd-x2-latent-upscaler\n             └── stable-diffusion-v1-5\n```\n\n\u003cp align=\"justify\"\u003eIn the folder \u003ccode\u003escripts\u003c/code\u003e there are four Python scripts,\nwhich can be used to download the models into the \u003ccode\u003eresources\u003c/code\u003e folder directly.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eUnder the main branch there are four directories. In scripts are the\n Python scripts for the web user interface. In resources there can be the .pb models be \n stored. After the installation this directory is empty. Created images are saved in outputs.\n images is the directory where documentation related images are stored.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eThe folders super-resolution, super-image and stabilityai\nare by default empty. There can be the pretrained models placed as well as the\nupscaler model.\u003c/p\u003e \n\n\u003cp align=\"justify\"\u003eThe directory tree shows how a tree looks, wenn some files\nare downloaded.\u003c/p\u003e\n\n## Troubleshooting\n\n### Web UI\n\n\u003cp align=\"justify\"\u003eIn the case of unexpected persistent problems, shut down \nthe Gradio server in the terminal window. After relaunch of the Gradio server,\nrefresh the browser window.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eIf there is a problem with the server and with the port, one can\nchange both values in the source code e.g. from\u003c/p\u003e\n\n\u003ccode\u003ewebui.launch(server_name=\"127.0.0.1\", server_port=7865)\u003c/code\u003e\n\n\u003cp align=\"justify\"\u003eto\u003c/p\u003e \n\n\u003ccode\u003ewebui.launch()\u003c/code\u003e\n\nin the script \u003ccode\u003eLazyImageUpscaler.py\u003c/code\u003e in the directory \u003ccode\u003e/scripts\u003c/code\u003e.\n\n### Super Resolution\n\nThe error message\n\n\u003ccode\u003emodule cv2.cv2 has no attribute dnn_superres\u003c/code\u003e\n\nor similiar error messages can be handeled as desribed bwlow. This error occured appeared from one moment to the next \nwithout me being able to understand why the error message occurred.\n\nFollowing solved this problem:\n\n\u003cpre\u003e\npip uninstall opencv-python\npip uninstall opencv-contrib-python\n\u003c/pre\u003e\n\nThen install latest version of OpenCV with pip3:\n\n\u003cpre\u003e\npip3 install opencv-contrib-python\n\u003c/pre\u003e\n\n### Super Image\n\n\u003cp align=\"justify\"\u003eError:\u003cp align=\"justify\"\u003e\n\n```\nImportError: cannot import name cached_download from huggingface_hub\n```\n\n\u003cp align=\"justify\"\u003ePossible Solution:\u003cp align=\"justify\"\u003e\n\n```\npip3 install huggingface_hub==0.25.00\npip3 install -U sentence-transformers\n```\n\n### Stable Diffusion\n\n\u003cp align=\"justify\"\u003eThe more I go in the direction of AI image upscaling,\nthe greater the problems with setting up the computer to get the desired \nresult.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eA big problem that I had before, independent of my\napplication, is a problem in the mismatch of version numbers of Python\nmodules. If I install one module, the other is uninstalled. So it is\ntricky until the system runs with all required modules.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eThe error messages and solution approaches reflect\nthis problem.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eError:\u003cp align=\"justify\"\u003e\n\n```\ncannot import name CpuOffload from accelerate.hooks\n```\n\n\u003cp align=\"justify\"\u003ePossible Solution:\u003cp align=\"justify\"\u003e\n\n```\npip install git+https://github.com/huggingface/accelerate.git\n```\n\n\u003cp align=\"justify\"\u003eError:\u003cp align=\"justify\"\u003e\n\n```\nAttributeError: StableDiffusionControlNetPipeline object has no attribute enable_vae_tiling\n```\n\n\u003cp align=\"justify\"\u003ePossible Solution:\u003cp align=\"justify\"\u003e\n\n```\npip install git+https://github.com/huggingface/diffusers.git@main\n```\n\n## Spin-Off\n\n\u003cp align=\"justify\"\u003eThe internal structure of the script is organised\nin such a way that the user interface can be expanded to include \nadditional methods for upscaling. In principle, the basic structure \ncan always be adopted. Essentially, fields for input parameters must\nbe adapted and the upscaler integrated as a function.\u003c/p\u003e \n\n## To-Do\n\n\u003cp align=\"justify\"\u003eSo far I integrated the possibility to compare two\nimages with respect to there quality. I need a separate independent\nPython tool, which is able to compare images from different sources \nlike \u003ci\u003eGimp\u003c/i\u003e and \u003ci\u003eRawTherapee\u003c/i\u003e with the original image. This\nis important to compare the results of my web user interface with the\nstate of the art software tools.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003eImprovement of this documentation. The web UI has\nto checked that it is more fail safe. The current work was quick and\ndirty programming. I need to sanitize and optimize the code.\u003c/p\u003e\n\n## Outlook\n\nI need to take a deepler look in how ESRGAN works. I tried to get it\nrun on the quickly, but this failed for the moment. An implementation\nin Python will give me further possibilities for upscaling. Initial\ntests show interesting results. \n\n## Free for Contributions\n\n\u003cp align=\"justify\"\u003eDue to a lack of time, I can only develop my tools\nin between. If anyone would like this tool to be developed further,\nthe best way is to support me with a donation as mentioned below. Then\nI can concentrate on these things and don't have to do anything else.\n\u003c/p\u003e\n\n## General Note\n\n\u003cp align=\"justify\"\u003eAll company names, brands, brand names and trademarks\nmentioned in this documentation belong to their respective owners. This\napplication is an independently developed software product by the author.\n\u003c/p\u003e\n\n## References\n\n[1] https://github.com/opencv/opencv_contrib/tree/master/modules/dnn_superres\n\n[2] https://github.com/Saafke/EDSR_Tensorflow/tree/master/models\n\n[3] https://github.com/fannymonori/TF-ESPCN/tree/master/export\n\n[4] https://github.com/Saafke/FSRCNN_Tensorflow/tree/master/models\n\n[5] https://github.com/fannymonori/TF-LapSRN/tree/master/export\n\n[6] https://github.com/cyc0102/opencv_super_resolution/tree/master\n\n[7] https://huggingface.co/\n\n[8] https://pypi.org/project/super-image/\n\n[9] https://huggingface.co/stabilityai/sd-x2-latent-upscaler\n\n[10] https://huggingface.co/stabilityai/stable-diffusion-x4-upscaler\n\n[11] https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5\n\n[12] https://pillow.readthedocs.io/en/stable/reference/Image.html\n\n[13] https://pillow.readthedocs.io/en/stable/handbook/concepts.html\n\n[14] https://scikit-image.org/\n\n\u003chr width=\"100%\" size=\"2\"\u003e\n\n## Donation\n\n\u003cp align=\"justify\"\u003eIf you like what I present here, or if it helps you,\nor if it is useful, you are welcome to donate a small contribution. Or\nas you might say: Every TRON counts! Many thanks in advance! :smiley:\n\u003c/p\u003e\n\n\u003cp align=\"left\"\u003e${\\textnormal{\\color{navy}Tron}}$\u003c/p\u003e\n\n```\nTQamF8Q3z63sVFWiXgn2pzpWyhkQJhRtW7\n```\n\u003cp align=\"left\"\u003e${\\textnormal{\\color{navy}Doge}}$\u003c/p\u003e\n\n```\nDMh7EXf7XbibFFsqaAetdQQ77Zb5TVCXiX\n```\n\u003cp align=\"left\"\u003e${\\textnormal{\\color{navy}Bitcoin}}$\u003c/p\u003e\n\n```\n12JsKesep3yuDpmrcXCxXu7EQJkRaAvsc5\n```\n\u003cp align=\"left\"\u003e${\\textnormal{\\color{navy}Ethereum}}$\u003c/p\u003e\n\n```\n0x31042e2F3AE241093e0387b41C6910B11d94f7ec\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzentrocdot%2Flazyimageupscaler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzentrocdot%2Flazyimageupscaler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzentrocdot%2Flazyimageupscaler/lists"}