How to install and use DragGAN? 3 ways to run it online and locally

AI Guides1 years ago (2024)update Newbase
0

DragGAN is a widely-used open source artificial intelligence computer vision project and area of academic research. It has the ability to precisely manipulate the posture, form, expression and orientation of static objects within images through direct manipulation via dragging motions. Capabilities include opening the mouth of an animal or moving a vehicle. It can also modify the angle, elevation or position of landscape elements. Recently, the DragGAN development team publicly released their official implementation on GitHub in an open source manner. This document serves to outline how one may execute, install and utilize DragGAN, including various options for both online and local use.

How to install and use DragGAN? 3 ways to run it online and locally

Running and using DragGAN online

If you just want to try out the effect of DragGAN, running DragGAN online is a better choice. Here we will introduce three methods to use DragGAN online, including Hugging Face and Google Colab.

Run via Hugging Face

Hugging Face is a prominent open source artificial intelligence model community. The platform brings together various types of artificial intelligence models, data sets and run spaces. Following the launch of the DragGAN project as open source software, its official team promptly established a project space on Hugging Face. Interested parties may access this space at any time to evaluate the operational effects.

Hugging Face: https://huggingface.co/spaces/DragGan/DragGan

How to install and use DragGAN? 3 ways to run it online and locally


Run via Google Colab

Google Colab is a cloud platform launched by Google that enables users to author, execute and share Python code using the Jupyter notebook environment. Google Colab is a freely available service that provides users with virtual machines that include access to high-performance central processing units (CPUs), graphics processing units (GPUs) and tensor processing units (TPUs), as well as pre-installed libraries such as TensorFlow, PyTorch, and others. Technical users may opt to utilize this method by accessing the provided runtime address, selecting the GPU option within settings, and executing the installation code and demo code blocks.

Google Colab: https://colab.research.google.com/drive/1mey-IXPwQC_qSthI5hO-LTX7QL4ivtPh?usp=sharing

How to install and use DragGAN? 3 ways to run it online and locally

Install and use DragGAN locally

If you want to install and deploy DragGAN locally on your computer, just follow the instructions on the DragGAN GitHub project. before operation Please download and install Git , Python and Conda . The specific steps are as follows:

Step 1: Clone the official DragGAN project

Open a command prompt or terminal and use the git command, git clone https://github.com/XingangPan/DragGAN.gitClone the official project to your desired folder.

Step 2: Set up CUDA and install Python environment

  1. After cloning is complete, use the cd command cd DragGANGo to this folder
  2. Then set up the conda environment: conda env create -f environment.yml, (Note: If you are running Mac, please edit the environment.yml file and delete - cudatoolkit=11.1, because Mac does not use Nvidia’s GPU. In addition, the Mac also needs to be set to run on the CPU and configured in the terminal. export PYTORCH_ENABLE_MPS_FALLBACK=1
  3. Activate the conda environment: conda activate stylegan3
  4. Install relevant dependencies: pip install -r requirements

Step 3: Download the pre-trained model

Use command python scripts/download_model.pydownload

Step 4: Set up the DragGAN GUI interface and run it

Use command python visualizer_drag_gradio.pyDownload the interface based on Gradio . After downloading and installing, copy the local address in the Running on local URL in the terminal. http://127.0.0.1:7860You can now run it in your local browser.

The above is the method for running DragGAN compiled by the AI ​​tool set. If you have any questions during installation and use, you can leave a message in the comment area or seek help from DragGAN’s official GitHub project.

Related articles

Comments

No comments yet...