Official source code is now available for DragGAN, the AI tool that makes your Photoshop tasks easier with just a few clicks. But how do you use it? Where do you install it? If you have the same question, don’t worry. Here, I will guide you on how to properly install, run and use DragGAN. You will also be able to understand how each button works in the editor dashboard of this AI tool.
I have already discussed what DragGAN actually is, how it works, and its benefits in our previous article. So, I won’t waste your time by adding more details about the tool. Click on the link to learn what DragGAN is. Now, let’s move on to the main topic – how to use this amazing AI tool to manipulate existing image directions.
How to install DragGAN?
To install and use DragGAN, we will take the help of Google Colab. The setup and installation process only takes 2 to 3 minutes. However, if you are a newbie, you need to carefully read every line in this guide. Let’s get started.
First, open the link to DragGAN in Colab.
Make sure you have logged in with a Google account in your browser. Now click on the “Connect” button in the top right corner. Wait until the connection is established successfully. Then click on “Runtime” and select “Change runtime type.” Here, confirm that the hardware accelerator is set to GPU. Click on “Save.”
If you see the message “Warning: This notebook was not authored by Google,” simply click on “Run anyway.”
Also, ensure that you are connected to the GPU RAM. As I mentioned earlier, click on “Connect” in the top right corner. You will see the connected GPU RAM information in the same place.
Now you have completed your initial setup, it’s time to run some commands to get your DragGAN tool ready.
Hover over “
!git clone https://github.com/XingangPan/DragGAN.git” and click on the “Play” button. Wait until the processing finishes.
Next, click on the “Play” button for “
cd /content/DragGAN” and again wait for the processing to finish.
Then, click on the “Play” button for “
!sh scripts/download_model.sh“. Wait for the process to complete.
Now, install the dependencies by clicking the “Play” button for “
!pip install gradio !pip install Ninja“.
After installing the dependencies, the last command is “
python visualizer_drag_gradio.py --share“. Click on the “Play” button and wait for the two URLs. One URL is for localhost, and the other one provides direct access with a gradio.live domain. Right-click on the public URL of gradio.live and open it in a new tab.
Congratulations! You have now installed the DragGAN image editor. Please note that the gradio.live URL will be active for the next 3 days, unless you click on the “Pause” button of the “
python visualizer_drag_gradio.py --share” command in Google Colab.
How to use the DragGAN AI editor?
Let’s explore each option before we start editing. In the “Pickle – Pretrained Model” section of the tool, there are different options available to select different animals and people. I selected “stylegan2-ffhq-512×512” to get some images of people.
In the “Latent” option, you can increase the Seed numbers to obtain different images in the editor.
Now, you need to decide which area of the image, you want to work on. Please note that the first time you try, you may make some mistakes. With daily practice, you will gain a better understanding of when to move the image to achieve the perfect output.
Now you need to add 2 dots in any area of the image. Suppose I want to close the mouth of the boy in the image. First, I will click on that area where the second red dot automatically comes. Here, first, I clicked on the end of the teeth for the first time, and then a blue dot appeared. In the second time, I clicked on his upper lips, where a red dot appeared.
At last, I will click on the Start button in the left side editor. Here, you can notice that the “Steps” number count will automatically increase in the editor, and the red dot will comes below the blue dot, and the boy’s lips will be automatically closed. You can also move his head, but here I just took an example of lips to show you the demos of the DragGAN AI tool.
The Steps count will automatically stop after the red dot comes below the blue dot. Also, you can click on the “Stop” button on the editor if you have already achieved the desired editing on the image.