Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
update readme
  • Loading branch information
seasonSH authored Jun 11, 2022
1 parent 4709420 commit 6ffd7c9
Showing 1 changed file with 78 additions and 78 deletions.
156 changes: 78 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ Official Implementation of our SemanticStyleGAN paper for training and inference
# Table of Contents
- [Installation](#installation)
- [Pretrained Models](#pretrained-models)
- [Inference](#inference)
* [Synthesis](#synthesis)
* [Inversion](#inversion)
* [Computing Metrics](#computing-metrics)
- [Training](#training)
* [Data Preparation](#data-preparation)
* [Training SemanticStyleGAN](#training-semanticstylegan)
- [Inference](#inference)
* [Computing Metrics](#computing-metrics)
* [Inversion](#inversion)
* [Synthesis](#synthesis)
- [Domain Adaptation](#domain-adaptation)
* [Domain Adaptation](#domain-adaptation)
- [Credits](#credits)
- [Acknowledgments](#acknowledgments)
- [Citation](#citation)
Expand All @@ -56,6 +56,78 @@ In this repository, we provide pretrained models for various domains.

<br>

# Inference

## Synthesis
### Random Synthesis
In `visualize/generate.py`, we provide a script for sampling random images and their corresponding segmentation masks with SemanticStyleGAN.
An example command is provided below:
```
python visualize/generate.py \
/path/to/checkpoint \
--outdir results/samples \
--sample 20 \
--save_latent
```
The `save_latent` flag will save the w latent code of each synthesized image in a separate `.npy` file.

### Local Latent Interpolation
<img src="docs/local_interpolation.gif" width="400px"/>

In `visualize/generate_video.py`, we provide a script for visualizing the local interpolation by SemanticStyleGAN.
An example command is provided below:
```
python visualize/generate_video.py \
/path/to/checkpoint \
--outdir /results/interpolation \
--latent /results/samples/000000_latent.npy
```
Here, `/results/samples/000000_latent.npy` is the latent code either generated by `visualize/generate.py` or output by `visualize/invert.py`. You can also ignore the `--latent` flag for
generating a video with a random latent code. The scripts will create sevaral mp4 files udner the output folder, each shows the interpolation animation in
a specific latent subspace.

### Synthesizing Components
In `visualize/generate_components.py`, we provide a script for visualizing the components synthesized by SemanticStyleGAN, where we will gradually add more local generators
to the synthesis procedure.
An example command is provided below:
```
python visualize/generate_components.py \
/path/to/checkpoint \
--outdir /results/components \
```
This command will synthesize random images in a gradual manner. You can also visualize the components of a specific target image with the following command:
```
python visualize/generate_components.py \
/path/to/checkpoint \
--outdir /results/components/000000 \
--latent /results/samples/000000_latent.npy \
```

## Computing Metrics
Given a trained generator and a prepared inception file, we can compute the metrics with following command:
```
python calc_fid.py \
--ckpt /path/to/checkpoint \
--inception /path/to/inception/file
```

## Inversion
### Optimization-based
You can use `visualize/invert.py` for inverting real images into the latent space of SemanticStyleGAN via optimization:
```
python visualize/invert.py \
--ckpt /path/to/checkpoint \
--imgdir /path/to/img/directory/ \
--outdir /path/to/output/directory/ \
--size 512 \
```
This script will save the reconstructed images and their corresponding w-plus latent codes in separate sub-directories under the `outdir`. Additionally, you can set `--finetune_step` to a non-zero integer for pivotal tuning inversion.

### Encoder
TODO

<br>

# Training

## Data Preparation
Expand Down Expand Up @@ -116,79 +188,7 @@ Additionally, if you have tensorboard installed, you can visualize tensorboard l

<br>

# Inference

## Computing Metrics
Given a trained generator and a prepared inception file, we can compute the metrics with following command:
```
python calc_fid.py \
--ckpt /path/to/checkpoint \
--inception /path/to/inception/file
```

## Inversion
### Optimization-based
You can use `visualize/invert.py` for inverting real images into the latent space of SemanticStyleGAN via optimization:
```
python visualize/invert.py \
--ckpt /path/to/checkpoint \
--imgdir /path/to/img/directory/ \
--outdir /path/to/output/directory/ \
--size 512 \
```
This script will save the reconstructed images and their corresponding w-plus latent codes in separate sub-directories under the `outdir`. Additionally, you can set `--finetune_step` to a non-zero integer for pivotal tuning inversion.

### Encoder
TODO

## Synthesis
### Random Synthesis
In `visualize/generate.py`, we provide a script for sampling random images and their corresponding segmentation masks with SemanticStyleGAN.
An example command is provided below:
```
python visualize/generate.py \
/path/to/checkpoint \
--outdir results/samples \
--sample 20 \
--save_latent
```
The `save_latent` flag will save the w latent code of each synthesized image in a separate `.npy` file.

### Local Latent Interpolation
<img src="docs/local_interpolation.gif" width="400px"/>

In `visualize/generate_video.py`, we provide a script for visualizing the local interpolation by SemanticStyleGAN.
An example command is provided below:
```
python visualize/generate_video.py \
/path/to/checkpoint \
--outdir /results/interpolation \
--latent /results/samples/000000_latent.npy
```
Here, `/results/samples/000000_latent.npy` is the latent code either generated by `visualize/generate.py` or output by `visualize/invert.py`. You can also ignore the `--latent` flag for
generating a video with a random latent code. The scripts will create sevaral mp4 files udner the output folder, each shows the interpolation animation in
a specific latent subspace.

### Synthesizing Components
In `visualize/generate_components.py`, we provide a script for visualizing the components synthesized by SemanticStyleGAN, where we will gradually add more local generators
to the synthesis procedure.
An example command is provided below:
```
python visualize/generate_components.py \
/path/to/checkpoint \
--outdir /results/components \
```
This command will synthesize random images in a gradual manner. You can also visualize the components of a specific target image with the following command:
```
python visualize/generate_components.py \
/path/to/checkpoint \
--outdir /results/components/000000 \
--latent /results/samples/000000_latent.npy \
```

<br>

# Domain Adaptation
## Domain Adaptation

In `train_adaptation.py`, we provide a script for performing domain adaptation on image-only datasets.
To do this, you first need to create an LMDB for the target image dataset.
Expand Down

0 comments on commit 6ffd7c9

Please sign in to comment.