Giter Site home page Giter Site logo

generators-with-stylegan2's Introduction

基于StyleGAN2的新版人脸生成器

Read English Introduction:Here

  这儿是一批基于StyleGAN2制作的新版人脸生成器,既包含基于旧版重制的网红脸明星脸超模脸萌娃脸黄种人脸生成器,也新增了两款更具美学意义的混血脸亚洲美人脸生成器,并附赠有通配的人脸属性编辑器。做了这么多款生成器已经足够用,我将不再尝试做人脸生成器相关的新内容,而是去探索更实用、更能满足用户需求的生成技术,以更好地服务人民(譬如Video-Auto-Wipe可以了解一下)。
  生成器的作用是可提供我们各种样式的人脸素材,供我们在多种场景下应用并有助于节省寻找真人(人脸)的成本,值得注意的是,每张人脸都是不存在于这个世界上的AI虚拟人物,他们独特且永不重复。




新版的提升与价值何在?

  基于StyleGAN2制作的版本消除了图片中水滴斑点和扭曲/损坏现象的出现,使生成的成功率接近100%(可参见下方随机生成的数据集),能被应用于大批量生成任务之中;另外图片的质量进一步提升,清晰度已逼近于官方训练所采用的数据集。我希望,这个项目能为影视、广告、游戏和医美工作者们助力,同时为普通爱好者们赋能。
  此项目已大部分免费开源,希望能帮助到有需要的朋友。模型版权所有为:www.seeprettyface.com,已完全开放给大家,请在合理的范围内使用。若对您有帮助欢迎在底部给予小小的赞助~



效果预览

网红脸生成器

  Image text

  Image text

  纯随机生成(无筛选)的一万张生成图片数据集:https://pan.baidu.com/s/1AqlNlTY0-tbEORPuKLdkqg 提取码:c7v9

明星脸生成器

  Image text

  Image text

  纯随机生成(无筛选)的一万张生成图片数据集:https://pan.baidu.com/s/1LabQMFLsKkYK3hLgRCQ-0A 提取码:p43h

超模脸生成器

  Image text

  Image text

  纯随机生成(无筛选)的一万张生成图片数据集:https://pan.baidu.com/s/1AT4q1JkMvAxWrHMs4Af1wg 提取码:vxf4

萌娃脸生成器

  Image text

  Image text

  纯随机生成(无筛选)的一万张生成图片数据集:https://pan.baidu.com/s/1CQYQFiIdXxCSjJwSUo_tvw 提取码:4bd0

黄种人脸生成器

  Image text

  Image text

  纯随机生成(无筛选)的一万张生成图片数据集:https://pan.baidu.com/s/1uC5fQ4UTALA1uU36Cgnnnw 提取码:rqvq

混血人脸生成器(非开源)

  你知道长得最好看的人脸是什么样吗?我将**明星脸生成器与世界超模脸生成器按精心调制的比例融合起来,制作出了此混血人脸生成器。此生成器合成的人脸具备独特且卓绝的美学风格(用户的评价是“马夸特面具融入了东方人的韵味”),是我认为目前AI画出的最好看的人脸生成器。然而此生成器已被买断属于非卖品。
  Image text

  Image text


亚洲美人脸生成器(非开源)

  有趣的事情是,在我开源完上述生成器后,一名视觉杂志社的主编找到我,说想一起探讨是否能做出更有辨识度和“惊艳感”的人脸生成器——因为只有在美学上AI能超越人类的话,这种技术才能有效冲击传统的视觉行业——因为这意味着人们能够花最低的成本获取最优质的资源。更有利的一点是,杂志社有优质的图像素材资源,而我有多变的训练技巧,于是我们合作,做出了这一款“亚洲美人脸”生成器,下面展示一些生成器合成的人脸素材。

港式美人脸

  Image text

日式美人脸

  Image text

如果您想作图可以在这个接口取得图片,接口截断率=0.8




电商定制(非开源)

  对于跨境电商来说,通常需要大量定制化的模特素材,例如黑人模特:

Image text


总结

  上述这么多生成器看着有点可怕,但其实它离真正的商用之路还早着很呢(Model-Swap-Face是一种可能的方向?)。。如果真想冲击传统视觉行业的话,至少有两个问题亟待解决:1.相关配套技术有待完善,譬如人脸植入、妆容精细控制、动画及全身合成等等;2.如何围绕精细的用户群构建特定的生成技术服务体系也有待探索。

环境配置

  · Both Linux and Windows are supported. Linux is recommended for performance and compatibility reasons.
  · 64-bit Python 3.6 installation. We recommend Anaconda3 with numpy 1.14.3 or newer.
  · TensorFlow 1.14 or 1.15 with GPU support. The code does not support TensorFlow 2.0.
  · On Windows, you need to use TensorFlow 1.14 — TensorFlow 1.15 will not work.
  · One or more high-end NVIDIA GPUs, NVIDIA drivers, CUDA 10.0 toolkit and cuDNN 7.5. To reproduce the results reported in the paper, you need an NVIDIA GPU with at least 16 GB of DRAM.
  · Docker users: use the provided Dockerfile to build an image with the required library dependencies.
  - On Windows, the compilation requires Microsoft Visual Studio to be in PATH. We recommend installing Visual Studio Community Edition and adding into PATH using "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat".
  我的测试环境配置为:Win10,1050Ti,CUDA 10.0,CuDNN 7.6.5,tensorflow-gpu 1.14.0,VS2017可完美运行。

Windows下常见问题 :Could not find MSVC/GCC/CLANG installation on this computer如何解决?

  在安装VS2017/VS2019时一定要将‘使用C++的桌面开发’选上(如下图所示) Image text   装好之后进入C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/ 目录下会有一个版本号的文件夹,将版本替换为dnnlib/tflib/custom_ops.py 29行的对应版本号(那是我安装的版本),如下图所示。 Image text

运行步骤

  1.在networks文件夹中按照txt地址下载对应模型,放在该位置
  2.在main.py中选择对应的模型和生成数量(另如果觉得生成的多样性不够可以尝试调高truncation_psi,不过成功率会下降),并运行main.py



赠品:基于StyleGAN2的属性编辑器

  基于StyleGAN2的属性编辑器(edit_photo.py)包含了与旧版属性编辑器基本相同的内容,含有21种可调整的方向,可实现简单的人脸属性编辑。此属性编辑器适用于此项目的所有生成器(即黄种人、网红脸、明星脸、超模脸、萌娃脸、混血脸和亚洲美人脸)以及官方生成器。

调整样例


下述样例均采用黄种人脸生成器。

1.调整笑容

Image text


2.调整年龄

Image text


3.调整水平角度

Image text


4.调整竖直角度

Image text


5.调整性别

Image text


6.调整颜值

Image text


7.调整脸型

Image text


8.调整眼睛开合

Image text


9.调整是否佩戴眼镜

Image text


10.增添/减弱一些生气的情绪

Image text


11.增添/减弱一些厌恶的情绪

Image text


12.增添/减弱一些害怕的情绪

Image text


13.增添/减弱一些开心的情绪

Image text


14.增添/减弱一些沮丧的情绪

Image text


15.增添/减弱一些惊讶的情绪

Image text


16.增添/减弱一些平静的情绪

Image text


17.调整脸的宽度

Image text


18调整脸的高度

Image text


19.调整向黑种人衍变

Image text


20.调整向黄种人衍变

Image text


21.调整向白种人衍变

Image text





了解技术原理 & 获取训练集:点此进入

Sample





小小的赞助~

Sample

若对您有帮助可给予小小的赞助~




generators-with-stylegan2's People

Contributors

a312863063 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

generators-with-stylegan2's Issues

Numpy1.14.3 不可使用

Numpy1.14.3 生成和编辑均不可使用
提示
(face) C:\Users\Administrator\AIFACE\generators-with-stylegan2-master>python main.py
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
ImportError: numpy.core.multiarray failed to import

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "", line 968, in _find_and_load
SystemError: <class '_frozen_importlib._ModuleLockManager'> returned a result with an error set
ImportError: numpy.core._multiarray_umath failed to import
ImportError: numpy.core.umath failed to import
2020-09-04 16:46:22.413086: F tensorflow/python/lib/core/bfloat16.cc:675] Check failed: PyBfloat16_Type.tp_base != nullptr

Numpy1.19.1 可以生成,但编辑模式不行并有以下提示
sys:1: FutureWarning: arrays to stack must be passed as a "sequence" type such as list or tuple. Support for non-sequence iterables such as generators is deprecated as of NumPy 1.16 and will raise an error in the future.
(此版本一开始成功编辑过几次,突然跳出这提示,之后不管整个环境重装几次都是不行了,网上有人说是模型的问题,重新放模型也无法解决)

Numpy从1.14 ~1.19 都逐个安装了还是不行,1.6以下的提示都和1.14.3提示一样,超过1.6的提示都和1.19.1的提示一样

求公开训练生成器

可以公开一下那两个没有公开的的训练模型
1.黄金比例混血脸生成器(generator_mixed-blood-stylegan2-config-f.pkl)
2.亚洲美人脸生成器(generator_trendy-beauty-stylegan2-config-f.pkl)

Can't download files in the internet folder

Hi, thanks for the wonderful projects, I have a problem to download the models in the internet folder even using vpn. They always stop downloading after I downloaded about 200-300M. I was wondering if you could provide a baidupan links for those who are blocked by the great wall. Thanks a lot.
Xiaohong Zhao

人脸合成

想请教一下,人脸合成可以修改头发长短的属性吗,或者说怎么生成短发的图片

It's just stuck here. I can't make a picture

(stylegan2) hujinhong@xdcs:~/pc/generators-with-stylegan2-master$ python main.py Loading networks from "networks/generator_yellow-stylegan2-config-f.pkl"... Setting up TensorFlow plugin "fused_bias_act.cu": Preprocessing... Loading... Done. Setting up TensorFlow plugin "upfirdn_2d.cu": Preprocessing... Loading... Done. Generating image 0/20 ...
It's just stuck here. I can't make a picture

tensorflow-gpu 版本问题

现在安装的cuda是10.2的,安装tensorflow-gpu==1.14.0之后运行报错
ImportError: Could not find 'cudart64_100.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 10.0 from this URL: https://developer.nvidia.com/cuda-90-download-archive
更换1.15.0后报错
FileNotFoundError: [Errno 2] No such file or directory: 'networks/generator_yellow-stylegan2-config-f.pkl'
更换2.1.0后报错
ModuleNotFoundError: No module named 'tensorflow.contrib'
大佬能不能对cuda和tensorflow高版本做个适配,秋梨膏

安装CUDA10.1及对应CUDNN后,运行报错:GPU找不到(已解决)

我安装了CUDA10.1、10.0及对应的CUDNN,首先切换到10.1的使用状态中,运行程序报类似GPU找不到的错误信息;

切换到10.0的使用状态中,又将numpy的版本从1.9降到和作者要求差不多的1.4.6后,以及VS2019后,GPU没问题了,运行报CUDA10.0支持VS最高到2017版本,我的是2019所以不支持;

更换到VS2017后,终于运行成功,出现了人脸合成图片。

感谢作者大大!

WIN10 RTX 3060 配置清单

本人是心理学系的菜鸟,折腾了几天才跑通,分享一下自己的配置

WIN10 + RTX3060 + VS2019 + python3.7 + cuda11.2 + cudnn8.1.0 + tensorflow1.15

ANACONDA 虚拟环境下跑通。

坑1: 30系显卡 cuda版本必须高于11
坑2:11以上的cuda版本必须搭配2以上的tensorflow,但是这套代码不支持2以上版本tensorflow,因此这里用一个大神的魔改的tensorflow1.15可以跑通https://zhuanlan.zhihu.com/p/356526953
坑3: “无法打开包括文件: 'tensorflow/core/framework/op.h'”,参考这个链接可以解决https://blog.csdn.net/qq_39024280/article/details/111904417
坑4:annaconda虚拟环境下用conda命令安装cuda,无法使用nvcc,会报错,我不懂咋解决,就直接下载了11.2的安装包,全局安装。

How to make a customized generator ?

Hi there. Thanks for sharing this amazing project.

I'm curious about your process of making these specialized generators.

Did you use the original StyleGAN FFHQ network to train on a hand-picked data set ? Or did you train the network from scratch with the data images you collected from the Internet ? How did you gather those specialized data set ?

Also from what I saw from your research notes in your website, you talked about the combination of InfoGAN and StyleGAN. What's that about ?

Lastly, can you show me how you trained all those specialized latent directions ?

Many thanks.

关于混血人脸的申请

作者你好,我们是浙江理工大学应用心理学系的本科生。我们正在做面孔的实验,可能需要使用到您提供的混血生成器,但是在你的仓库里面并没有找到这个生成器,不知道是否能提供一些混血的照片,用作于实验研究。

人脸覆盖

怎么让每次生成的图片不会覆盖掉前一次生成的图片

每次循环,只有第一张图片能正常生成

比如设为20,只有第一张是人脸,其它的全都是横状彩色波纹。其实第一张图片也有比较小的概率失败,不过从图案上看至少还能看到人脸的轮廓,其它的图就全是毫无意义的图案了。

加了点日志瞧了下,从运行时间上看,第一张图要15分钟(3070),剩下的图都是200毫秒内就结束了。

是否有其他人也遇到类似情况呢?

环境:3070, win10, anaconda python 3.7, vs2017. 脚本探测出来的GPU最高能力是sm_8x,nvcc不认识,手动降了档,试过75、72、61、62,都是一样的错误情况。

很好用,就是黄种人生成器不太像东亚人

首先非常感谢作者的免费分享,文档写的也很详细,发这个就是想提醒一下跟我有同样用途的人。
我是做心理学面孔研究的,想在这里获取高质量的**人图片。生成图片的质量确实非常高,是midjourney, stable diffusion这种当下最流行的AI绘画软件完全无法比拟的,但是问题就是生成的面孔更像东南亚人,不像东亚的。

另外面孔多样性也非常欠缺,特别是男性,许多男性长相都类似图里这个样子,导致连起来看像族谱。细节方面,大家的鼻子都长得差不多,每个人都有大卧蚕。

image

nncv :command not found

您好,我在允许main.py后出现了nvcc命令找不到的错误,请问是需要安装什么包吗 我是在ubuntu下面进行实验的

如何真实编辑真实人脸

作者的工作着实令人震撼,btw,能否请教以下如何编辑真实图片啊,我试了一些方案,迭代优化的w+时间太慢了要2分钟,并且控制表情太顿,笑得也不好看, 基于模型预测隐码的方式,重构图与原图不怎么像,怎么弄比较好,希望得到贵人的指导

训练使用的神经网络

您好, 我在尝试还原您的整个神经网络用来训练还原图片的decoder。请问您在训练时使用的是最原本的nvlab的tf版本的stylegan2的网络嘛

运行报错

Generating image 0/20 ...
Traceback (most recent call last):
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1356, in _do_call
return fn(*args)
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1341, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1429, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: No OpKernel was registered to support Op 'FusedBiasAct' used by {{node Gs/_Run/Gs/G_mapping/Dense0/FusedBiasAct}}with these attrs: [gain=1.41421354, T=DT_FLOAT, axis=1, grad=0, alpha=0.2, act=3]
Registered devices: [CPU, XLA_CPU, XLA_GPU]
Registered kernels:
device='GPU'; T in [DT_HALF]
device='GPU'; T in [DT_FLOAT]

     [[Gs/_Run/Gs/G_mapping/Dense0/FusedBiasAct]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "main.py", line 55, in
main()
File "main.py", line 52, in main
generate_images(network_pkl, generate_num)
File "main.py", line 39, in generate_images
images = Gs.run(z, None, **Gs_kwargs) # [minibatch, height, width, channel]
File "/home/aistudio/generators-with-stylegan2/dnnlib/tflib/network.py", line 442, in run
mb_out = tf.get_default_session().run(out_expr, dict(zip(in_expr, mb_in)))
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 950, in run
run_metadata_ptr)
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1173, in _run
feed_dict_tensor, options, run_metadata)
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1350, in _do_run
run_metadata)
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1370, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: No OpKernel was registered to support Op 'FusedBiasAct' used by node Gs/_Run/Gs/G_mapping/Dense0/FusedBiasAct (defined at :96) with these attrs: [gain=1.41421354, T=DT_FLOAT, axis=1, grad=0, alpha=0.2, act=3]
Registered devices: [CPU, XLA_CPU, XLA_GPU]
Registered kernels:
device='GPU'; T in [DT_HALF]
device='GPU'; T in [DT_FLOAT]

     [[Gs/_Run/Gs/G_mapping/Dense0/FusedBiasAct]]

Errors may have originated from an input operation.
Input Source operations connected to node Gs/_Run/Gs/G_mapping/Dense0/FusedBiasAct:
Gs/_Run/Gs/G_mapping/Dense0/Const (defined at /home/aistudio/generators-with-stylegan2/dnnlib/tflib/ops/fused_bias_act.py:105)
Gs/_Run/Gs/G_mapping/Dense0/MatMul (defined at :46)
Gs/_Run/Gs/G_mapping/Dense0/mul_1 (defined at :67)

数据集获取细节

您好,非常感谢您的开源项目,从中学到了很多东西!
想请教在爬取得到图片后,需要使用 dlib 进行人脸的抠取,之后是否需要对人脸边框进行一定的扩大呢?根据您的经验,扩大比例为多少较为合适呢?

无法复现网红模型结果

我用原始的10w+张网红数据集,基于style2官方源码训练框架,不管是在stylegan2-ffhq-config-f.pkl或者generator_wanghong-stylegan2-config-f.pkl模型上refine,很快清晰度就会下降,面部的立体感、发丝很明显不如generator_wanghong-stylegan2-config-f.pkl的效果,也调了下参数,感觉还是难以复现。能请教下其中的训练技巧吗

TF2.x

请问有兴趣和计划升级到TF2吗?

训练

您好,有幸看到您做的效果,实在太惊人,不知可否提供下您所写的训练代码呢?
本人邮箱:[email protected]

Pose modifying the face??

Hi @a312863063.
Your repos and the continuity in the work and datasets everything is awesome.
I have cloned your repo and taken your latent representations. I want to change pose positions of a human face horizontally, vertically (yaw, roll). I checked the results. The pose was changing. But also face structure is also changing. How can i get the face different poses (20 degrees rotation, 30 ...)without modifying face???

Thanks in Advance.

Regards,
SandhyaLaxmi

latent_direction的通用性

Hi 想请问下为什么您生成的编辑方向,对不同的generator是同一套也能编辑呢?

我理解编辑方向对不同的生成器,应该是不同的会比较合理?不知道您git里的latent_directions是用哪个生成器做的,又为什么能用到其他生成器呢?

谢谢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.