This guide provides details on generating the dataset structure required for AI Clothing Try-On. The dataset consists of train/ and test/ directories, each containing cloth/ and image/ subdirectories. Additional processing generates cloth_mask/, image-parse-v3/, openpose_img/, and openpose_json/ directories.
- GPU: NVIDIA GPU with CUDA support (Recommended: NVIDIA RTX series)
- Memory: At least 8GB RAM
- Windows 10/11 (Recommended)
- Ubuntu (Optional)
- Python 3.8+
- OpenCV (cv2)
- numpy
- Pillow (PIL)
- rembg
- Docker
- CUDA
- MS Visual Studio (For Windows)
python -m venv dataset_env
source dataset_env/bin/activate # On Windows use: dataset_env\Scripts\activatepip install numpy pillow opencv-python rembg-
Download CUDA Toolkit:
- Go to CUDA Toolkit Downloads
- Select your operating system and download the latest stable version.
- Install it and ensure to add CUDA to your system’s
PATH.
-
Download cuDNN:
- Visit NVIDIA cuDNN and log in to download.
- Extract and copy the contents to your CUDA installation directory (e.g.,
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.x\)
sudo apt update
sudo apt install -y nvidia-cuda-toolkit- Download Visual Studio:
- Visit Microsoft Visual Studio
- Download and install the Community Edition.
- Enable C++ Development Tools:
- During installation, select Desktop Development with C++.
- Set Up Environment Variables:
- Open System Properties > Advanced > Environment Variables
- Add
C:\Program Files (x86)\Microsoft Visual Studio\<version>\Community\VC\Auxiliary\BuildtoPATH.
The dataset should be organized as follows:
dataset/
│-- train/
│ │-- cloth/ # Original cloth images
│ │-- cloth_mask/ # Generated cloth masks
│ │-- image/ # Original images
│ │-- image-parse-v3/ # Processed images (output of SCHP)
│ │-- openpose_img/ # OpenPose processed images
│ │-- openpose_json/ # OpenPose keypoint JSON files
│
│-- test/
│ │-- cloth/ # Original cloth images
│ │-- cloth_mask/ # Generated cloth masks
│ │-- image/ # Original images
│ │-- image-parse-v3/ # Processed images (output of SCHP)
│ │-- openpose_img/ # OpenPose processed images
│ │-- openpose_json/ # OpenPose keypoint JSON files
To generate the cloth masks from the cloth/ directory, run the following command:
python cloth_mask.pyThe script cloth_mask.py follows these steps:
- Reads images from the
cloth/directory. - Removes the background using
rembg. - Converts the foreground to white and background to black.
- Saves the processed mask images in the
cloth_mask/directory.
To generate OpenPose images and keypoints:
python openpose.py- Uses OpenPose to extract keypoints from images in
image/. - Saves the skeleton images in
openpose_img/. - Saves the keypoints JSON files in
openpose_json/.
The OpenPose processing runs inside a Docker container. The package virtual_clothing_tryon openpose_cmu contains the necessary setup. Ensure you have CUDA and MS Visual Studio installed before using OpenPose.
To build and run the OpenPose container:
docker build -t openpose_cmu .
docker run --gpus all -v /path/to/dataset:/opt/openpose -it openpose_cmuTo perform semantic human parsing, run the following command:
python image_parse.py- Loads pre-trained SCHP model.
- Parses human images from
image/. - Saves parsed outputs in
image-parse-v3/.
This implementation is based on the Self-Correction-Human-Parsing (SCHP) repository.
- Missing Dependencies: Ensure all required libraries are installed.
- Incorrect Image Paths: Check if the dataset is structured correctly before running scripts.
- CUDA Not Recognized: Ensure CUDA is installed and correctly added to the system
PATH. - Docker Issues: Verify that Docker, CUDA, and MSVS are properly installed.
This project is part of the AI Clothing Try-On dataset preparation pipeline.