{"id":22778934,"url":"https://github.com/skytnt/anime-segmentation","last_synced_at":"2025-05-15T10:03:07.770Z","repository":{"id":63643442,"uuid":"524606306","full_name":"SkyTNT/anime-segmentation","owner":"SkyTNT","description":"high-accuracy segmentation for anime character","archived":false,"fork":false,"pushed_at":"2025-01-06T02:59:28.000Z","size":14351,"stargazers_count":703,"open_issues_count":7,"forks_count":69,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-08T20:43:52.963Z","etag":null,"topics":["anime","segmentation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SkyTNT.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}},"created_at":"2022-08-14T07:48:29.000Z","updated_at":"2025-05-07T20:35:40.000Z","dependencies_parsed_at":"2024-12-25T22:07:04.237Z","dependency_job_id":"0af26f80-32d7-446b-8aa0-263ea4f3d779","html_url":"https://github.com/SkyTNT/anime-segmentation","commit_stats":{"total_commits":72,"total_committers":3,"mean_commits":24.0,"dds":0.04166666666666663,"last_synced_commit":"2e295137777e8571ae76b7f926c4dac7c9aebfa9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkyTNT%2Fanime-segmentation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkyTNT%2Fanime-segmentation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkyTNT%2Fanime-segmentation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkyTNT%2Fanime-segmentation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SkyTNT","download_url":"https://codeload.github.com/SkyTNT/anime-segmentation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319716,"owners_count":22051072,"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":["anime","segmentation"],"created_at":"2024-12-11T20:07:19.508Z","updated_at":"2025-05-15T10:02:59.544Z","avatar_url":"https://github.com/SkyTNT.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Anime Segmentation\nSegmentation for anime character\n\n![](./doc/banner.jpg)\n\n## Online Demo\n\nIntegrated into [Huggingface Spaces 🤗](https://huggingface.co/spaces) using [Gradio](https://github.com/gradio-app/gradio). Try it out [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/skytnt/anime-remove-background)\n\n## Support Models\n\n[ISNet](https://github.com/xuebinqin/DIS), [U2Net](https://github.com/xuebinqin/U-2-Net), [MODNet](https://github.com/ZHKKKe/MODNet), [InSPyReNet](https://github.com/plemeri/inspyrenet)\n\n## Download Trained Models\n\nModels can be downloaded [here](https://huggingface.co/skytnt/anime-seg)\n\n## Requirements\n\nYou need to [install pytorch](https://pytorch.org/) first\n\nThen `pip install -r requirements.txt`\n\n## Train\n\n`python train.py --net isnet_is --data-dir path/to/dataset --epoch 1000 --batch-size-train 10 --batch-size-val 4 --workers-train 10 --workers-val 5 --acc-step 3 --benchmark --log-step 10 --val-epoch 3  --img-size 1024`\n\ndetail\n\n```\narguments:\n  -h, --help            show this help message and exit\n  --net {isnet_is,isnet,u2net,u2netl,modnet,inspyrnet_res,inspyrnet_swin}\n                        isnet_is: Train ISNet with intermediate feature supervision,\n                        isnet: Train ISNet,\n                        u2net: Train U2Net full,\n                        u2netl: Train U2Net lite,\n                        modnet: Train MODNet\n                        inspyrnet_res: Train InSPyReNet_Res2Net50\n                        inspyrnet_swin: Train InSPyReNet_SwinB\n  --pretrained-ckpt PRETRAINED_CKPT\n                        load form pretrained ckpt of net\n  --resume-ckpt RESUME_CKPT\n                        resume training from ckpt\n  --img-size IMG_SIZE   image size for training and validation,\n                        1024 recommend for ISNet,\n                        384 recommend for InSPyReNet,\n                        640 recommend for others,\n\n  --data-dir DATA_DIR   root dir of dataset\n  --fg-dir FG_DIR       relative dir of foreground\n  --bg-dir BG_DIR       relative dir of background\n  --img-dir IMG_DIR     relative dir of images\n  --mask-dir MASK_DIR   relative dir of masks\n  --fg-ext FG_EXT       extension name of foreground\n  --bg-ext BG_EXT       extension name of background\n  --img-ext IMG_EXT     extension name of images\n  --mask-ext MASK_EXT   extension name of masks\n  --data-split DATA_SPLIT\n                        split rate for training and validation\n  \n  --lr LR               learning rate\n  --epoch EPOCH         epoch num\n  --gt-epoch GT_EPOCH   epoch for training ground truth encoder when net is isnet_is\n  --batch-size-train BATCH_SIZE_TRAIN\n                        batch size for training\n  --batch-size-val BATCH_SIZE_VAL\n                        batch size for val\n  --workers-train WORKERS_TRAIN\n                        workers num for training dataloader\n  --workers-val WORKERS_VAL\n                        workers num for validation dataloader\n  --acc-step ACC_STEP   gradient accumulation step\n  --accelerator {cpu,gpu,tpu,ipu,hpu,auto}\n                        accelerator\n  --devices DEVICES     devices num\n  --fp32                disable mix precision\n  --benchmark           enable cudnn benchmark\n  --log-step LOG_STEP   log training loss every n steps\n  --val-epoch VAL_EPOCH\n                        valid and save every n epoch\n  --cache-epoch CACHE_EPOCH\n                        update cache every n epoch\n  --cache CACHE         ratio (cache to entire training dataset), higher\n                        value require more memory, set 0 to disable cache\n```\n\n## Inference\n\n`python inference.py --net isnet_is --ckpt path/to/isnet_is.ckpt --data-dir path/to/input_data --out out --img-size 1024 --only-matted`\n\n## Export model\n\n`python export.py --net isnet_is --ckpt path/to/isnet_is.ckpt --to onnx --out isnet.onnx --img-size 1024`\n\n## Dataset\n\nThis dataset is a combined dataset of [AniSeg](https://github.com/jerryli27/AniSeg#about-the-models) and [character_bg_seg_data](https://github.com/ShuhongChen/bizarre-pose-estimator#download).\n\nI clean the dataset using [DeepDanbooru](https://github.com/KichangKim/DeepDanbooru) first then manually, to make sue all mask is anime character.\n\n#### download\n\n```shell\ngit lfs install\ngit clone https://huggingface.co/datasets/skytnt/anime-segmentation\ncd anime-segmentation\nunzip -q 'data/*.zip'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskytnt%2Fanime-segmentation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskytnt%2Fanime-segmentation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskytnt%2Fanime-segmentation/lists"}