upsampling method changed + face model added

This commit is contained in:
sr9 2021-02-21 15:04:52 +09:00
parent 570477276c
commit 7e281802b9
20 changed files with 136 additions and 6 deletions

View File

@ -1,7 +1,13 @@
## PyTorch Implementation of [AnimeGANv2](https://github.com/TachibanaYoshino/AnimeGANv2)
**Weight Conversion (Optional, requires TensorFlow 1.x)**
**Face Model**: Distilled from [this model](https://github.com/bryandlee/naver-webtoon-faces/blob/master/README.md#face2webtoon) with L2 + VGG + GAN Loss and CelebA-HQ images. See `test_faces.ipynb` for the inference. Model file can be downloaded from [here](https://drive.google.com/file/d/10T6F3-_RFOCJn6lMb-6mRmcISuYWJXGc/view?usp=sharing). Enjoy!
<img src="./samples/face_results.jpg" width="512"> &nbsp;
**Weight Conversion from the Original Repo (Requires TensorFlow 1.x)**
```
git clone https://github.com/TachibanaYoshino/AnimeGANv2
python convert_weights.py
@ -12,6 +18,8 @@ python convert_weights.py
python test.py --input_dir [image_folder_path]
```
**Results from converted [[Paprika](https://drive.google.com/file/d/1K_xN32uoQKI8XmNYNLTX5gDn1UnQVe5I/view?usp=sharing)] style model**
(input image, original tensorflow result, pytorch result from left to right)
@ -20,4 +28,4 @@ python test.py --input_dir [image_folder_path]
<img src="./samples/compare/2.jpg" width="960"> &nbsp;
<img src="./samples/compare/3.jpg" width="960"> &nbsp;
**Note:** Training code not included / Tested on RTX3090 + PyTorch1.7.1 / Results slightly different due to the [bilinear upsample issue](https://github.com/pytorch/pytorch/issues/10604)
**Note:** Tested on RTX3090 + PyTorch1.7.1 / Results from converted weights slightly different due to the [bilinear upsample issue](https://github.com/pytorch/pytorch/issues/10604)

View File

@ -93,12 +93,12 @@ class Generator(nn.Module):
out = self.block_b(out)
out = self.block_c(out)
# out = F.interpolate(out, half_size, mode="bilinear", align_corners=True)
out = F.interpolate(out, scale_factor=2, mode="bilinear", align_corners=False)
out = F.interpolate(out, half_size, mode="bilinear", align_corners=True)
# out = F.interpolate(out, scale_factor=2, mode="bilinear", align_corners=False)
out = self.block_d(out)
# out = F.interpolate(out, input.size()[-2:], mode="bilinear", align_corners=True)
out = F.interpolate(out, scale_factor=2, mode="bilinear", align_corners=False)
out = F.interpolate(out, input.size()[-2:], mode="bilinear", align_corners=True)
# out = F.interpolate(out, scale_factor=2, mode="bilinear", align_corners=False)
out = self.block_e(out)
out = self.out_layer(out)

BIN
samples/face_results.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 843 KiB

BIN
samples/faces/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
samples/faces/10.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
samples/faces/11.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
samples/faces/12.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
samples/faces/13.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

BIN
samples/faces/14.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
samples/faces/15.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
samples/faces/16.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
samples/faces/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
samples/faces/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
samples/faces/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
samples/faces/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

BIN
samples/faces/6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
samples/faces/7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
samples/faces/8.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
samples/faces/9.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

122
test_faces.ipynb Normal file

File diff suppressed because one or more lines are too long