{"id":5392,"date":"2026-03-10T20:35:49","date_gmt":"2026-03-11T00:35:49","guid":{"rendered":"https:\/\/dft.wiki\/?p=5392"},"modified":"2026-03-10T20:43:13","modified_gmt":"2026-03-11T00:43:13","slug":"ai-image-transformation-upscaling-enhancing-extending","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=5392","title":{"rendered":"AI Image Transformation &#8211; Upscaling \/ Enhancing \/ Extending"},"content":{"rendered":"<p><strong>UPSCALING<\/strong><\/p>\n<p>Upscaling models are specialized architectures designed to increase image resolution by a specific factor (e.g., 2x, 4x, or 8x).<\/p>\n<p>Unlike standard resizing, these models use a generative pipeline to &#8220;fill in&#8221; missing details, producing a sharp, high-resolution result from a low-resolution input.<\/p>\n<pre>from PIL import Image\r\nfrom diffusers import StableDiffusionUpscalePipeline\r\n\r\npipe = StableDiffusionUpscalePipeline.from_pretrained(\r\n    \"<strong>stabilityai\/stable-diffusion-x4-upscaler<\/strong>\",\r\n)\r\n\r\nresult = pipe(\r\n    prompt=\"<strong>high quality, detailed, sharp focus.<\/strong>\",\r\n    image=Image.open(\"<strong>cat.png<\/strong>\").convert(\"RGB\"),\r\n    guidance_scale=7.5,\r\n).images[0]\r\n\r\nresult.save(\"<strong>output.png<\/strong>\")<\/pre>\n<p>For comparison, here is a standard bilinear expansion (lossy\/blurry) at 4x scale:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5395\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/cat_stretched.png\" alt=\"\" width=\"1024\" height=\"1024\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/cat_stretched.png 1024w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/cat_stretched-300x300.png 300w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/cat_stretched-150x150.png 150w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/cat_stretched-768x768.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>And here is the same image processed via LLM Upscaling (generative refinement):<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5394\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/cat_upscaled.png\" alt=\"\" width=\"1024\" height=\"1024\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/cat_upscaled.png 1024w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/cat_upscaled-300x300.png 300w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/cat_upscaled-150x150.png 150w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/cat_upscaled-768x768.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>For more details and reference, see my own code used to generate the images above at <strong>Upscaling<\/strong> [<a href=\"https:\/\/github.com\/davift\/Upscaling\">Link<\/a>].<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5400\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/Screenshot_2026-03-10_20-14-08.png\" alt=\"\" width=\"974\" height=\"644\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/Screenshot_2026-03-10_20-14-08.png 974w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/Screenshot_2026-03-10_20-14-08-300x198.png 300w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/Screenshot_2026-03-10_20-14-08-768x508.png 768w\" sizes=\"auto, (max-width: 974px) 100vw, 974px\" \/><\/p>\n<hr \/>\n<p><strong>ENHANCING<\/strong><\/p>\n<p>Enhancing focuses on improving clarity and sharpness without necessarily changing the image dimensions. A common workflow involves upscaling an image to capture detail and then downscaling it back to the original size.<\/p>\n<p>In the example below, we use a Convolutional Neural Network (CNN) rather than a Diffusion model. This method is often more mathematically loyal to the original colors and structures than generative alternatives.<\/p>\n<pre>from super_image import EdsrModel, ImageLoader\r\nfrom PIL import Image\r\n\r\nimage = Image.open('cat.png')\r\n\r\nmodel = EdsrModel.from_pretrained(\r\n    'eugenesiow\/edsr-base',\r\n    scale=2\r\n)\r\n\r\ninputs = ImageLoader.load_image(image)\r\npreds = model(inputs)\r\n\r\nImageLoader.save_image(preds, 'output.png')<\/pre>\n<hr \/>\n<p><strong>EXTENDING<\/strong><\/p>\n<p>Extending is a variation of Outpainting. It uses a mask to guide the AI in generating new pixels beyond the original boundaries, effectively &#8220;growing&#8221; the canvas while maintaining stylistic consistency.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5402\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/outpainting.png\" alt=\"\" width=\"768\" height=\"256\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/outpainting.png 768w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2026\/03\/outpainting-300x100.png 300w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/p>\n<p>For a deeper dive and code samples, see the post <strong>Inpainting \/ Outpainting<\/strong> [<a href=\"https:\/\/dft.wiki\/?p=5380\">Link<\/a>].<\/p>\n","protected":false},"excerpt":{"rendered":"<p>UPSCALING Upscaling models are specialized architectures designed to increase image resolution by a specific factor [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-5392","post","type-post","status-publish","format-standard","hentry","category-ai"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/5392","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5392"}],"version-history":[{"count":6,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/5392\/revisions"}],"predecessor-version":[{"id":5405,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/5392\/revisions\/5405"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5392"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5392"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}