{"id":13690404,"url":"https://github.com/jayleicn/animeGAN","last_synced_at":"2025-05-02T11:31:20.754Z","repository":{"id":38897712,"uuid":"83440490","full_name":"jayleicn/animeGAN","owner":"jayleicn","description":"A simple PyTorch Implementation of Generative Adversarial Networks, focusing on anime face drawing.","archived":false,"fork":false,"pushed_at":"2022-08-24T04:29:50.000Z","size":16997,"stargazers_count":1281,"open_issues_count":6,"forks_count":197,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-04-12T11:55:37.863Z","etag":null,"topics":["dataset","generative-adversarial-network","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/jayleicn.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}},"created_at":"2017-02-28T14:15:55.000Z","updated_at":"2025-04-02T07:31:16.000Z","dependencies_parsed_at":"2022-07-13T16:44:37.116Z","dependency_job_id":null,"html_url":"https://github.com/jayleicn/animeGAN","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayleicn%2FanimeGAN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayleicn%2FanimeGAN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayleicn%2FanimeGAN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayleicn%2FanimeGAN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jayleicn","download_url":"https://codeload.github.com/jayleicn/animeGAN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252030170,"owners_count":21683301,"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":["dataset","generative-adversarial-network","pytorch"],"created_at":"2024-08-02T17:00:16.687Z","updated_at":"2025-05-02T11:31:17.678Z","avatar_url":"https://github.com/jayleicn.png","language":"Jupyter Notebook","readme":"# AnimeGAN\n\n\u003e A simple PyTorch Implementation of  Generative Adversarial Networks, focusing on anime face drawing.\n\n### Randomly Generated Images\n\nThe images are generated from a DCGAN model trained on 143,000 anime character faces for 100 epochs.\n\n![fake_sample_1](images/fake_sample.png)\n\n\n### Image Interpolation\n\nManipulating latent codes, enables the transition from images in the first row to the last row.\n\n![transition](images/fake_transition.png)\n\n\n\n### Original Images\n\nThe images are not clean, some outliers can be observed, which degrades the quality of the generated images.\n\n![real_sample](images/real_sample.png)\n\n\n\n### Usage\n\nTo run the experiment, \n\n```bash\n$ python main.py --dataRoot path_to_dataset/ \n```\n\nThe pretrained model for DCGAN are also in this repo, play it inside the jupyter notebook.\n\n\n\n### anime-faces Dataset\n\nAnime-style images  of 126 tags are collected from [danbooru.donmai.us](http://danbooru.donmai.us/) using the crawler tool [gallery-dl](https://github.com/mikf/gallery-dl). The images are then processed by a anime face detector [python-animeface](https://github.com/nya3jp/python-animeface). The resulting dataset contains ~143,000 anime faces. Note that some of the tags may no longer meaningful after cropping, i.e. the cropped face images under 'uniform' tag may not contain visible parts of uniforms.\n\n\u003e How to construct the dataset from scratch ?\n\n  Prequisites: gallery-dl, python-animeface\n\n1. Download anime-style images \n\n   ```bash\n   # download 1000 images under the tag \"misaka_mikoto\"\n   gallery-dl --images 1000 \"https://danbooru.donmai.us/posts?tags=misaka_mikoto\"\n\n   # in a multi-processing manner\n   cat tags.txt | \\\n   xargs -n 1 -P 12 -I 'tag' \\ \n   bash -c ' gallery-dl --images 1000 \"https://danbooru.donmai.us/posts?tags=$tag\" '\n   ```\n\n2. Extract faces from the downloaded images\n\n   ```python\n   import animeface\n   from PIL import Image\n\n   im = Image.open('images/anime_image_misaka_mikoto.png')\n   faces = animeface.detect(im)\n   x,y,w,h = faces[0].face.pos\n   im = im.crop((x,y,x+w,y+h))\n   im.show() # display\n   ```\n\n\nI've cleaned the original dataset, the new version of the dataset has\n115085 images in 126 tags. You can access the images from:\n- GitHub: https://github.com/jayleicn/animeGAN/releases/tag/data\n- BaiduYun: https://pan.baidu.com/s/1o8Nxllo\n\nNon-commercial use please.\n\n### Things I've learned\n1. GANs are really hard to train.\n2. DCGAN generally works well, simply add fully-connected layers causes problems.\n3. In my cases, more layers for G yields better images, in the sense that G should be more powerful than D.\n4. Add noise to D's inputs and labels helps stablize training.\n5. Use differnet input and generate resolution (64x64 vs 96x96), there seems no obvious difference during training, the generated images are also very similar.\n6. Binray Noise as G's input amazingly works, but the images are not as good as those with Gussian Noise, idea credit to @cwhy ['Binary Noise' here I mean a sequence of {-1,1} generated by bernoulli distribution at p=0.5 ]\n\nI did not carefully verify them, if you are looking for some general GAN tips, see @soumith's [ganhacks](https://github.com/soumith/ganhacks)\n\n### Others\n\n1. This project is heavily influenced by [chainer-DCGAN](https://github.com/mattya/chainer-DCGAN) and [IllustrationGAN](https://github.com/tdrussell/IllustrationGAN), the codes are mostly borrowed from [PyTorch DCGAN example](https://github.com/pytorch/examples/tree/master/dcgan), thanks the authors for the clean codes.\n2. Dependencies: pytorch, torchvision\n3. This is a toy project for me to learn PyTorch and GANs, most importantly, for fun! :) Any feedback is welcome.\n\n@jayleicn\n","funding_links":[],"categories":["Network Implementations","Applications using GANs","Projects","Paper implementations｜论文实现","Paper implementations"],"sub_categories":["PyTorch","Anime character generation","GANs","Other libraries｜其他库:","Other libraries:"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjayleicn%2FanimeGAN","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjayleicn%2FanimeGAN","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjayleicn%2FanimeGAN/lists"}