为 pix2pix 准备你本身的数据集(Prepare your own datasets for pix2pix)

Pix2pix’s training requires paired data. We provide a python script to generate training data in the form of pairs of images {A,B}, where A and B are two different depictions of the same underlying scene. For example, these might be pairs {label map, photo} or {bw image, color image}. Then we can learn to translate A to B or B to A:
Pix2pix 的训练须要配对的数据。咱们提供一个 python 脚原本产生配对形式 {A,B} 的图像做为训练数据,其中 A 和 B 是同一个场景的不一样描述。举例而言,这些多是 {label map, photo} (标签地图,照片)或者 {bw image, color image} (黑白图像,彩色图像)。而后咱们能够训练从 A 到 B 或者从 B 到 A。python

Create folder /path/to/data with subdirectories A and B. A and B should each have their own subdirectories train, val, test, etc. In /path/to/data/A/train, put training images in style A. In /path/to/data/B/train, put the corresponding images in style B. Repeat same for other data splits (val, test, etc).
建立文件夹 /path/to/data,具备子目录 ABAB 应该各自具备其子目录 train, val, test 等。在 /path/to/data/A/train 目录中,放入 A 样式的训练图像;在 /path/to/data/B/train目录中,放入对应的 B 样式的图像。对其余的数据划分( val, test 等),也是相似。web

Corresponding images in a pair {A,B} must be the same size and have the same filename, e.g., /path/to/data/A/train/1.jpg is considered to correspond to /path/to/data/B/train/1.jpg.
一个配对形式 {A,B} 的对应图像,必须具备相同的尺寸,而且具备相同的文件名。如 /path/to/data/A/train/1.jpg 被认为与 /path/to/data/B/train/1.jpg 相对应。bash

Once the data is formatted this way, call:
一旦数据如此格式化后,调用:ide

python datasets/combine_A_and_B.py --fold_A /path/to/data/A --fold_B /path/to/data/B --fold_AB /path/to/data

This will combine each pair of images (A,B) into a single image file, ready for training.
这将合并图像对 (A,B) 到一个图像文件中,能够用来进行训练。svg