MindSpore版的StyleGAN2-ada,以及简单的反投影(使用ModelZoo的VGG16实现lpips loss)以及属性编辑
conda install mindspore=2.1.0 -c mindspore -c conda-forge
pip install torch rich pretty_errors face_alignment dlib tqdm
- 从NVlabs/stylegan2-ada-pytorch获取
stylegan2-ffhq-config-f.pkl
,放置到./ckpt
下, - 从official/cv/VGG/vgg16获取
vgg16_bn_ascend_v170_imagenet2012_official_cv_top1acc74.33_top5acc92.1.ckpt
,改名为vgg16.ckpt
,放置到./ckpt
下。 - 从http://dlib.net/files/获取
shape_predictor_68_face_landmarks.dat.bz2
,解压后将shape_predictor_68_face_landmarks.dat
放置到./ckpt
下。
首先得到mindspore版的权重
python 1.convert-to-mindspore.py
随机生成图片
python 2.generate-using-seeds.py
反投影图片(以obama.png为例)
python 3.project-real-image.py
大量参考了https://github.com/NVlabs/stylegan2-ada-pytorch。
实现不完全正确,可能有精度问题,图像输出和torch版本相差较大,同时自定义算子都采用了最笨的实现方式,速度也慢许多。