{"id":23739867,"url":"https://github.com/p1atdev/wd-tagger-rs","last_synced_at":"2025-07-27T11:38:27.857Z","repository":{"id":253248706,"uuid":"842931305","full_name":"p1atdev/wd-tagger-rs","owner":"p1atdev","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-30T21:35:48.000Z","size":260,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-22T00:47:50.408Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/p1atdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2024-08-15T12:19:34.000Z","updated_at":"2024-08-30T21:35:51.000Z","dependencies_parsed_at":"2024-08-15T14:06:27.893Z","dependency_job_id":"978434ae-1eee-4156-8f6e-b6e4d62c37c1","html_url":"https://github.com/p1atdev/wd-tagger-rs","commit_stats":null,"previous_names":["p1atdev/wd-tagger-rs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p1atdev%2Fwd-tagger-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p1atdev%2Fwd-tagger-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p1atdev%2Fwd-tagger-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p1atdev%2Fwd-tagger-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p1atdev","download_url":"https://codeload.github.com/p1atdev/wd-tagger-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231970931,"owners_count":18453925,"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":[],"created_at":"2024-12-31T09:39:37.178Z","updated_at":"2025-07-27T11:38:27.850Z","avatar_url":"https://github.com/p1atdev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wd-tagger-rs\n\nAn inference tool of [WaifuDiffusion Tagger](https://huggingface.co/spaces/SmilingWolf/wd-tagger).\n\n\u003e [!IMPORTANT]\n\u003e WIP. \n\n## Usage\n\nYou need Rust toolchain:\n\nSee https://www.rust-lang.org/tools/install\n\n### With CPU (recommended)\n\nTo install:\n\n```bash\ncargo install --git https://github.com/p1atdev/wd-tagger-rs\n```\n\nTo run:\n\n```bash\ntagger v3 ./assets/sample1_3x1024x1024.webp\n```\n\nOutput:\n\n```\n[src/main.rs:183:13] result = TaggingResult {\n    rating: {\n        \"general\": 0.91256857,\n    },\n    character: {},\n    general: {\n        \"1girl\": 0.996445,\n        \"solo\": 0.977317,\n        \"double_bun\": 0.94901526,\n        \"hair_bun\": 0.94456,\n        \"twintails\": 0.9389738,\n        \"pink_hair\": 0.93058735,\n        \"fang\": 0.8859673,\n        \"smile\": 0.88062656,\n        \"pink_eyes\": 0.8463925,\n        \"looking_at_viewer\": 0.83266306,\n...\n```\n\n\n### With CoreML\n\n#### Build\n\nInstall with `--features coreml` flag:\n\n```bash\ncargo install --git https://github.com/p1atdev/wd-tagger-rs \\\n  --features coreml\n```\n\nThen you can run as the same as the CPU version:\n\n```bash\ntagger v3 ./assets/sample1_3x1024x1024.webp\n```\n\n\n## Models\n\n### v3 family\n\nYou can use v3 family models with the `tagger v3` command, and you can specify the model with the `--model` option.\n\n- `--model`\n  - `vit`: SmilingWolf/wd-vit-tagger-v3\n  - `swin-v2`: SmilingWolf/wd-swin-v2-tagger-v3 (default)\n  - `convnext`: SmilingWolf/wd-convnext-tagger-v3\n  - `vit-large`: SmilingWolf/wd-vit-large-tagger-v3\n  - `eva02-large`: SmilingWolf/wd-eva02-large-tagger-v3\n\nExample:\n```bash\ntagger v3 ./assets/sample1_3x1024x1024.webp --model eva02-large\n```\n\nSee `tagger v3 --help` for more details.\n\n### Run custom models\n\nYou can use the custom models with `tagger custom` command, that is on HuggingFace and the same format of the original model.\n\n- Example: [deepghs/idolsankaku-eva02-large-tagger-v1](https://huggingface.co/deepghs/idolsankaku-eva02-large-tagger-v1)\n\n```bash\ntagger custom ./assets/sample1_3x1024x1024.webp \\\n  --repo-id deepghs/idolsankaku-eva02-large-tagger-v1 \n```\n\n```bash\nTarget device: \u003cCPU\u003e\n[src/cli/main.rs:112:13] \u0026result = TaggingResult {\n    rating: {\n        \"safe\": 0.94494337,\n    },\n    character: {},\n    general: {\n        \"twintails\": 0.95630574,\n        \"pink_hair\": 0.91894686,\n        \"female\": 0.8313366,\n        \"solo\": 0.8135544,\n        \"1girl\": 0.74666,\n        \"looking_at_viewer\": 0.6675732,\n        \"ribbon\": 0.6159363,\n        \"asian\": 0.52826667,\n        \"female_only\": 0.5272801,\n        \"double_bun\": 0.46635512,\n        \"long_hair\": 0.42993295,\n        \"blouse\": 0.41456583,\n        \"east_asian\": 0.37745702,\n        \"japanese\": 0.35556853,\n    },\n}\n```\n\nSee `tagger custom --help` for more details.\n\n## Save the prediction result\n\n### as JSON\n\nIf you specified `--output` option, tagger will save the result as JSON in default.\n\n```bash\ntagger v3 ./assets/sample1_3x1024x1024.webp \\\n  --output ./output.json\n```\n\nOr you can specify the output format explicitly:\n\n```bash\ntagger v3 ./assets/sample1_3x1024x1024.webp \\\n  --output ./output.json \\\n  --format json\n```\n\nThe json file includes all of the prediction results. For example: \n\n```json\n{\n  \"rating\": {\n    \"sensitive\": 0.086992234,\n    \"general\": 0.9125686,\n    \"questionable\": 0.0006592274,\n    \"explicit\": 0.0001244545\n  },\n  \"character\": {\n    \"celestia_ludenberg\": 7.4505806e-7,\n    \"usami_sumireko\": 0.0000015199184,\n    \"japanese_crested_ibis_(kemono_friends)\": 5.364418e-7,\n    // ... about 2400 lines left\n  },\n  \"general\": {\n    \"breathing_fire\": 0.0000025331974,\n    \"horse_tail\": 0.0000015795231,\n    \"grey_hoodie\": 0.0000023841858,\n    \"green_ribbon\": 0.0002577901,\n    \"stand_(jojo)\": 5.066395e-7,\n    \"yellow_pupils\": 0.000052034855,\n    \"cat_ear_panties\": 2.9802322e-8,\n    // ... about 8000 lines left\n  }\n}\n```\n\n\n### as Caption\n\nYou can specify the output format by `--format caption`:\n\n```bash\ntagger v3 ./assets/sample1_3x1024x1024.webp \\\n  --output ./output.txt \\\n  --format caption\n```\n\nIf you don't specify the `--output` option, tagger will save to the same directory of the input file.\n\n```bash\ntagger v3 ./assets/sample1_3x1024x1024.webp \\\n  --format caption\n```\n\nTagger saves to `./assets/sample1_3x1024x1024.txt`.\n\nThe caption file includes the only above the threshold (default to 0.35) tags. For example:\n\n```\n1girl, solo, double_bun, hair_bun, twintails, pink_hair, fang, smile, pink_eyes, looking_at_viewer, upper_body, long_hair, pink_theme, open_mouth, shirt, simple_background, skin_fang, pink_background, blush, :d, neck_ribbon, collared_shirt, ribbon, jacket, sidelocks, pink_shirt, cardigan, general\n```\n\n\n## Other experimental execution devices\n\n### With CUDA \n\n#### Prerequisites\n\n##### cuDNN\n\ncuDDN 9.x **MUST** be installed. You can get it from here:\n\nhttps://developer.nvidia.com/cudnn-downloads\n\n##### onnxruntime \n\nDownlaod prebuilt onnxruntime from ONNX Runtime's releases. (e.g. `onnxruntime-linux-x64-gpu-1.19.0.tgz`):\n\nhttps://github.com/microsoft/onnxruntime/releases/tag/v1.19.0 \n\nThen extract it and place files to `~/.local/share`, and set `LD_LIBRARY_PATH`.\n\nFor example:\n\n```bash\nwget https://github.com/microsoft/onnxruntime/releases/download/v1.19.0/onnxruntime-linux-x64-gpu-1.19.0.tgz\ntar -xvf onnxruntime-linux-x64-gpu-1.19.0.tgz\nmkdir -p ~/.local/share/wdtagger/onnxruntime\nmv onnxruntime-linux-x64-gpu-1.19.0 ~/.local/share/wdtagger/onnxruntime/1.19.0\nrm onnxruntime-linux-x64-gpu-1.19.0.tgz\n```\n\nAdd the following to your `.bashrc` or `.zshrc`:\n\n```bash\n# wdtagger\nexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/.local/share/wdtagger/onnxruntime/1.19.0/lib\n```\n\n\u003e [!NOTE]\n\u003e Please check that you are specifying the `lib` directory, not the root directory of the extracted onnxruntime.\n\nTo apply:\n\n```bash\nsource ~/.bashrc\n```\n\n#### Build\n\nTo build:\n\n```bash\ncargo install --path . --features cuda\n```\n\nTo run:\n\n```bash\ntagger v3 ./assets/sample1_3x1024x1024.webp \\\n    --devices 0 \\\n    --model vit-large # vit, swin-v2, convnext, vit-large, eva02-large\n```\n\n#### Docker\n\nThis is just PoC.\n\nUsing docker:\n\n```yml\nservices:\n  cuda:\n    build:\n      context: .\n      dockerfile: ./docker/Dockerfile.cuda\n    deploy:\n      resources:\n        reservations:\n          devices:\n            - driver: nvidia\n              count: 1\n              capabilities: [gpu]\n    volumes:\n      - type: bind\n        source: ./assets\n        target: /workspace/assets\n      - type: bind # to use huggingface cache\n        source: ~/.cache/huggingface\n        target: /root/.cache/huggingface\n\n    command: [\"./tagger\"] \n```\n\nTo run:\n\n```bash\ndocker compose run cuda ./tagger ./assets/sample1_3x1024x1024.webp \n```\n\nTo down:\n```bash\ndocker compose down --remove-orphans\n```\n\n### With TensorRT \n\n#### Prerequisites\n\n##### TensorRT\n\nYou need at least `libnvinfer`. You can get it from here:\n\nhttps://developer.nvidia.com/tensorrt/download/10x\n\n#### Build\n\n```bash\ncargo install --path . --features tensorrt\n```\n\n```bash\ntagger v3 ./assets/sample1_3x1024x1024.webp \\\n    --devices 0 \\\n    --model eva02-large\n```\n\n\u003e [!NOTE]\n\u003e Currently TensorRT mode is not so fast as CUDA mode.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp1atdev%2Fwd-tagger-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp1atdev%2Fwd-tagger-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp1atdev%2Fwd-tagger-rs/lists"}