|
1 | 1 | ## Overview of Code Structure
|
2 |
| -[train.py](./train.py) is a general-purpose training script. It works for various models (with model option `--model`: e.g., `pix2pix`, `cyclegan`, `colorization`) and different datasets (with dataset option `--dataset_mode`: e.g., `aligned`, `unaligned`, `single`, `colorization`). See the main [README](../README.md) and Training/test [tips](tips.md) for more details. |
3 |
| - |
4 |
| -[test.py](./test.py) is a general-purpose test script. Once you have trained your models with `train.py`, you can use this script to test the model. It will load a saved model from `--checkpoints_dir` and save the results to `--results_dir`. See the main [README](../README.md) and Training/test [tips](tips.md) for more details. |
5 |
| - |
6 |
| - |
7 |
| -[data](./data) directory contains all the modules related to datasets. |
8 |
| -* [\_\_init\_\_.py](./data/__init__.py) implements the interface between this package and training/test script. You should call `from data import CreateDataLoader` and `data_loader = CreateDataLoader(opt)` to create a dataloader given an option `opt`. |
9 |
| -* [base_dataset.py](./data/base_dataset.py) implements an abstract base dataset class. It also includes common transformation functions `get_transform` and `get_simple_transform` which can be used in dataset classes. To add a custom dataset class called `dummy`, you need to add a file called `dummy_dataset.py` and define a subclass `DummyDataset` inherited from `BaseDataset`. You need to implement functions: `name`, `__len__`, `__getitem__`, and `modify_commandline_options`. You can use this dataset using `--dataset_mode dummy`. |
10 |
| -* [image_folder.py](./data/image_folder.py) implements a modified Image folder class. We |
11 |
| -modify the original PyTorch code so that it also loads images from the current directory as well as the subdirectories. |
12 |
| -* [template_dataset.py](./data/template_dataset.py) provides a class template with detailed documentation. Check out this file if you plan to implement your own dataset class. |
13 |
| -* [aligned_dataset.py](./data/aligned_dataset.py) includes a dataset class that can load aligned image pairs. |
14 |
| -* [unaligned_dataset.py](./data/unaligned_dataset.py) includes a dataset class that can load unaligned/unpaired datasets. |
15 |
| -* [single_dataset.py](./data/single_dataset.py) includes a dataset class that can load a collection of single images. It is used in `test.py` when only model in one direction is being tested. |
16 |
| -* [colorization_dataset.py](./data/colorization_dataset.py) implements a dataset class that can load a collection of RGB images and convert it into (L, ab) pairs. It is used with pix2pix-based colorization model. |
17 |
| - |
18 |
| - |
19 |
| -[models](./models) directory contains all the modules related to core core formulations and network. |
20 |
| -* [\_\_init\_\_.py](./models/__init__.py) |
21 |
| -* [base_model.py](./models/base_model.py) |
22 |
| -* [template_model.py](./models/template_model.py) |
23 |
| -* [pix2pix_model.py](./models/pix2pix_model.py) |
24 |
| -* [colorization_model.py](./models/colorization_model.py) |
25 |
| -* [cycle_gan_model.py](./models/cycle_gan_model.py) |
26 |
| -* [networks.py](./models/networks.py) module implements network architectures (both generators and discriminators), as well as normalization layers, initialization, optimization scheduler (learning rate policy), and GAN loss function. |
27 |
| -* [test_model.py](./models/test_model.py) |
28 |
| - |
29 |
| -[options](./options) directory includes option modules: training options, test options and basic options (used in both training and test). |
30 |
| -* [\_\_init\_\_.py](./options/__init__.py) an empty file to make the `options` directory a package. |
31 |
| -* [base_options.py](./options/base_options.py) includes options that are used in both training and test. It also implements a few helper functions such as parsing, printing, and saving the options. It also gathers additional options defined in `modify_commandline_options` functions in both dataset class and model class. |
32 |
| -* [train_options.py](./options/train_options.py) includes options that are only used in training time. |
33 |
| -* [test_options.py](./options/test_options.py) includes options that are only used in test time. |
34 |
| - |
35 |
| - |
36 |
| -[util](./util) directory includes a misc collection of useful utility functions. |
37 |
| - * [\_\_init\_\_.py](./util/__init__.py): an empty file to make the `util` directory a package. |
38 |
| - * [get_data.py](./util/get_data.py) |
39 |
| - * [html.py](./util/html.py) |
40 |
| - * [image_pool.py](./util/image_pool.py) |
41 |
| - * [util.py](./util/util.py) |
42 |
| - * [visualizer.py](./util/visualizer.py) |
| 2 | +We give a brief overview of each directory and each file. Please see the documentation in each file for more details. If you have questions, you may find useful information in [training/test tips](tips.md) and [frequently asked questions](qa.md). |
| 3 | + |
| 4 | +[train.py](../train.py) is a general-purpose training script. It works for various models (with option `--model`: e.g., `pix2pix`, `cyclegan`, `colorization`) and different datasets (with option `--dataset_mode`: e.g., `aligned`, `unaligned`, `single`, `colorization`). See the main [README](.../README.md) and Training/test [tips](tips.md) for more details. |
| 5 | + |
| 6 | +[test.py](../test.py) is a general-purpose test script. Once you have trained your model with `train.py`, you can use this script to test the model. It will load a saved model from `--checkpoints_dir` and save the results to `--results_dir`. See the main [README](.../README.md) and Training/test [tips](tips.md) for more details. |
| 7 | + |
| 8 | + |
| 9 | +[data](../data) directory contains all the modules related to data loading and data preprocessing. |
| 10 | +* [\_\_init\_\_.py](../data/__init__.py) implements the interface between this package and training/test script. In the `train.py` and `test.py`, we call `from data import CreateDataLoader` and `data_loader = CreateDataLoader(opt)` to create a dataloader given the option `opt`. |
| 11 | +* [base_dataset.py](../data/base_dataset.py) implements an abstract base class for datasets. It also includes common transformation functions `get_transform` and `get_simple_transform` which can be used in subclasses. To add a custom dataset class called `dummy`, you need to add a file called `dummy_dataset.py` and define a subclass `DummyDataset` inherited from `BaseDataset`. You need to implement four functions: `name`, `__len__`, `__getitem__`, and optionally `modify_commandline_options`. You can then use this dataset class by specifying flag `--dataset_mode dummy`. |
| 12 | +* [image_folder.py](../data/image_folder.py) implements an image folder class. We modify the official PyTorch image folder [code](https://github.com/pytorch/vision/blob/master/torchvision/datasets/folder.py) so that this class can load images from both the current directory and its subdirectories. |
| 13 | +* [template_dataset.py](../data/template_dataset.py) provides a dataset class template with detailed documentation. Check out this file if you plan to implement your own dataset class. |
| 14 | +* [aligned_dataset.py](../data/aligned_dataset.py) includes a dataset class that can load aligned image pairs. It assumes a single image directory `/path/to/data/train`, which contains image pairs in the form of {A,B}. See [here](https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/blob/master/docs/tips.md#prepare-your-own-datasets-for-pix2pix) on how to prepare aligned datasets. During test time, you need to prepare a directory `/path/to/data/test` for test data. |
| 15 | +* [unaligned_dataset.py](../data/unaligned_dataset.py) includes a dataset class that can load unaligned/unpaired datasets. It assumes that two directories to host training images from domain A `/path/to/data/trainA` and from domain B `/path/to/data/trainB` separately. Then you can train the model with the dataset flag `--dataroot /path/to/data`. Similarly, you need to prepare two directories `/path/to/data/testA` and `/path/to/data/testB` during test time. |
| 16 | +* [single_dataset.py](../data/single_dataset.py) includes a dataset class that can load a set of single images. It is used in `test.py` when only model in one direction is being tested. The option `--model test` is used for generating CycleGAN results only for one side. This option will automatically set `--dataset_mode single`. |
| 17 | +* [colorization_dataset.py](../data/colorization_dataset.py) implements a dataset class that can load a set of nature images in RGB, and convert RGB format into (L, ab) pairs. It is required by pix2pix-based colorization model (`--model colorization`). |
| 18 | + |
| 19 | + |
| 20 | +[models](../models) directory contains core modules related to objective functions, optimizations, and network architectures. |
| 21 | +* [\_\_init\_\_.py](../models/__init__.py) |
| 22 | +* [base_model.py](../models/base_model.py) |
| 23 | +* [template_model.py](../models/template_model.py) |
| 24 | +* [pix2pix_model.py](../models/pix2pix_model.py) |
| 25 | +* [colorization_model.py](../models/colorization_model.py) |
| 26 | +* [cycle_gan_model.py](../models/cycle_gan_model.py) |
| 27 | +* [networks.py](../models/networks.py) module implements network architectures (both generators and discriminators), as well as normalization layers, initialization, optimization scheduler (learning rate policy), and GAN loss function. |
| 28 | +* [test_model.py](../models/test_model.py) |
| 29 | + |
| 30 | +[options](../options) directory includes our option modules: training options, test options and basic options (used in both training and test). |
| 31 | +* [\_\_init\_\_.py](../options/__init__.py) an empty file to make the `options` directory a package. |
| 32 | +* [base_options.py](../options/base_options.py) includes options that are used in both training and test. It also implements a few helper functions such as parsing, printing, and saving the options. It also gathers additional options defined in `modify_commandline_options` functions in both dataset class and model class. |
| 33 | +* [train_options.py](../options/train_options.py) includes options that are only used in training time. |
| 34 | +* [test_options.py](../options/test_options.py) includes options that are only used in test time. |
| 35 | + |
| 36 | + |
| 37 | +[util](../util) directory includes a misc collection of useful utility functions. |
| 38 | + * [\_\_init\_\_.py](../util/__init__.py): an empty file to make the `util` directory a package. |
| 39 | + * [get_data.py](../util/get_data.py) |
| 40 | + * [html.py](../util/html.py) |
| 41 | + * [image_pool.py](../util/image_pool.py) |
| 42 | + * [util.py](../util/util.py) |
| 43 | + * [visualizer.py](../util/visualizer.py) |
0 commit comments