{"id":13553724,"url":"https://github.com/bryandlee/animegan2-pytorch","last_synced_at":"2025-05-14T19:08:07.770Z","repository":{"id":37387474,"uuid":"339378016","full_name":"bryandlee/animegan2-pytorch","owner":"bryandlee","description":"PyTorch implementation of AnimeGANv2","archived":false,"fork":false,"pushed_at":"2023-01-06T10:26:08.000Z","size":39376,"stargazers_count":4428,"open_issues_count":37,"forks_count":649,"subscribers_count":58,"default_branch":"main","last_synced_at":"2025-04-13T13:58:38.461Z","etag":null,"topics":["gan","image2image","style-transfer"],"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/bryandlee.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":"2021-02-16T11:34:21.000Z","updated_at":"2025-04-12T04:21:02.000Z","dependencies_parsed_at":"2023-02-05T21:32:10.635Z","dependency_job_id":null,"html_url":"https://github.com/bryandlee/animegan2-pytorch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryandlee%2Fanimegan2-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryandlee%2Fanimegan2-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryandlee%2Fanimegan2-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryandlee%2Fanimegan2-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bryandlee","download_url":"https://codeload.github.com/bryandlee/animegan2-pytorch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254209859,"owners_count":22032897,"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":["gan","image2image","style-transfer"],"created_at":"2024-08-01T12:02:32.037Z","updated_at":"2025-05-14T19:08:06.367Z","avatar_url":"https://github.com/bryandlee.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook","图像风格","🤖 AI \u0026 LLM (人工智能与大模型)"],"sub_categories":["网络服务_其他"],"readme":"## PyTorch Implementation of [AnimeGANv2](https://github.com/TachibanaYoshino/AnimeGANv2)\n\n\n**Updates**\n\n* `2021-10-17` Add weights for [FacePortraitV2](#additional-model-weights). [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/bryandlee/animegan2-pytorch/blob/main/colab_demo.ipynb)\n\n    ![sample](https://user-images.githubusercontent.com/26464535/142294796-54394a4a-a566-47a1-b9ab-4e715b901442.gif)\n\n* `2021-11-07` Thanks to [ak92501](https://twitter.com/ak92501), a [web demo](https://huggingface.co/spaces/akhaliq/AnimeGANv2) is integrated to [Huggingface Spaces](https://huggingface.co/spaces) with [Gradio](https://github.com/gradio-app/gradio). [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/akhaliq/AnimeGANv2)\n\n* `2021-11-07` Thanks to [xhlulu](https://github.com/xhlulu), the `torch.hub` model is now available. See [Torch Hub Usage](#torch-hub-usage).\n \n \n## Basic Usage\n\n**Inference**\n```\npython test.py --input_dir [image_folder_path] --device [cpu/cuda]\n```\n\n\n## Torch Hub Usage\n\nYou can load the model via `torch.hub`:\n\n```python\nimport torch\nmodel = torch.hub.load(\"bryandlee/animegan2-pytorch\", \"generator\").eval()\nout = model(img_tensor)  # BCHW tensor\n```\n\nCurrently, the following `pretrained` shorthands are available:\n```python\nmodel = torch.hub.load(\"bryandlee/animegan2-pytorch:main\", \"generator\", pretrained=\"celeba_distill\")\nmodel = torch.hub.load(\"bryandlee/animegan2-pytorch:main\", \"generator\", pretrained=\"face_paint_512_v1\")\nmodel = torch.hub.load(\"bryandlee/animegan2-pytorch:main\", \"generator\", pretrained=\"face_paint_512_v2\")\nmodel = torch.hub.load(\"bryandlee/animegan2-pytorch:main\", \"generator\", pretrained=\"paprika\")\n```\n\nYou can also load the `face2paint` util function:\n```python\nfrom PIL import Image\n\nface2paint = torch.hub.load(\"bryandlee/animegan2-pytorch:main\", \"face2paint\", size=512)\n\nimg = Image.open(...).convert(\"RGB\")\nout = face2paint(model, img)\n```\nMore details about `torch.hub` is in [the torch docs](https://pytorch.org/docs/stable/hub.html)\n\n\n## Weight Conversion from the Original Repo (Tensorflow)\n1. Install the [original repo's dependencies](https://github.com/TachibanaYoshino/AnimeGANv2#requirements): python 3.6, tensorflow 1.15.0-gpu\n2. Install torch \u003e= 1.7.1\n3. Clone the original repo \u0026 run\n```\ngit clone https://github.com/TachibanaYoshino/AnimeGANv2\npython convert_weights.py\n```\n\n\u003cdetails\u003e\n\u003csummary\u003esamples\u003c/summary\u003e\n\n\u003cbr\u003e\nResults from converted `Paprika` style model (input image, original tensorflow result, pytorch result from left to right)\n\n\u003cimg src=\"./samples/compare/1.jpg\" width=\"960\"\u003e \u0026nbsp; \n\u003cimg src=\"./samples/compare/2.jpg\" width=\"960\"\u003e \u0026nbsp; \n\u003cimg src=\"./samples/compare/3.jpg\" width=\"960\"\u003e \u0026nbsp; \n   \n\u003c/details\u003e\n \n**Note:** Results from converted weights slightly different due to the [bilinear upsample issue](https://github.com/pytorch/pytorch/issues/10604)\n\n\n## Additional Model Weights\n\n**Webtoon Face** [[ckpt]](https://drive.google.com/file/d/10T6F3-_RFOCJn6lMb-6mRmcISuYWJXGc)\n\n\u003cdetails\u003e\n\u003csummary\u003esamples\u003c/summary\u003e\n\nTrained on \u003cb\u003e256x256\u003c/b\u003e face images. Distilled from [webtoon face model](https://github.com/bryandlee/naver-webtoon-faces/blob/master/README.md#face2webtoon) with L2 + VGG + GAN Loss and CelebA-HQ images.\n\n![face_results](https://user-images.githubusercontent.com/26464535/143959011-1740d4d3-790b-4c4c-b875-24404ef9c614.jpg) \u0026nbsp; \n  \n\u003c/details\u003e\n\n\n**Face Portrait v1** [[ckpt]](https://drive.google.com/file/d/1WK5Mdt6mwlcsqCZMHkCUSDJxN1UyFi0-)\n\n\u003cdetails\u003e\n\u003csummary\u003esamples\u003c/summary\u003e\n\nTrained on \u003cb\u003e512x512\u003c/b\u003e face images.\n\n[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1jCqcKekdtKzW7cxiw_bjbbfLsPh-dEds?usp=sharing)\n  \n![samples](https://user-images.githubusercontent.com/26464535/127134790-93595da2-4f8b-4aca-a9d7-98699c5e6914.jpg)\n\n[📺](https://youtu.be/CbMfI-HNCzw?t=317)\n  \n![sample](https://user-images.githubusercontent.com/26464535/129888683-98bb6283-7bb8-4d1a-a04a-e795f5858dcf.gif)\n\n\u003c/details\u003e\n\n\n**Face Portrait v2** [[ckpt]](https://drive.google.com/uc?id=18H3iK09_d54qEDoWIc82SyWB2xun4gjU)\n\n\u003cdetails\u003e\n\u003csummary\u003esamples\u003c/summary\u003e\n\nTrained on \u003cb\u003e512x512\u003c/b\u003e face images. Compared to v1, `🔻beautify` `🔺robustness` \n\n[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1jCqcKekdtKzW7cxiw_bjbbfLsPh-dEds?usp=sharing)\n  \n![face_portrait_v2_0](https://user-images.githubusercontent.com/26464535/137619176-59620b59-4e20-4d98-9559-a424f86b7f24.jpg)\n\n![face_portrait_v2_1](https://user-images.githubusercontent.com/26464535/137619181-a45c9230-f5e7-4f3c-8002-7c266f89de45.jpg)\n\n🦑 🎮 🔥\n  \n![face_portrait_v2_squid_game](https://user-images.githubusercontent.com/26464535/137619183-20e94f11-7a8e-4c3e-9b45-378ab63827ca.jpg)\n\n\n\u003c/details\u003e\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbryandlee%2Fanimegan2-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbryandlee%2Fanimegan2-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbryandlee%2Fanimegan2-pytorch/lists"}