Beginner’s Guide to Using a Kaggle Notebook to Start Generating AI Images for Free

I created a Kaggle notebook for using the Stable Diffusion models to generate the images. For people with technical background in programming, it’s easy to start using it. However, there are also a lot of people drawn to AI that do not have any tech experience. The purpose of this article is to get those people started on generating AI content.

The software we use is called Stable Diffusion Web UI. We will just use webui in this article to refer to the software. You need at least 30 minutes to follow the guide, or longer if you would like to experiment more on your own. It is recommended that you read the article entirely before you try. Now, if you are ready, let’s get started.

Register a Kaggle Account

You will need a free Kaggle account to use the notebook. If you already have an account, you can skip this section. You need a valid email and a working cellphone number to continue. A Google voice number will work as well.

  • Open up a browser and visit https://kaggle.com .
  • Click on Register.

  • You can register with Google or with your email.
  • Follow the online instructions to finish registration. Email verification is needed in this step if you choose to register with your email.
  • Once you are registered and logged on to Kaggle, you need to verify your phone number. Click on the icon on the upper right hand corner.

  • Click on Account.

  • Click on Not verified under Phone Verification.

  • Follow the online instructions to verify your phone number. This step is required to use the GPUs and have network access for the notebook.

Copy & Edit the Notebook

  • Visit this notebook.
    https://www.kaggle.com/code/amida168/stable-diffusion-webui-various-models
  • Click on Copy & Edit to clone the notebook to your own account.

  • Click on the down arrow to expand Settings in the right-hand panel.

  • Make sure the ACCELERATOR is set to GPU T4 x 2 and INTERNET is on.

  • This notebook supports a lot of models. By default, no model is loaded. We need to edit one line to load one model. We are going to use ProtoGen X3.4 as an example. Locate the main panel and find the following line: #Uncomment the following line to use ProtoGen X3.4. Remove the # from the beginning of the next line so that it reads
    !wget -O /kaggle/working/stable-diffusion-webui/models/Stable-diffusion/ProtoGen_X3.4.safetensors -L https://huggingface.co/darkstorm2150/Protogen_x3.4_Official_Release/resolve/main/ProtoGen_X3.4.safetensors
  • In a notebook, a block of code or markdown text is called a cell. Now you are ready to run this cell. Scroll up a bit and click on the play icon to run the code in this cell. Note that this step takes a long time. It can take anywhere from 15 to 30 minutes.

  • Scroll down to the end of this cell and you can see the status of running the code. Note that a common problem of this step is network errors. If you see some error messages about some files that cannot be downloaded, you will have to try it later when the network condition is better.

  • When it’s done running, you will see a link to a webui provided. Click on the link next to “Running on public URL: ” to open the webui.

Generate AI Images

  • Now you are ready to generate AI images! The first text box is for Prompt, and this is where you tell the AI model what to generate. The second text box is for Negative prompt, and this is where you tell the AI model what NOT to generate. Enter the following text in the Prompt:
    modelshoot style, (extremely detailed CG unity 8k wallpaper), full shot body photo of Portrait of a beautiful woman, dark magic school student uniform, flowy hair, photorealistic photography, trending on ArtStation, trending on CGSociety, Intricate, High Detail, Sharp focus, dramatic, photorealistic photography shot on Canon EOS mark IV, f5.6, matte
  • Enter the following text in the Negative prompt:
    canvas frame, cartoon, 3d, ((disfigured)), ((bad art)), ((deformed)),((extra limbs)),((close up)),((b&w)), weird colors, blurry, (((duplicate))), ((morbid)), ((mutilated)), [out of frame], extra fingers, mutated hands, ((poorly drawn hands)), ((poorly drawn face)), (((mutation))), (((deformed))), ((ugly)), blurry, ((bad anatomy)), (((bad proportions))), ((extra limbs)), cloned face, (((disfigured))), out of frame, ugly, extra limbs, (bad anatomy), gross proportions, (malformed limbs), ((missing arms)), ((missing legs)), (((extra arms))), (((extra legs))), mutated hands, (fused fingers), (too many fingers), (((long neck))), Photoshop, video game, ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, mutation, mutated, extra limbs, extra legs, extra arms, disfigured, deformed, cross-eye, body out of frame, blurry, bad art, bad anatomy, 3d render

  • Now enter the other parameters according to this screenshot:

  • Scroll up to the top and click on the big orange Generate button to generate an image. It takes about 45 to 60 seconds to generate an image of this size.

  • Congrats! You have generated your first AI image!

  • Click on the image to enlarge it and right click on the image to save it. On some browsers, you might be able to drag and drop the image to your folder. When you stop the session, the generated images will be gone. Therefore, be sure to save the images you want to keep. There is a way to keep the files between sessions, but I didn’t have good experience with it so I don’t use it. If you don’t want to save the images one by one, I will show you how to save all the images you generated during a session.

  • You can now try to change the prompts and parameters and see how the model responds to the changes. Don’t set the size too big, otherwise webui might crash. I usually set the size to 512×512 or 768×768 for square images and  512×768 or 768×512 for rectangular images. Most models are trained using 512×512 images, so some people recommend using 512×512 as the size.
  • Before you stop this session, there is a feature that’s very useful. Click on PNG info to access it.

  • Drag and drop an image you saved earlier to the Source box.

  • The parameters used to generate the image are loaded. You can then click on the buttons on the bottom to send the parameters to other tabs for processing without entering the parameters again. Pretty neat, right?

  • When you are done generating, it’s time to stop running the webui. Close the webui window. Switch to the Kaggle notebook window.
  • Click on Cancel Run to stop running the code.

Save the Images and Clean up

  • Move the cursor to the last cell and click on the play icon.

  • Go to the right panel and scroll up to the Data tab to expand it if necessary. Click on the triangle by /kaggle/working to expand it.

  • Click on the 3 vertical dots by output.zip to see the option to download it.

  • Move the cursor to the right of the GPU status to find the 3 vertical dots. If you don’t see the dots, try to make your browser window wider. Make sure you have saved your output.zip, then click on Stop session to stop. Sometimes, the Stop session icon is already visible and there is no need to click on the 3 vertical dots to expand it. Note that this session lasted 2 hours and 28 minutes. After you stop the session, this will be subtracted from your GPU usage quota. Each week, you get about 30 to 35 hours of GPU time. The quota resets every Friday.

There are some points to note.

  • When you want to try a different model listed here, make sure you put # back to the model you are not going to use and remove the # from the model you want to try.
  • When you stop the session, everything will be gone.
  • Every time you try to run it, you have to wait for the webui to be installed and a model to be downloaded. It takes about 15 to 30 minutes to get everthing ready.
  • Kaggle only has the Python programming language version 3.7 which is not officially supported by webui. It’s running now, but it might not run in the future.
  • The notebook is using an older version of webui because of compatibility problem. Newer features of webui are not available.
  • If you have more than one model loaded and you tried to switch model, webui might crash because the notebook has only 16GB of RAM available.
  • Some advanced features are not working because of limitations in RAM. For example, the Checkpoint Merger used to mix models is not working.
  • The settings you specify in webui have to be specified again in every session.

Thanks for following these steps to learn how to generate AI images. If you have questions, feel free to ask in the comments section.


This post may contain affiliated links. When you click on the link and purchase a product, we receive a small commision to keep us running. Thanks.


Be the first to comment

Leave a Reply