Make VIRAL AI QR Codes with Stable Diffusion [Python Code]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
which are everybody's family it's completely viral on internet and in this video I'm going to teach you how to use completely free tools using stable diffusion on free Google collab to generate your QR code only QR code there is no limits you can generate as much as you want with the designs that you like so for example before I jump into the code and then explain you how it is happening first you need to know how to do it this is a very simple web interface which is ideally what you're going to run on top of a Google collab notebook once you run this gradu application you have to go enter the URL for which you want to create the QR code or even the text like you can have any message right now I've got this YouTube link like the channel one little coder if you have not subscribed to the channel this is the best time to do it so then you have to give the prompt The Prompt is basically the init image based on which you want to generate the QR code and at this point I've given tall skyscrapers I don't know why did I say tall skyscrapers is in every skyscraper stall now this sounds like a tongue twister anyway save the image once the image is generated the way you generate an image you scroll down and click run once the image is generated it's save the image make sure that the image Works otherwise it's very difficult make sure the image Works go back to like any QR code scanner scanner or if you have got Google Lens you can try with that otherwise if you are like me you can use this and paste it here and then you can see the scan data points to one little coder YouTube channel Let me refresh this again let me show you another example instead of tall skyscrapers let's say Sunset and just like simply Sunset nothing more than that just given Sunset and also you can give negative from the negative prompts usually if you are not familiar with stable diffusion positive prompt or the prompt is where the Generation image generation is guided towards and negative prompt is where the image generation is guided far away from so whatever you give here most likely will not appear on the final image whatever you give here is how the image is going to appear so I'm going to save this once again the QR code that we just generated save the image save it go back to the QR code image generator here or selector read the image you have got only little code quite amazing and we are going to see step by step guide of how to run this on your own Google Cloud notebook completely this is not my code the entire thing is possible due to the hugging face project and that is possible because of Dion timmer's control net model the on Timber uploaded I think yesterday probably the control net model that is used to generate all these QR code so if you are not familiar with control net control net is a type of stable diffusion modular plugin you can call it that helps you control one particular aspect of the image while retaining the properties of everything else and that is how people have been generating QR code using stable diffusion so this control net model works with stable diffusion 1.5 and this model was released like I think most likely yesterday and you have got the entire code how to do the same thing so now somebody has created a Hugging Facebook is on top of it and we are using that on our Google collab notebook the first step in everything is first open your good you Google collab notebook and then first check if you have enabled GPU if you have enabled GPU when you run nvd SMI you would see something like this what is a GPU Ram and the Tesla the GPU type if you have not enabled go click runtime select change runtime and then make sure that you have enabled GPU it should T4 which is the free GPU that you get from Google gulab should be completely fine also to make it easier I'm going to link this Google collab notebook in the YouTube description so all you have to do is go just click run all and you are fine to start with your first AI generated QR code so once you have checked that you have got GPU the next thing is we're going to clone the spaces and literally clone that project into our environment so we are going to clone that entire repository here it's not a GitHub repository it's a hugging face repo and we are going to just clone it once we have cloned it we have to enter inside that particular directory so that we can see the files and run the file that's what we are doing in this particular line of code after we have entered inside this folder this directory we are going to check what is there inside it is it the same that is available in the hugging phase spaces go click files here and see everything that is available here and see everything that is available here you've got app.pi examples readme requirements.txt go here check you've got the same set of items once you come back here now that you know that you have everything that you need and you have also entered inside that particular folder like you have entered inside that particular folder now you have to start installing every single package that is required in the requirements.txt but to quickly show you what is in the requirements.txt so you have got diffusers Library which is quite important for you to run the stable diffusion model and you've got Transformers from which the model is going to be downloaded and you have got accelerate which is for Accelerated Computing Pi torch xformers again gives you faster acceleration radio for the web application pillow for image processing QR code to generate the QR code the default QR code so once you install say saying pip install R requirements.txt all the required libraries are going to get installed after you have installed because you are running this on Google collaboro notebook you have to just set this environment variable saying in one share is equal to true that means when you run this code it will finally give you a shareable link that is valid for let's say 24 hours once you have set this then all you have to do is use the bash command the python Bank Python app.pi and that will download the model it takes a bit of time to run at the start like at least couple of minutes once it is once all the models are downloaded some example QR codes are generated once those example QR codes are generated you get the link the link the public URL that you can share with anybody in the world but you can also click and access it let me click the link and that's going to take me to the same interface that we just saw QR code AI are generated how to generate beautiful QR codes based on the control net QR code model that Dion Timber had shared so now you have to go here and then create a QR code content once again now just put YouTube or I should I should put the entire YouTube right it should go here and select dot com C slash one little coder let's let's stick to it maybe maybe we can add https so this is a link ideally it should work if you open it so this link is what we are going to embed or we can embed any content that we want as well which we can try next so at this point you are going to give an image an image that you want to start with so that's the init image is basically like the prompt that you are going to give so if you want to give an image like a QR code image you can give it here but if you do not want if you want it to be generated that's where you give the prompt here so I'm going to go give a prompt if you do not know what to give then you have certain prompts and examples here you can use this and you can play with this but if you do not want find completely fine you can say um let's say a Japanese letter and Samurai Japanese letter and Samurai maybe let's see if it happens just click run and this is again where you have you can Define the models and all these things this is always not 100 correct so always please make sure that you try your model first and the guidance scale is something that will help you play with how creative the image should be how close the image should be to the prompt so always play with guidance skill you would get different result and even with the different seed value you would get different drizzle okay as you can see this did not produce any good result for us let me just go search for something a beautiful pyramid a beautiful pyramid or the rhyme and then see if it is going to help and also make sure that you have got the right set of negative from sometimes these negative forms you don't want it to affect it like for example low quality blurry it might be possible that the image that you're creating might be low quality and blurry so you don't want the negative forms to affect it so make sure you have got the right set of negative forms do not blindly use any negative prompt I just said pyramid hopefully okay hope hopefully I've got some pyramids and it's actually funny so I've got pyramids okay QR code I'm not entirely sure if this QR code will work let's try right click save images save the image now go back to the QR Code Reader that we have got refresh the page right now we do not have anything here download the image and add it oh completely fine absolutely works fine so if you want to create a QR code let's say you know subscribe to the channel and all these kind of things this is how you can generate the QR code once again I'm going to quickly summarize the entire video we're going to use a hugging face space which indeed uses this control net model thanks to Dion Timmer Dion Timmer shared a QR code condition control net model for stable division 1.5 and there is also a support code that you can use but instead of doing directly taking this code and running I'm going to use a hugging face spaces that was created by hugging face steam probably and we are going to duplicate it or we are going to clone it into our Google collab notebook but for us to run this faster on our Google collab notebook first we need to make sure that we have got GPU that's what we are doing here if not go to runtime Click Change runtime type and then select GPU but if you are going to use my Google collab notebook you don't have to be worried because it's already configured to use GPU the next thing is clone the repository go into the particular folder QR code AR generator install the requirements.txt and make sure that you set share is equal to true for you to get the app link and then run python app.pi don't forget the bank and at this point it's going to download the model generate three examples and you're going to get the link once you click the link you reach this place where you have to enter the QR code content like whatever you want to give or if you have an optional input image you can give it and then the prompt that that is like basically what the image that you want to embed as part of the QR code negative wrongs which you do not want to see and um The Tick markers if you have got an internet image or not and then play with these parameters that will help you create different variations of the same image and finally click run if you want to generate the same QR code again you can use the seed value with the same settings you've got some examples here and that will give you the QR code save it use Google Lens or anything or share it with your friends this should ideally work in many of the cases I have like at least like until now I've tried like 10 or 20 QR codes and most of the times it has completely worked just try it with your Google Lens application it should ideally work I hope this video was helpful to you in learning how to create AI generated fancy QR codes everybody is fascinated about I'll link the Google collab notebook in the YouTube description and also the hugging face spaces where you can actually go and try it but only thing is you'll be on Queue that's like annoying and frustrating sometimes that's why I made this tutorial on running this on your Google collab completely for free let me know in the comment section what do you feel about it if it works if it doesn't work happy to hear your comments see you in another video Happy prompting
Info
Channel: 1littlecoder
Views: 7,406
Rating: undefined out of 5
Keywords: ai, machine learning, artificial intelligence
Id: ar3GrHUlNAg
Channel Id: undefined
Length: 11min 45sec (705 seconds)
Published: Fri Jun 16 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.