diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..fc323a9 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +recursive-include ganslate *.sh +recursive-include ganslate/utils/cli/cookiecutter_templates * +recursive-exclude ganslate/utils/cli/cookiecutter_templates __pycache__/* \ No newline at end of file diff --git a/docs/installation.md b/docs/installation.md index 960c7ca..36b59bf 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -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 --volume=:/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. -`` must be replaced with the full path of a directory where your data is located. -`` must be replaced with the path to the `ganslate` repository was cloned. - -!!! note - `` 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 -it ganslate:latest`. `` 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 diff --git a/docs/tutorials/horse2zebra.md b/docs/tutorials/horse2zebra.md index 00a4504..ec6a682 100644 --- a/docs/tutorials/horse2zebra.md +++ b/docs/tutorials/horse2zebra.md @@ -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 to the command `bash download_cyclegan_dataset.sh horse2zebra . 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=/default.yaml ``` !!! note diff --git a/ganslate/utils/cli/cookiecutter_templates/your_first_run/__init__.py b/ganslate/utils/cli/cookiecutter_templates/your_first_run/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ganslate/utils/cli/cookiecutter_templates/your_first_run/cookiecutter.json b/ganslate/utils/cli/cookiecutter_templates/your_first_run/cookiecutter.json new file mode 100644 index 0000000..6bcafcf --- /dev/null +++ b/ganslate/utils/cli/cookiecutter_templates/your_first_run/cookiecutter.json @@ -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": "." +} \ No newline at end of file diff --git a/ganslate/utils/cli/cookiecutter_templates/your_first_run/{{ cookiecutter.project_name }}/__init__.py b/ganslate/utils/cli/cookiecutter_templates/your_first_run/{{ cookiecutter.project_name }}/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ganslate/utils/cli/cookiecutter_templates/your_first_run/{{ cookiecutter.project_name }}/default.yaml b/ganslate/utils/cli/cookiecutter_templates/your_first_run/{{ cookiecutter.project_name }}/default.yaml new file mode 100644 index 0000000..16b492f --- /dev/null +++ b/ganslate/utils/cli/cookiecutter_templates/your_first_run/{{ cookiecutter.project_name }}/default.yaml @@ -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 + diff --git a/ganslate/utils/cli/interface.py b/ganslate/utils/cli/interface.py index 715815f..4d1a99a 100644 --- a/ganslate/utils/cli/interface.py +++ b/ganslate/utils/cli/interface.py @@ -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") @@ -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 diff --git a/setup.cfg b/setup.cfg index 1e3d020..f9fd348 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,8 +5,8 @@ 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 @@ -14,7 +14,7 @@ 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]