Skip to content

Commit

Permalink
Update installation and first run docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Suraj Pai committed Sep 2, 2021
1 parent 3dfeb53 commit 6c7d7dc
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 30 deletions.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
recursive-include ganslate *.sh
recursive-include ganslate/utils/cli/cookiecutter_templates *
recursive-exclude ganslate/utils/cli/cookiecutter_templates __pycache__/*
20 changes: 5 additions & 15 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,18 @@ You can install `ganslate` either through a docker setup or directly on your sys
Dockerized setup is the easiest way to get started with the framework. If you do not have docker installed, you can follow instructions [here](https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository)


First, you can build the docker image by running the following commands at the repository root level
You can run the docker image, which will give you access to a container with all dependencies installed, using,

```console
cd docker/
docker build -t ganslate:latest .
docker run --gpus all -it surajpaib/ganslate:latest
```

Once the docker image is built, it can be run using,
This will drop down to a shell and [you can now check out the quickstart page](quickstart.md)

```console
docker run --gpus all -it \
--shm-size=24gb --volume=<data_dir>:/data --volume=<repo_dir>:/ganslate \
--name=ganslate ganslate:latest /bin/bash
```

The docker container [mounts volumes from the host system](https://docs.docker.com/storage/volumes/) to allow easier persistence of data.

`<data_dir>` must be replaced with the full path of a directory where your data is located.
`<repo_dir>` must be replaced with the path to the `ganslate` repository was cloned.

!!! note
`<data_dir>` can initially point to an empty directory to simplify setup. Data can be moved into this directory later as docker mounts the directory to the container.
!!! note
To get your data into the docker container, you can use volume mounts. The docker container [mounts volumes from the host system](https://docs.docker.com/storage/volumes/) to allow easier persistence of data. This can be done as `docker run --gpus all --volume=<data_dir>:/data -it ganslate:latest`. `<data_dir>` must be replaced with the full path of a directory where your data is located, this will then be mounted on the `/data` path within the docker

## Local

Expand Down
17 changes: 6 additions & 11 deletions docs/tutorials/horse2zebra.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
# Your First Run (horse2zebra)

For both types of install, running the basic horse2zebra example is similar.
#### Data download
The horse2zebra dataset can be downloaded using instructions below,
1. Open a terminal inside the cloned repository and run,
For both types of install, running the basic horse2zebra example is the same.

Once the installation is complete and you can access the CLI as show in the [quickstart](../quickstart.md), run
```console
cd projects/horse2zebra
bash download_cyclegan_dataset.sh horse2zebra .
ganslate your-first-run
```

!!! note
The horse2zebra dataset will be downloaded at the root-level of the ganslate directory. This can be changed by providing a <data_dir> to the command `bash download_cyclegan_dataset.sh horse2zebra <data_dir>. However, the yaml files need to be manually changed. For non-advanced users, it is best to stick to the default location
On running this, a few options will show up that can be customized. You may also leave it at its default values. Once the prompts
are completed, you will have a folder generated with a demo `horse2zebra` project in the path you specified.

### Training
Next, you can run the training using the command below,

```console
cd /code
python tools/train.py config=projects/horse2zebra/experiments/default.yaml
ganslate train config=<path_specified>/default.yaml
```

!!! note
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"project_name": "horse2zebra",
"number_of_iterations": 117700,
"batch_size": 1,
"logging_frequency": 500,
"checkpointing_frequency": 2000,
"generator_model": ["Resnet2D", "Unet2D"],
"cycle_consistency_ssim_percentage": 0.84,
"path": "."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
project_dir: null

train:
output_dir: "./checkpoints/horse2zebra_default"
cuda: True
n_iters: {{ cookiecutter.number_of_iterations }}
n_iters_decay: {{ cookiecutter.number_of_iterations }}
batch_size: {{ cookiecutter.batch_size }}
mixed_precision: True

logging:
freq: {{ cookiecutter.logging_frequency }}
wandb:
project: "horse2zebra"

checkpointing:
freq: {{ cookiecutter.checkpointing_frequency }}

dataset:
name: "ImageDataset"
root: "{{ cookiecutter.path }}/{{ cookiecutter.project_name }}/datasets/horse2zebra/train/"
num_workers: 16
image_channels: 3
preprocess: "resize"
load_size: 256
flip: True

gan:
name: "CycleGAN"

generator:
name: {{ cookiecutter.generator_model }}
n_residual_blocks: 9
in_out_channels:
AB: [3, 3]

discriminator:
name: "PatchGAN2D"
n_layers: 3
in_channels:
B: 3

optimizer:
lambda_AB: 10.0
lambda_BA: 10.0
lambda_identity: 0
proportion_ssim: {{ cookiecutter.cycle_consistency_ssim_percentage }}
lr_D: 0.0002
lr_G: 0.0004

metrics:
discriminator_evolution: True
ssim: True

infer:
checkpointing:
load_iter: 1
dataset:
name: "ImageDataset"
root: "{{ cookiecutter.path }}/{{ cookiecutter.project_name }}/datasets/horse2zebra/test/"
num_workers: 16
image_channels: 3
preprocess: "resize"
load_size: 256
flip: False

11 changes: 10 additions & 1 deletion ganslate/utils/cli/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ def new_project(path):
template = str(COOKIECUTTER_TEMPLATES_DIR / "new_project")
cookiecutter(template, output_dir=path)

# First run
@interface.command(help="Fetch resources for the horse2zebra first run")
@click.argument("path", default="./")
def your_first_run(path):
template = str(COOKIECUTTER_TEMPLATES_DIR / "your_first_run")
project_path = cookiecutter(template, output_dir=path)
download_script_path = "ganslate/utils/cli/scripts/download_cyclegan_datasets.sh"
subprocess.call(["bash", download_script_path, "horse2zebra", project_path])

# Download project
@interface.command(help="Download a project.")
@click.argument("name")
Expand All @@ -54,7 +63,7 @@ def download_project(name, path):
@click.argument("name")
@click.argument("path")
def download_dataset(name, path):
download_script_path = "ganslate/utils/scripts/download_cyclegan_datasets.sh"
download_script_path = "ganslate/utils/cli/scripts/download_cyclegan_datasets.sh"
subprocess.call(["bash", download_script_path, name, path])

# Install Nvidia Apex
Expand Down
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ author = "ganslate team"
# author-email =
url = https://github.com/Maastro-CDS-Imaging-Group/ganslate
description = GAN image-to-image translation framework made simple and extensible.
long-description = file: README.md
long-description-content-type = text/markdown
long_description = file: README.md
long_description_content_type = text/markdown
license = mit
platforms = any
keywords = one, two
classifiers =
Development Status :: 3 - Alpha
Programming Language :: Python :: 3 :: Only
Intended Audience :: Science/Research
project-urls =
project_urls =
Documentation = https://ganslate.netlify.app/ # TODO: Update

[options]
Expand Down

0 comments on commit 6c7d7dc

Please sign in to comment.