<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Akshat Gupta on Medium]]></title>
        <description><![CDATA[Stories by Akshat Gupta on Medium]]></description>
        <link>https://medium.com/@akshat.gupta_52904?source=rss-7cdc15f234cd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_sRMWSnIYqJ9TYak</url>
            <title>Stories by Akshat Gupta on Medium</title>
            <link>https://medium.com/@akshat.gupta_52904?source=rss-7cdc15f234cd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 00:40:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akshat.gupta_52904/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[“Getting best of both world — Image quality improvements with extensive image compression”]]></title>
            <link>https://engg.glance.com/getting-best-of-both-world-image-quality-improvements-with-extensive-image-compression-825cd5604e27?source=rss-7cdc15f234cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/825cd5604e27</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Akshat Gupta]]></dc:creator>
            <pubDate>Wed, 21 Sep 2022 05:10:38 GMT</pubDate>
            <atom:updated>2022-09-21T05:10:38.462Z</atom:updated>
            <content:encoded><![CDATA[<h3>“Getting best of both world — Image quality improvements with extensive image compression”</h3><h3>Abstract</h3><p>Image super-resolution is one of the most critical areas of computer vision, where the main aim is to increase the quality of the low resolution image to high resolution image. The image quality also becomes very crucial for e-commerce transactions. It is a known fact that user experience is highly correlated to the quality of images; better the quality of the product, more enticing it becomes for the user. This goes especially for products, banners, highlights, etc.</p><p>Now, it is possible to increase the quality of image, but that comes with its cost; the output image size. Most approaches for super-resolution increases the size of the image drastically :( . Decreasing the image size is also very critical aspect as we can create a better user experience if the images load quickly and the image quality is improved. This can influence the commerce site performance and eventually improve the conversion rate.</p><h3>Problem Statement</h3><p>With these points in mind, we tried to solve for the this particular use case -<br>“How can we increase the quality of images while reducing image size”<br>In other words, we want a solution which improves the image quality (sharpness, contrast, etc.) and simultaneously reducing the final size of the image, so that it improves the user experience both ways, and also reduce the cost for storing images.</p><h3>Solution Approach</h3><p>We maintain a global database of images, where we dump all the raw images. Our high level proposed solution is to pick the images, process them (our solution, which will be explained in detail below) and then dump to the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*dh11K8CuIm-5jgxBwBmRPA.png" /><figcaption>High Level Solution Approach</figcaption></figure><p>In the proposed architecture, we do have the flexibility to tradeoff with size + quality of image in the post processing step. We have a <strong>quality hyperparameter</strong> which we can tune to increase the quality , and hence increasing the size, and vice versa.</p><h3>Technical Solution Details</h3><h4>SwinIR ( Sliding window Image Restoration Model )</h4><p>SwinIR is a deep learning model, which is the current state of the art model for image super-resolution. It provides a 4x upscaled version of the input image with better quality and contrast</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EUAfMPV7RcsuNSOnpjYsmw.png" /></figure><p>Features of this model -</p><ol><li>It combines both low level and high level features to enhance the images.</li><li>The base framework for this model is vision transformer (ViT), which divides the image into several grids, process the grids separately and then combines them for final inference.</li><li>Using skip connections to transmit the information and stabilise the training</li><li>Loss function — L1 pixel loss</li><li>Shallow Feature Extraction — simple set of convolutional (3x3) layers</li><li>HQ Reconstruction — upscaling 4x.</li></ol><h3>Memory Based Optimisations</h3><h3>Lanczos Resampling</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*GRUKbuANsIEAHKRXlS1JVA.png" /><figcaption>Lanczos Resampling</figcaption></figure><p>This is being used to resample the 4x upscaled image to the original image using this kernel. This kernel is one of the best resampling techniques used in image processing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*07Puxv_8q9MK0E8nO3CitQ.png" /><figcaption>Left — original image, Right — Lanczos Resampled Image</figcaption></figure><h3>Quality Parameter in PIL</h3><p>This parameter is used to construct the quantisation tables for compression. This decides the amount of compression required to decrease the size of the image, by trading off the quality.</p><p>As per implementation, the image quality is on a scale from 1 (worst) to 95 (best). The default is 75. Values above 95 should be avoided.PIL also has a parameter Optimise=True, which does another pass at the image to compress it even further without minimal changes in the image quality.</p><p>In our solution we are using<strong> Quality Parameter = 50, with Optimise=True</strong> to further reduce the size</p><h3>WebP Format</h3><p>WebP is <strong>a modern image format that provides superior lossless and lossy compression for images on the web.</strong> On experimentation, we found that this is the best format to save images. To give perspective, simply changing the compression type from jpeg to webp, we saw around <strong>30%</strong> size in reduction without minimal changes in the image quality.</p><h3>Results</h3><p>We conducted an experiment on close to 500 images, 400 from shop101 platform, and the others from different platforms.<br>The below results are from main images from shopify (banners + headlights)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*mgZQiSmQ6wDXWaVz18cHrA.png" /><figcaption>Shopify Images</figcaption></figure><p>The below images are left (original image with resolution and size)<br>middle (quality parameter 95) and right (quality parameter 50)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZDSxj5YXYdqJgB90JG9ejg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MG_jR88M0nigdeXiPqsqWg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RwybJqbwwKSJ_57DcZ2hXA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*72OuwSJtlS1eW5sfS-MFRw.png" /></figure><h3>Compression Tool</h3><p>We also created a tool, where you can upload bulk images and download their compressed versions. It supports jpeg, png, webp format and the quality parameter from 5 to 95 (higher being better quality) . This tool is using gradio and is deployed on GKE (Google Kubernetes Engine)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*fwuMQtIC-ddjucYFIuFK2g.png" /><figcaption>InHouse tool for image compression</figcaption></figure><h3>Impact</h3><p>We used this solution to upload the images to the shopify website and we saw a drastic drop in loading time from 3–4 seconds to <strong>0.45 seconds. </strong>We used Lighthouse tool provided by Google</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*OojStqgbUCXO7AYR9L8eGg.png" /><figcaption>Lighthouse Report</figcaption></figure><h3>Final Thoughts</h3><p>We started this use case as just a POC, where all we wanted to do first was to increase the quality, and then as soon as we started getting results, we started exploration on optimising the size as well, because we didn’t want to increase the load time to impact the user experience. And after a lot of experimentation, we got to this point where we were able to see the impact of this :). It was really a fun use-case to work with and to learn.</p><h3>Links</h3><p>SwinIR — <a href="https://arxiv.org/pdf/2108.10257.pdf">https://arxiv.org/pdf/2108.10257.pdf</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=825cd5604e27" width="1" height="1" alt=""><hr><p><a href="https://engg.glance.com/getting-best-of-both-world-image-quality-improvements-with-extensive-image-compression-825cd5604e27">“Getting best of both world — Image quality improvements with extensive image compression”</a> was originally published in <a href="https://engg.glance.com/">Glance</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>