Enhance Your Images with Super Resolution using OpenCV and Python Deep Learning

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back guys this is Ashwin here in this video we are going to see how to use super resolution for low quality images so the objective of the project is to enhance or increase the resolution of low quality images let's say if we have a resolution of uh one cross one we can enhance the uh resolution by three to four times or even eight times without losing much of the quality so we will compare with the traditional method and also with deep learning trained uh model so for this thing I am going to use opencv with deep learning modules so for this complete setup you have to use opencv contract and and all the installation process with the coda even if you don't have Coda at least that opencv contrib and all the necessary libraries that are needed to check that installation process uh click on the right top corner of this video I can I already explained all the steps in detail so after watching that video just come back here and we will start this project now first let's import the modules [Applause] import modules so I will import opencv2 and from CV to import DNN super Russ so this is that opencv contract file uh has so all the necessary supporting modules will be there if you already installed it means so it won't show any errors for you and after this we will initialize the uh super resolution object initialize super resolution object I will say Sr equals DNN superus Dot DNN super simplementation create now that is done we will read the model so for this thing you have to download the uh model as well so maybe I can just provide you the links here links to download s so the first link is uh so this is the edsr tensorflow so this is somewhat uh best model and this is one of the largest model as well I already downloaded this edsr model so I'll just copy this link address and paste it here so you can just directly go for this models and another one is uh lab srn so this model can enhance your resolution but by 8X so I also have this model so we are going to like experiment with this two models you can also download this just copy this link address and I just uh paste it here now I'll just read the models so I'll just mention the path I have edsr wait okay I have this Forex model that I already downloaded now Sr Dot read model read model of path now this will just read the model and after that uh set the model and uh scale Sr Dot set model of how to mention the model name so here it is edsr edsr and the scale that how much you want to like enhance so this is like I can enhance up to four so I'll just specify it as four now this is done so after initializing a if you have coda if you have Coda support that means if you have Nvidia GPU and the installation process is already done you can set this so this is like completely optional or else it will just use the CPU so Sr Dot set preferable backend CV2 Dot DNN Dot DNN back encoder again Sr Dot set preferable Target same CV2 dot DNN DNN Target coda okay now this is done just run this now we will write few things first we will load the image load the image so image equals CV2 Dot I am read of I have a test image in this same folder so I have this test image now I will run this now upsample the image so we already loaded everything with this object so result equals or we can just say it as upscaled equals s r dot of sample of the image so this will have the up sample upscaled image now after that I'll just save the image save the upscaled image now CV2 dot I am right of upscaled upscale dot PNG and I will pass the upscaled variable so here it will store the upscaled image so upscale test dot PNG so this will be good run this only for initial time it will take some time just to like move around the files and after that it will run quickly so for now we are just loading the image for upscaling purpose if you have a video means you can also like iterate through the images in the video and do the upscaling and you can write that video as well so everything is possible if you have GPU support like this means the processing will be much faster now that is done let's compare the image so this is for the upscaling process before that traditional method traditional method that will be like by cubic by cubic so I will get the by cubic as well so by cubic equals CV2 Dot resize of the image and we have to pass the dimension so I already have this dimension in this upscaled maybe I can just do it next step so if you already know the resolution means it's not a issue if you don't uh have the resolution you I'm just taking the resolution from the upskilled so it will just match so upscaled Dot shape of 1 and uh upscaled dot shape of 0 and after that interpolation okay it's not suggesting me anything interpolation equals CV2 Dot enter cubic okay we will also write this save the image now CV2 Dot I am right off by cubic test dot PNG and pass the by cubic variable okay now run this let's compare both these things now so this is the folder I was in and this is the test image I'll just open this now you can see the resolution it is like very small and I can also show you with the file info now you can see it is uh okay this is not this is upscale test now this is the original file 232 cross 155 and if you this is the upscaled one 926 in Cross 620 you can see the difference we have like enhanced this by like uh four times you can also see the difference in uh size so this is like a significant difference and the pixel density is also increased and we didn't lose that much of a quality here let's also see the bike cubic one so this is the by cubic one if you see the file info it's also like uh have like similar size but you can see the quality uh there is a difference so this is the upscaled one and this is the by cubic one so you can clearly see the difference how the bicubic one is uh differing so you can clearly see the uh some kind of like distortions or all over the image it's not at all clear but on the other hand uh the super resolution model uh done a great job you can clearly see the enhancement and uh even if you zoom it I cannot see like any distortions in the image so this is the difference between like traditional and deep learning methods now that we have done the comparison Let's uh try with another module that is like 8x so I'll just comment this path instead of this path I'll just uh have particles lab Sr and 8x and I'll also comment this or I can have it as like a separate uh file itself srn this is edsr okay I'll just copy everything and paste it here now here I'll just change the model name to lab Sr and 8x and here also I have to change it to lap srn and for the scaling I will just mention it as 8. so I will just do the same thing lab srn and this is the by cubic test with the 8x so we can see a comparison just run everything okay now this is like much quicker than uh before and this is also like a smaller module but uh still it's giving like 8X enhancement now let's uh compare the differences again starting with the original image so this is the original now let's see the 8X image so this is the 8X resolution if you see the original you can clearly see the difference between the resolution and let's also see the file info so 232 cross 155 and here if you see the file info it's one eight five six cross one two four zero and you can clearly see the size is also increased and again I can see like much of a difference with this solution let's see the bicubic output by cubic 8x again you could see a clear difference between these things if I have like a side by side comparison between the by cubic one and the uh super resolution uh model there is a clear Distortion but here with the 8X uh there is like minor Distortion but uh it is really acceptable if you just uh go for like 4X or 5x it is pretty reasonable like from 232 cross 155 enhancing up to this uh resolution this is like crazy uh output so compared to the traditional method method I am always like preferring uh this deep learning one let me know what you think about this uh in the comments so that's pretty much it guys so these are the two models I just compared and apart from that we have like few more modules that are open source you can check on that uh you can check these on the internet but the first model that I have so showed edsr showed a good result with 4X resolution so that is like a best model you could use uh that's pretty much it guys if you have any queries regarding this video please leave a comment below I'll definitely answer that and if you like this video hit the like button and don't forget to subscribe the channel for more videos like this see you guys in the next video
Info
Channel: Hackers Realm
Views: 13,060
Rating: undefined out of 5
Keywords: super resolution with opencv, upscale your images using deep super resolution, super resolution, machine learning, image processing, how to perform super resolution using deep learning, how to perform super resolution using opencv, opencv cuda, upscale image using ai, increase resolution of photo, super resolution opencv tutorial, super resolution image processing, hackers realm, tutorial, image upscaling, computer vision, python, artificial intelligence, neural network, opencv
Id: -LqHr5V67C4
Channel Id: undefined
Length: 15min 44sec (944 seconds)
Published: Thu Mar 02 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.