-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update documentation and a stylegan3 script
- Loading branch information
Showing
7 changed files
with
143 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Train StyleGAN model | ||
|
||
[The styleGAN3 model](https://github.com/NVlabs/stylegan3) is trained on [the Cedar platform](https://docs.alliancecan.ca/wiki/Cedar). This model supports [three configs](https://github.com/NVlabs/stylegan3/blob/main/docs/configs.md): | ||
StyleGAN3-T (translation equiv.), StyleGAN3-R (translation and rotation equiv.), or StyleGAN2. | ||
|
||
Refer to [this documentation](./PrepareImageSetForStyleGAN.md) to prepare the image set for this training. | ||
|
||
## Start the training job | ||
|
||
Step 1: Use [`rsync`](https://linuxhandbook.com/transfer-files-ssh/) or other commands to transfer transformed Bliss | ||
images to Cedar | ||
|
||
Step 2. Login to the Cedar and fetch stylegan3 source code | ||
``` | ||
mkdir stylegan3 | ||
cd stylegan3 | ||
git clone https://github.com/NVlabs/stylegan3 | ||
``` | ||
|
||
Step 3. Creating a zip archive of Bliss images will lead to a better performance | ||
``` | ||
cd stylegan3 | ||
python dataset_tool.py --source=../bliss_single_chars_final --dest=../datasets/bliss-256x256.zip | ||
``` | ||
|
||
Step 4: Submit Job | ||
|
||
* Copy [requirements.txt](../jobs/stylegan3/requirements.txt) to stylegan3 source code root directory. | ||
|
||
* Copy [job_stylegan3.sh](../jobs/stylegan3/job_stylegan3.sh) to the `scratch/' directory in your home directory | ||
|
||
* Submit the job | ||
|
||
``` | ||
cd ~/scratch | ||
sbatch job_stylegan3.sh | ||
``` | ||
|
||
Use `sq` to check the status of the job. Use `scancel` to cancel a running job. | ||
|
||
## The training result | ||
|
||
The Bliss images were first trained using `stylegan3-r` config (translation and rotation equiv.). This job had to be | ||
cancelled after running 2.5 days because the cluster the job was running on is a shared resource that was waited by | ||
another team. Before the cancellation, the job had generated some training result that can be found at | ||
[this repository](https://github.com/cindyli/bliss-data/tree/main/styleGAN/styleGAN-training-results/stylegan3-r). | ||
|
||
`reals.png` is a collection of real Bliss symobles | ||
|
||
`fakes*.png` are random image grids exported from the training loop at regular intervals. | ||
|
||
`training_options.json` contains training options used for this round of training. | ||
|
||
`metric-fid50k_full.jsonl` logs the result and records` FID evaluated by the training loop for every export. | ||
|
||
## Use a trained model to generate images | ||
|
||
Looking at `metric-fid50k_full.jsonl`, `network-snapshot-004160.pkl` model has the lowest FID value. Run this command | ||
to submit a job to generate an image using this model: | ||
|
||
``` | ||
sbatch job_stylegan3-t_gen_images.sh | ||
``` | ||
|
||
`job_stylegan3-t_gen_images.sh` can be located [here](../jobs/stylegan3/job_stylegan3-t_gen_images.sh). | ||
|
||
## Conclusion | ||
|
||
After studying the training results and images generated by a trained model. Generated images are not good enough | ||
for brainstorming new Bliss symbols. The decision is not to continue explore this model. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
#SBATCH --job-name=stylegan3-t-gen-images | ||
#SBATCH --time 10-00:00 | ||
#SBATCH --nodes=1 | ||
#SBATCH --gpus-per-node=v100l:1 | ||
#SBATCH --mem=128G | ||
#SBATCH --ntasks-per-node=4 | ||
#SBATCH --cpus-per-task=4 | ||
#SBATCH --account=def-whkchun | ||
#SBATCH --output=%x.o%j | ||
|
||
pip install --no-index --upgrade pip | ||
module load python/3.8.2 | ||
python -V | ||
|
||
virtualenv --no-download $SLURM_TMPDIR/env | ||
source $SLURM_TMPDIR/env/bin/activate | ||
|
||
module load scipy-stack/2021a | ||
module load cuda/11.1.1 | ||
|
||
echo "Start to check CUDA Toolkit version" | ||
nvcc -V | ||
echo "End of checking CUDA Toolkit version" | ||
|
||
echo "Start to check gcc version" | ||
which gcc | ||
echo "End of checking gcc version" | ||
|
||
pip install -r /home/cindyli/stylegan3/stylegan3/requirements.txt | ||
|
||
pip list | ||
|
||
export CUDA_LAUNCH_BLOCKING=1 | ||
|
||
echo "Hello from job $SLURM_JOB_ID on nodes $SLURM_JOB_NODELIST." | ||
python /home/cindyli/stylegan3/stylegan3/gen_images.py --outdir=/home/cindyli/stylegan3/out-stylegan3-t --trunc=1 --seeds=2 --network=/home/cindyli/stylegan3/training-runs/00016-stylegan3-t-bliss-256x256-gpus1-batch32-gamma2/network-snapshot-004160.pkl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
Pillow | ||
flake8 | ||
|
||
# Used by all image processing scripts | ||
Pillow |