├── .editorconfig ├── .gitignore ├── .vscode └── settings.json ├── AnimeGANv3-Python.py ├── License.txt ├── Pipfile ├── Pipfile.lock ├── Readme.md └── models ├── animeganv3_H40_model.onnx ├── animeganv3_H50_model.onnx └── animeganv3_H64_model.onnx /.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_size = 4 9 | indent_style = space 10 | trim_trailing_whitespace = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/python 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=python 4 | 5 | ### Python ### 6 | # Byte-compiled / optimized / DLL files 7 | __pycache__/ 8 | *.py[cod] 9 | *$py.class 10 | 11 | # C extensions 12 | *.so 13 | 14 | # PyInstaller 15 | # Usually these files are written by a python script from a template 16 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 17 | *.manifest 18 | *.spec 19 | 20 | # Installer logs 21 | pip-log.txt 22 | pip-delete-this-directory.txt 23 | 24 | # Unit test / coverage reports 25 | htmlcov/ 26 | .tox/ 27 | .nox/ 28 | .coverage 29 | .coverage.* 30 | .cache 31 | nosetests.xml 32 | coverage.xml 33 | *.cover 34 | *.py,cover 35 | .hypothesis/ 36 | .pytest_cache/ 37 | cover/ 38 | 39 | # Translations 40 | *.mo 41 | *.pot 42 | 43 | # Django stuff: 44 | *.log 45 | local_settings.py 46 | db.sqlite3 47 | db.sqlite3-journal 48 | 49 | # Flask stuff: 50 | instance/ 51 | .webassets-cache 52 | 53 | # Scrapy stuff: 54 | .scrapy 55 | 56 | # Sphinx documentation 57 | docs/_build/ 58 | 59 | # PyBuilder 60 | .pybuilder/ 61 | target/ 62 | 63 | # Jupyter Notebook 64 | .ipynb_checkpoints 65 | 66 | # IPython 67 | profile_default/ 68 | ipython_config.py 69 | 70 | # pyenv 71 | # For a library or package, you might want to ignore these files since the code is 72 | # intended to run in multiple environments; otherwise, check them in: 73 | # .python-version 74 | 75 | # pipenv 76 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 77 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 78 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 79 | # install all needed dependencies. 80 | #Pipfile.lock 81 | 82 | # poetry 83 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 84 | # This is especially recommended for binary packages to ensure reproducibility, and is more 85 | # commonly ignored for libraries. 86 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 87 | #poetry.lock 88 | 89 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 90 | __pypackages__/ 91 | 92 | # Celery stuff 93 | celerybeat-schedule 94 | celerybeat.pid 95 | 96 | # SageMath parsed files 97 | *.sage.py 98 | 99 | # Environments 100 | .env 101 | .venv 102 | env/ 103 | venv/ 104 | ENV/ 105 | env.bak/ 106 | venv.bak/ 107 | 108 | # Spyder project settings 109 | .spyderproject 110 | .spyproject 111 | 112 | # Rope project settings 113 | .ropeproject 114 | 115 | # mkdocs documentation 116 | /site 117 | 118 | # mypy 119 | .mypy_cache/ 120 | .dmypy.json 121 | dmypy.json 122 | 123 | # Pyre type checker 124 | .pyre/ 125 | 126 | # pytype static type analyzer 127 | .pytype/ 128 | 129 | # Cython debug symbols 130 | cython_debug/ 131 | 132 | # PyCharm 133 | # JetBrains specific template is maintainted in a separate JetBrains.gitignore that can 134 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 135 | # and can be added to the global gitignore or merged into this file. For a more nuclear 136 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 137 | #.idea/ 138 | 139 | # End of https://www.toptal.com/developers/gitignore/api/python 140 | 141 | # images 142 | *.jpg 143 | *.JPG 144 | *.jpeg 145 | *.JPEG 146 | *.png 147 | *.PNG 148 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "python.analysis.typeCheckingMode": "basic" 3 | } 4 | -------------------------------------------------------------------------------- /AnimeGANv3-Python.py: -------------------------------------------------------------------------------- 1 | 2 | import argparse 3 | import cv2 4 | import onnxruntime 5 | import numpy as np 6 | import sys 7 | import time 8 | from pathlib import Path 9 | from numpy import floating 10 | from numpy.typing import NDArray 11 | from typing import Any, Literal 12 | 13 | 14 | def LoadImageAsNDArray(path: Path) -> tuple[NDArray[floating[Any]], tuple[int, int]]: 15 | image_mat = cv2.imread(str(path)) 16 | image, width_and_height = PreprocessImage(image_mat) 17 | image = np.asarray(np.expand_dims(image, 0)) 18 | return (image, tuple(width_and_height)) 19 | 20 | def PreprocessImage(image: np.ndarray[int, np.dtype[np.generic]], x32=True) -> tuple[NDArray[floating[Any]], list[int]]: 21 | height, width = image.shape[:2] 22 | if x32: 23 | def to_32s(x): 24 | if x < 256: 25 | return 256 26 | return x - x % 32 27 | image = cv2.resize(image, (to_32s(width), to_32s(height))) 28 | image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB).astype(np.float32) / 127.5 - 1.0 29 | return (image, [width, height]) 30 | 31 | def SaveImage(transform_image_ndarray: NDArray, width_and_height: tuple[int, int], output_image_path: Path) -> None: 32 | transform_image_ndarray = (transform_image_ndarray.squeeze() + 1.0) / 2 * 255 33 | transform_image_ndarray = transform_image_ndarray.astype(np.uint8) 34 | transform_image_ndarray = cv2.resize(transform_image_ndarray, (width_and_height[0], width_and_height[1])) 35 | cv2.imwrite(str(output_image_path), cv2.cvtColor(transform_image_ndarray, cv2.COLOR_RGB2BGR)) 36 | 37 | def TransformImage(input_dir_path: Path, output_dir_path: Path, onnx_model_type: Literal['H40', 'H50', 'H64']) -> None: 38 | 39 | # get input image paths 40 | input_image_paths = [i for i in Path(input_dir_path).glob('**/*.*') if i.suffix.lower() in ('.jpg', '.jpeg', '.png')] 41 | if len(input_image_paths) == 0: 42 | print('Error: No images in ".jpg, ".jpeg", ".png" format in specified directory.') 43 | sys.exit(1) 44 | 45 | # create output dir 46 | output_dir_path.mkdir(parents=True, exist_ok=True) 47 | 48 | # load onnx runtime model 49 | print('Loading ONNX runtime model...') 50 | onnx_path = Path(__file__).resolve().parent / f'models/animeganv3_{onnx_model_type}_model.onnx' 51 | with open(onnx_path, mode='rb') as fp: 52 | onnx = fp.read() 53 | session = onnxruntime.InferenceSession(onnx, providers=['CPUExecutionProvider']) 54 | x = session.get_inputs()[0].name 55 | y = session.get_outputs()[0].name 56 | print('Loaded ONNX runtime model.') 57 | 58 | # start inference 59 | print('Processing...') 60 | total_start_at = time.time() 61 | for input_image_path in input_image_paths: 62 | start_at = time.time() 63 | 64 | # load image as ndarray 65 | image_ndarray, width_and_height = LoadImageAsNDArray(input_image_path) 66 | 67 | # run inference 68 | transform_data = session.run(None, {x: image_ndarray}) 69 | 70 | # save image 71 | output_image_path = output_dir_path / input_image_path.name 72 | SaveImage(transform_data[0], width_and_height, output_image_path) 73 | print(f'Processed image: "{input_image_path}" ({width_and_height[0]}×{width_and_height[1]}) time: {time.time() - start_at:.3f}s') 74 | 75 | total_end_at = time.time() 76 | print(f"Average time per image: {(total_end_at - total_start_at) / len(input_image_paths):.3f}s") 77 | 78 | 79 | if __name__ == '__main__': 80 | 81 | # parse arguments 82 | parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) 83 | parser.add_argument('InputDirPath', help='Image directory path of input source') 84 | parser.add_argument('OutputDirPath', help='Image directory path of output destination') 85 | parser.add_argument('--onnx-model-type', choices=('H40', 'H50', 'H64'), default='H40', help='onnx model type (H40, H50, H64)') 86 | args = parser.parse_args() 87 | 88 | input_dir_path: Path = Path(args.InputDirPath) 89 | output_dir_path: Path = Path(args.OutputDirPath) 90 | onnx_model_type: Literal['H40', 'H50', 'H64'] = args.onnx_model_type 91 | 92 | # start transform 93 | TransformImage(input_dir_path, output_dir_path, onnx_model_type) 94 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2022 tsukumi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /Pipfile: -------------------------------------------------------------------------------- 1 | [[source]] 2 | url = "https://pypi.org/simple" 3 | verify_ssl = true 4 | name = "pypi" 5 | 6 | [packages] 7 | opencv-python = "*" 8 | onnxruntime = "*" 9 | numpy = "*" 10 | 11 | [dev-packages] 12 | 13 | [requires] 14 | python_version = "3.10" 15 | -------------------------------------------------------------------------------- /Pipfile.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_meta": { 3 | "hash": { 4 | "sha256": "2a111cb6ea5d76b83ee2a822e5ad81057900d9624ad9016cdd44fd7211c830a0" 5 | }, 6 | "pipfile-spec": 6, 7 | "requires": { 8 | "python_version": "3.10" 9 | }, 10 | "sources": [ 11 | { 12 | "name": "pypi", 13 | "url": "https://pypi.org/simple", 14 | "verify_ssl": true 15 | } 16 | ] 17 | }, 18 | "default": { 19 | "coloredlogs": { 20 | "hashes": [ 21 | "sha256:612ee75c546f53e92e70049c9dbfcc18c935a2b9a53b66085ce9ef6a6e5c0934", 22 | "sha256:7c991aa71a4577af2f82600d8f8f3a89f936baeaf9b50a9c197da014e5bf16b0" 23 | ], 24 | "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", 25 | "version": "==15.0.1" 26 | }, 27 | "flatbuffers": { 28 | "hashes": [ 29 | "sha256:0ae7d69c5b82bf41962ca5fde9cc43033bc9501311d975fd5a25e8a7d29c1245", 30 | "sha256:71e135d533be527192819aaab757c5e3d109cb10fbb01e687f6bdb7a61ad39d1" 31 | ], 32 | "version": "==2.0.7" 33 | }, 34 | "humanfriendly": { 35 | "hashes": [ 36 | "sha256:1697e1a8a8f550fd43c2865cd84542fc175a61dcb779b6fee18cf6b6ccba1477", 37 | "sha256:6b0b831ce8f15f7300721aa49829fc4e83921a9a301cc7f606be6686a2288ddc" 38 | ], 39 | "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", 40 | "version": "==10.0" 41 | }, 42 | "mpmath": { 43 | "hashes": [ 44 | "sha256:604bc21bd22d2322a177c73bdb573994ef76e62edd595d17e00aff24b0667e5c", 45 | "sha256:79ffb45cf9f4b101a807595bcb3e72e0396202e0b1d25d689134b48c4216a81a" 46 | ], 47 | "version": "==1.2.1" 48 | }, 49 | "numpy": { 50 | "hashes": [ 51 | "sha256:004f0efcb2fe1c0bd6ae1fcfc69cc8b6bf2407e0f18be308612007a0762b4089", 52 | "sha256:09f6b7bdffe57fc61d869a22f506049825d707b288039d30f26a0d0d8ea05164", 53 | "sha256:0ea3f98a0ffce3f8f57675eb9119f3f4edb81888b6874bc1953f91e0b1d4f440", 54 | "sha256:17c0e467ade9bda685d5ac7f5fa729d8d3e76b23195471adae2d6a6941bd2c18", 55 | "sha256:1f27b5322ac4067e67c8f9378b41c746d8feac8bdd0e0ffede5324667b8a075c", 56 | "sha256:22d43376ee0acd547f3149b9ec12eec2f0ca4a6ab2f61753c5b29bb3e795ac4d", 57 | "sha256:2ad3ec9a748a8943e6eb4358201f7e1c12ede35f510b1a2221b70af4bb64295c", 58 | "sha256:301c00cf5e60e08e04d842fc47df641d4a181e651c7135c50dc2762ffe293dbd", 59 | "sha256:39a664e3d26ea854211867d20ebcc8023257c1800ae89773cbba9f9e97bae036", 60 | "sha256:51bf49c0cd1d52be0a240aa66f3458afc4b95d8993d2d04f0d91fa60c10af6cd", 61 | "sha256:78a63d2df1d947bd9d1b11d35564c2f9e4b57898aae4626638056ec1a231c40c", 62 | "sha256:7cd1328e5bdf0dee621912f5833648e2daca72e3839ec1d6695e91089625f0b4", 63 | "sha256:8355fc10fd33a5a70981a5b8a0de51d10af3688d7a9e4a34fcc8fa0d7467bb7f", 64 | "sha256:8c79d7cf86d049d0c5089231a5bcd31edb03555bd93d81a16870aa98c6cfb79d", 65 | "sha256:91b8d6768a75247026e951dce3b2aac79dc7e78622fc148329135ba189813584", 66 | "sha256:94c15ca4e52671a59219146ff584488907b1f9b3fc232622b47e2cf832e94fb8", 67 | "sha256:98dcbc02e39b1658dc4b4508442a560fe3ca5ca0d989f0df062534e5ca3a5c1a", 68 | "sha256:a64403f634e5ffdcd85e0b12c08f04b3080d3e840aef118721021f9b48fc1460", 69 | "sha256:bc6e8da415f359b578b00bcfb1d08411c96e9a97f9e6c7adada554a0812a6cc6", 70 | "sha256:bdc9febce3e68b697d931941b263c59e0c74e8f18861f4064c1f712562903411", 71 | "sha256:c1ba66c48b19cc9c2975c0d354f24058888cdc674bebadceb3cdc9ec403fb5d1", 72 | "sha256:c9f707b5bb73bf277d812ded9896f9512a43edff72712f31667d0a8c2f8e71ee", 73 | "sha256:d5422d6a1ea9b15577a9432e26608c73a78faf0b9039437b075cf322c92e98e7", 74 | "sha256:e5d5420053bbb3dd64c30e58f9363d7a9c27444c3648e61460c1237f9ec3fa14", 75 | "sha256:e868b0389c5ccfc092031a861d4e158ea164d8b7fdbb10e3b5689b4fc6498df6", 76 | "sha256:efd9d3abe5774404becdb0748178b48a218f1d8c44e0375475732211ea47c67e", 77 | "sha256:f8c02ec3c4c4fcb718fdf89a6c6f709b14949408e8cf2a2be5bfa9c49548fd85", 78 | "sha256:ffcf105ecdd9396e05a8e58e81faaaf34d3f9875f137c7372450baa5d77c9a54" 79 | ], 80 | "index": "pypi", 81 | "version": "==1.23.3" 82 | }, 83 | "onnxruntime": { 84 | "hashes": [ 85 | "sha256:00b07118bfe8beb44d6028813f14f1bfe4bd7896ac49be3ad9d76102f11ba744", 86 | "sha256:0a376399d21ea070a173c81aae0901012955afd0acc9e5574d7f22d54ceaff65", 87 | "sha256:0ee2f32e4427005c788ed0c081dc74846b7417600705610648cfe7062c2270e8", 88 | "sha256:25179f463e8f641f7f37963dd13e3561f64d0f733287f3e740352ccba440e9f7", 89 | "sha256:2715aa4d0bc03acf92c79df3d52e7435ea9da3ab2ed2208ad66534a51d2e5de9", 90 | "sha256:3b24c6323e7ae328ede4f76ccf7eb014ce29493cca013edee453e2ff342499b3", 91 | "sha256:4749a89d2f820ae5d80704a55fedd233fa54dd2adaecf4423435eb68207dace7", 92 | "sha256:51a8777018e464b9ba8091c028c53c9f399d64a5994a9ff9f17e88969e62bbe2", 93 | "sha256:64152aae1c6ffd74598775c775b86407df7c4aea01f418db672c0d9d86f641f6", 94 | "sha256:65bdbb27ea50f0f84c2039ea66e97363c6a31022965575bca8e5f220a40b0c5c", 95 | "sha256:76bbd92cbcc5b6b0f893565f072e33f921ae3350a77b74fb7c65757e683516c7", 96 | "sha256:7d9578da310f324eb7fb4014458a50f53e2cbe1eaa98a5ac521675ad7158ca21", 97 | "sha256:84176d930aabbdc6ad93021cf416e58af6a88f1c43a5d921f0b02c82c0491cd1", 98 | "sha256:8c7caab808df8fa323e1cfaced9785cd068d54701f3bf78ae8733e702a053ff4", 99 | "sha256:92d28a7bd547290c0e47d60ca64c52b4976a9bd51622bd83be85bccce316f413", 100 | "sha256:977e4388c773a14cf2f71c6f4ac4f039691ab3ac7ade4e13e7f019d752eaa053", 101 | "sha256:98bb8920036b6ae1bc71af1bb061cd42297717a4b25c0ba521f3471ef946e4f2", 102 | "sha256:9bd0ab5b99ef0d34331fd871603a3fd5f375fb0518bfc5ca09ce48194a813dfa", 103 | "sha256:9c28b8c06df60f986693d35aecc33d9edd494db53ab7915bbe9830c20471d654", 104 | "sha256:a5c4f5332083dd3815b78ddb16d4a0cf4907a59edd956bcfe53992b71b8feac1", 105 | "sha256:a9954f6ffab4a0a3877a4800d817950a236a6db4901399eec1ea52033f52da94", 106 | "sha256:aa5e0653fb7e1a24bb73a378f208b8fd9a7b1622f89f26be093efd93a4fe4f25", 107 | "sha256:c79b15b9136e68eafc0badc88d306c6c794611857c2b573d9cd8ee1dfaf25619", 108 | "sha256:e987ca0206a6dda3d0b70bb3ebee3dc5ff9ea59c6caa7c6586ce5bac87a7f0e3", 109 | "sha256:ef3e24a703fb4896bd0e360dfa4fadd6b2b57f64a05b040e01ab717c4e2d5a0c", 110 | "sha256:f0104e0e8327c8468d646941540af9397b737155dffe078da4bf36da95d1c21e", 111 | "sha256:ff9da60be6c5800dcc10c52dd54aa07ab9a0d86c1e99649881bee9d9838031e0" 112 | ], 113 | "index": "pypi", 114 | "version": "==1.12.1" 115 | }, 116 | "opencv-python": { 117 | "hashes": [ 118 | "sha256:0dc82a3d8630c099d2f3ac1b1aabee164e8188db54a786abb7a4e27eba309440", 119 | "sha256:5af8ba35a4fcb8913ffb86e92403e9a656a4bff4a645d196987468f0f8947875", 120 | "sha256:6e32af22e3202748bd233ed8f538741876191863882eba44e332d1a34993165b", 121 | "sha256:c5bfae41ad4031e66bb10ec4a0a2ffd3e514d092652781e8b1ac98d1b59f1158", 122 | "sha256:dbdc84a9b4ea2cbae33861652d25093944b9959279200b7ae0badd32439f74de", 123 | "sha256:e6e448b62afc95c5b58f97e87ef84699e6607fe5c58730a03301c52496005cae", 124 | "sha256:f482e78de6e7b0b060ff994ffd859bddc3f7f382bb2019ef157b0ea8ca8712f5" 125 | ], 126 | "index": "pypi", 127 | "version": "==4.6.0.66" 128 | }, 129 | "packaging": { 130 | "hashes": [ 131 | "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb", 132 | "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522" 133 | ], 134 | "markers": "python_version >= '3.6'", 135 | "version": "==21.3" 136 | }, 137 | "protobuf": { 138 | "hashes": [ 139 | "sha256:07a0bb9cc6114f16a39c866dc28b6e3d96fa4ffb9cc1033057412547e6e75cb9", 140 | "sha256:308173d3e5a3528787bb8c93abea81d5a950bdce62840d9760effc84127fb39c", 141 | "sha256:4143513c766db85b9d7c18dbf8339673c8a290131b2a0fe73855ab20770f72b0", 142 | "sha256:49f88d56a9180dbb7f6199c920f5bb5c1dd0172f672983bb281298d57c2ac8eb", 143 | "sha256:6b1040a5661cd5f6e610cbca9cfaa2a17d60e2bb545309bc1b278bb05be44bdd", 144 | "sha256:77b355c8604fe285536155286b28b0c4cbc57cf81b08d8357bf34829ea982860", 145 | "sha256:7a6cc8842257265bdfd6b74d088b829e44bcac3cca234c5fdd6052730017b9ea", 146 | "sha256:80e6540381080715fddac12690ee42d087d0d17395f8d0078dfd6f1181e7be4c", 147 | "sha256:8f9e60f7d44592c66e7b332b6a7b4b6e8d8b889393c79dbc3a91f815118f8eac", 148 | "sha256:9666da97129138585b26afcb63ad4887f602e169cafe754a8258541c553b8b5d", 149 | "sha256:aa29113ec901281f29d9d27b01193407a98aa9658b8a777b0325e6d97149f5ce", 150 | "sha256:b6cea204865595a92a7b240e4b65bcaaca3ad5d2ce25d9db3756eba06041138e", 151 | "sha256:ba596b9ffb85c909fcfe1b1a23136224ed678af3faf9912d3fa483d5f9813c4e", 152 | "sha256:c7c864148a237f058c739ae7a05a2b403c0dfa4ce7d1f3e5213f352ad52d57c6" 153 | ], 154 | "markers": "python_version >= '3.7'", 155 | "version": "==4.21.6" 156 | }, 157 | "pyparsing": { 158 | "hashes": [ 159 | "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb", 160 | "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc" 161 | ], 162 | "markers": "python_full_version >= '3.6.8'", 163 | "version": "==3.0.9" 164 | }, 165 | "pyreadline3": { 166 | "hashes": [ 167 | "sha256:6f3d1f7b8a31ba32b73917cefc1f28cc660562f39aea8646d30bd6eff21f7bae", 168 | "sha256:b0efb6516fd4fb07b45949053826a62fa4cb353db5be2bbb4a7aa1fdd1e345fb" 169 | ], 170 | "markers": "python_version >= '3.8' and sys_platform == 'win32'", 171 | "version": "==3.4.1" 172 | }, 173 | "sympy": { 174 | "hashes": [ 175 | "sha256:938f984ee2b1e8eae8a07b884c8b7a1146010040fccddc6539c54f401c8f6fcf", 176 | "sha256:e32380dce63cb7c0108ed525570092fd45168bdae2faa17e528221ef72e88658" 177 | ], 178 | "markers": "python_version >= '3.8'", 179 | "version": "==1.11.1" 180 | } 181 | }, 182 | "develop": {} 183 | } 184 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | 2 | # AnimeGANv3-Python 3 | 4 | A command-line tool that transforms photos into an anime look using ONNX Runtime trained models of [AnimeGANv3](https://github.com/TachibanaYoshino/AnimeGANv3). 5 | Based on the inference process of [AnimeGANv3.exe](https://github.com/TachibanaYoshino/AnimeGANv3/blob/master/AnimeGANv3/AnimeGANv3.exe). 6 | 7 | ## Install 8 | 9 | It is written in Python, so it is cross-platform. 10 | However, it consumes a large amount of CPU and memory because inference is performed on the CPU. 11 | 12 | Requirements: Python 3.10 / pip / pipenv 13 | 14 | ```bash 15 | # clone code 16 | git clone https://github.com/tsukumijima/AnimeGANv3-Python.git 17 | cd AnimeGANv3-Python 18 | 19 | # install pipenv 20 | pip install pipenv 21 | 22 | # run pipenv sync 23 | ## Windows (PowerShell) 24 | $env:PIPENV_VENV_IN_PROJECT="true"; pipenv sync 25 | ## Linux 26 | PIPENV_VENV_IN_PROJECT="true" pipenv sync 27 | ``` 28 | 29 | ## Usage 30 | 31 | ```bash 32 | # run AnimeGANv3-Python.py inside pipenv 33 | pipenv run python AnimeGANv3-Python.py C:/path/to/input_images C:/path/to/output_images --onnx-model-type H40 34 | ``` 35 | 36 | ``` 37 | usage: AnimeGANv3-Python.py [-h] [--onnx-model-type {H40,H50,H64}] InputDirPath OutputDirPath 38 | 39 | positional arguments: 40 | InputDirPath Image directory path of input source 41 | OutputDirPath Image directory path of output destination 42 | 43 | options: 44 | -h, --help show this help message and exit 45 | --onnx-model-type {H40,H50,H64} 46 | onnx model type (H40, H50, H64) 47 | ``` 48 | 49 | ## Examples 50 | 51 | ⬅ original photo | transform into anime look ➡ 52 | 53 | ![example_01](https://user-images.githubusercontent.com/39271166/191425491-2900b532-e5b4-497a-9b3c-d539fdec8469.jpg) 54 | ![example_02](https://user-images.githubusercontent.com/39271166/191425500-726c1691-7b84-4e1b-8f06-9ce60cddb7c4.jpg) 55 | ![example_03](https://user-images.githubusercontent.com/39271166/191425514-179d30f9-adc8-4c33-a8e1-cf590ffb08ff.jpg) 56 | ![example_04](https://user-images.githubusercontent.com/39271166/191425533-5d530f6f-b19a-419f-9952-86c334540c0f.jpg) 57 | ![example_05](https://user-images.githubusercontent.com/39271166/191425459-e6aded57-9eae-4885-8d64-4ad9f471a665.jpg) 58 | ![example_06](https://user-images.githubusercontent.com/39271166/191425470-ecab3470-e6c6-4465-8771-37de595f3079.jpg) 59 | ![example_07](https://user-images.githubusercontent.com/39271166/191425480-41273edb-1f88-43dd-a32f-1434be0b5234.jpg) 60 | ![example_08](https://user-images.githubusercontent.com/39271166/191425483-da3d9d3c-74fc-4e71-8de4-05ec0a51f27e.jpg) 61 | 62 | ## License 63 | 64 | [MIT License](License.txt) 65 | -------------------------------------------------------------------------------- /models/animeganv3_H40_model.onnx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zunan-islands/AnimeGANv3-Python/92ed749f58febad059bfb49127cff53bef5ab931/models/animeganv3_H40_model.onnx -------------------------------------------------------------------------------- /models/animeganv3_H50_model.onnx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zunan-islands/AnimeGANv3-Python/92ed749f58febad059bfb49127cff53bef5ab931/models/animeganv3_H50_model.onnx -------------------------------------------------------------------------------- /models/animeganv3_H64_model.onnx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zunan-islands/AnimeGANv3-Python/92ed749f58febad059bfb49127cff53bef5ab931/models/animeganv3_H64_model.onnx --------------------------------------------------------------------------------