# 论文复现:Encoding in Style: a StyleGAN Encoder for Image-to-Image Translation
- paddle-PSP
This project is based on the pixel2style2pixel (pSp). pSp framework generates a series of style vectors based on a novel encoder network, which is fed into a pre-trained style generator to form an extended W + potential space. The encoder can directly reconstruct real input images.
- [1] Richardson E , Alaluf Y , Patashnik O , et al. Encoding in Style: a StyleGAN Encoder for Image-to-Image Translation[J]. 2020.
Model | LPIPS | Similarity | MSE |
---|---|---|---|
Paper | 0.17 | 0.56 | 0.03 |
Pytorch | 0.15 | 0.57 | 0.03 |
Paddle | 0.17 | 0.57 | 0.03 |
Pytorch | Paddle |
---|---|
Hardware:GPU、CPU
Framework:PaddlePaddle >=2.0.0
Pretrained models saved inpretrained_models/
.
Pretrained models | Description |
---|---|
FFHQ StyleGAN(stylegan2-ffhq-config-f.pdparams) | StyleGAN trained with the FFHQ dataset fromrosinality ,output size:1024x1024 |
IR-SE50 Model(model_ir_se50.pdparams) | IR_SE model (TreB1eN)trained for computering ID loss. |
CurricularFace Backbone(CurricularFace_Backbone.paparams) | Pretrained CurricularFace model(HuangYG123)evaled Similarity |
AlexNet(alexnet.pdparams和lin_alex.pdparams) | computered lpips loss |
StyleGAN Inversion(psp_ffhq_inverse.pdparams) | pSp trained with the FFHQ dataset for StyleGAN inversion. |
Baidu driver:https://pan.baidu.com/s/1G-Ffs8-y93R0ZlD9mEU6Eg password:m3nb
Pretrained pSp encoder:
模型 | Description |
---|---|
StyleGAN Inversion(psp_ffhq_inverse.pdparams) | pSp trained with the FFHQ dataset for StyleGAN inversion. |
python scripts/compile_ranger.py
python scripts/train.py \
--dataset_type=ffhq_encode \
--exp_dir=exp/test \
--workers=0 \
--batch_size=8 \
--test_batch_size=8 \
--test_workers=0 \
--val_interval=2500 \
--save_interval=5000 \
--encoder_type=GradualStyleEncoder \
--start_from_latent_avg \
--lpips_lambda=0.8 \
--l2_lambda=1 \
--id_lambda=0.1 \
--optim_name=ranger
python scripts/inference.py \
--exp_dir=inference \
--checkpoint_path=pretrained_models/psp_ffhq_inverse.pdparams \
--data_path=CelebA_test \
--test_batch_size=8 \
--test_workers=4
- LPIPS
python scripts/calc_losses_on_images.py \
--mode lpips \
--data_path=inference/inference_results \
--gt_path=CelebA_test
- MSE
python scripts/calc_losses_on_images.py \
--mode l2 \
--data_path=inference/inference_results \
--gt_path=CelebA_test
- Similarity
python scripts/calc_id_loss_parallel.py \
--data_path=inference/inference_results \
--gt_path=CelebA_test
├─config # 配置
├─data #数据集加载
├─CelebA_test # 测试数据图像
├─logs #日志
├─train # 训练日志
├─test # 测试日志
├─models # 模型
├─encoders # 编码器
├─loss # 损失函数
├─mtcnn #
├─stylegan2 #
├─utils # 编译算子
├─scripts #算法执行
trian #训练
inference #测试
├─utils # 工具代码
│ README.md #英文readme
│ README_cn.md #中文readme
Parameter | Default |
---|---|
Config | None |
The overall information of the model is as follows:
Information | Descriptions |
---|---|
Version | Paddle 2.1.2 |
Application | Image Generation |
Hardware | GPU / CPU |
# encoding=utf8
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.