{"id":18552972,"url":"https://github.com/lunarwhite/gen-anime-face","last_synced_at":"2025-06-13T18:36:15.227Z","repository":{"id":39717190,"uuid":"373345800","full_name":"lunarwhite/gen-anime-face","owner":"lunarwhite","description":"Train GAN model ref NTU MLDS. 李宏毅老师的二次元人脸/头像数据集","archived":false,"fork":false,"pushed_at":"2024-10-26T02:26:01.000Z","size":155,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T15:52:32.096Z","etag":null,"topics":["acg","animation","deep-learning","keras","python","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lunarwhite.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-06-03T01:20:00.000Z","updated_at":"2024-10-26T02:25:59.000Z","dependencies_parsed_at":"2024-05-21T06:46:18.041Z","dependency_job_id":"481beb0e-8fd6-4c6f-9dbb-ce1e6586f7c2","html_url":"https://github.com/lunarwhite/gen-anime-face","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lunarwhite/gen-anime-face","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunarwhite%2Fgen-anime-face","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunarwhite%2Fgen-anime-face/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunarwhite%2Fgen-anime-face/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunarwhite%2Fgen-anime-face/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lunarwhite","download_url":"https://codeload.github.com/lunarwhite/gen-anime-face/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunarwhite%2Fgen-anime-face/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259699780,"owners_count":22898332,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acg","animation","deep-learning","keras","python","tensorflow"],"created_at":"2024-11-06T21:15:41.368Z","updated_at":"2025-06-13T18:36:15.185Z","avatar_url":"https://github.com/lunarwhite.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gen-anime-face\n\n![GitHub Repo stars](https://img.shields.io/github/stars/lunarwhite/gen-anime-face?color=orange)\n![GitHub watchers](https://img.shields.io/github/watchers/lunarwhite/gen-anime-face?color=yellow)\n![GitHub forks](https://img.shields.io/github/forks/lunarwhite/gen-anime-face?color=green)\n![GitHub top language](https://img.shields.io/github/languages/top/lunarwhite/gen-anime-face)\n![GitHub License](https://img.shields.io/github/license/lunarwhite/gen-anime-face?color=white)\n\nGAN-based image generation of animated/ACGN faces. 基于李宏毅老师的二次元人脸/头像数据集，应用训练GAN，实现二次元人脸生成\n\n```\n.\n├── LICENSE\n├── main.py\n├── README.md\n├── requirements.txt\n├── res\n│   └── image # 数据集\n└── tmp # 保存 model 图片\n```\n\n## 1 Overview\n\n- 数据初始来源：[MakeGirlsMoe](https://make.girls.moe/#/)\n- 数据集下载：[Kaggle](https://www.kaggle.com/lunarwhite/anime-face-dataset-ntumlds)\n- 选择 GAN 搭建模型，借助 Keras 搭建训练\n- 主要工具包版本为 TensorFlow `2.2.0`、和 Python `3.7.10`\n\n## 2 Setup\n\n- clone repo：`git clone https://github.com/lunarwhite/gen-anime-face.git`\n- 更新 pip：`pip3 install --upgrade pip`\n- 为项目创建虚拟环境：`conda create --name \u003cenv_name\u003e python=3.7`\n- 激活 env：`conda activate \u003cenv_name\u003e`\n- 安装 Python 库依赖：`pip3 install -r requirements.txt`\n\n## 3 Train\n\n- 运行：`python main.py`\n- 调参：在 `main.py` 文件中修改常用参数\n  ```python\n  def main():\n      gan = GAN(\n          optimizer = Adam(0.0002, 0.5), # 优化方法，初始学习率\n          loss=\"binary_crossentropy\" # 损失函数\n      )\n      gan.train(\n          epochs=300, # 训练轮数\n          batch_size=32, # 一次训练所抓取的数据样本数量\n          sample_interval=50 # 多少个 epoch之 后 save 一次实验结果\n      )\n  ```\n\n## 4 Workflow\n\n- 观察数据\n  - 数据集大小\n  - 数据集样本\n  - 图像分辨率\n- 数据预处理\n  - 归一化\n- 搭建模型\n  - Update discriminator # do not update the parameters of generator\n    - real_images = `sample_batch_data(training_data, batch_size)`\n    - noise = `sample_batch_noise(batch_size, noise_dim)`\n    - fake_images = `generator(noise)`\n    - real_predicts = `discriminator(real_images)`\n    - fake_predicts = `discriminator(fake_images)`\n    - d_loss = `loss_d_fn(real_predicts, real_labels, fake_predicts, fake_labels)`\n    - d_grad = `gradients(d_loss, d_params)`\n    - d_params = `updates(d_params, d_grad)`\n  - Update Generator # do not update the parameters of discriminator\n    - noise = `sample_batch_noise(noise_dim, batch_size)`\n    - fake_images = `generator(noise)`\n    - fake_predicts = `discriminator(fake_images)`\n    - g_loss = `loss_g_fn( fake_predicts, real_labels)`\n    - g_grad = `gradients(g_loss, g_params)`\n    - g_params = `updates(g_params, g_grad)`\n- 可视化分析\n  - 模型可视化\n- 改进模型\n  - 1: Normalize the inputs\n  - 2: A modified loss function\n  - 4: BatchNorm\n  - 5: Avoid Sparse Gradients: ReLU, MaxPool\n  - 6: Use Soft and Noisy Labels\n  - 9: Use the ADAM Optimizer\n  - 10: Track failures early\n  - 13: Add noise to inputs, decay over time\n  - 17: Use Dropouts in G in both train and test phase\n\n## 5 Reference\n\n- [How to Train a GAN? Tips and tricks to make GANs work](https://github.com/soumith/ganhacks)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flunarwhite%2Fgen-anime-face","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flunarwhite%2Fgen-anime-face","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flunarwhite%2Fgen-anime-face/lists"}