How to use from
Docker Model Runner
docker model run hf.co/damoncao/Anime_Image2Prompt
Quick Links

Anime_Image2Prompt

English | ไธญๆ–‡่ฏดๆ˜Ž

English

Model overview

Anime_Image2Prompt is a Qwen3.5-2B-based vision-language model that converts a single anime, illustration, or anime-style image into Danbooru-style prompt tags. It separates general visual attributes, character identities, and copyrights/franchises, making it useful for image organization, dataset annotation, and prompt extraction in generative-image workflows.

The repository contains all weights required for inference; no base model or separate adapter is needed. The model is stored in BF16, occupies approximately 4.12 GiB, and has 2,213,241,664 parameters. The included program loads local files from this directory by default.

Original-to-regeneration comparison

The following two pairs demonstrate the complete workflow. 01.png and 02.png are the original images. Each original was processed by Anime_Image2Prompt, and the extracted prompt was passed without manual rewriting directly to WAI-illustrious-SDXL v15.0. The resulting images are 01-regen.png and 02-regen.png, respectively.

01 ยท Original 01 ยท Prompt regeneration
Example 01 original Example 01 prompt regeneration
02 ยท Original 02 ยท Prompt regeneration
Example 02 original Example 02 prompt regeneration

These examples illustrate how the model captures major semantics such as character identity, clothing, scene, and composition. Prompt regeneration is not image-to-image or pixel-level reconstruction; the final image also depends on the generation model, random seed, and sampling settings.

Output format

The model's native output is a fixed JSON object:

{
  "general_tags": ["1girl,long hair,blue eyes"],
  "character_tags": ["example character"],
  "copyright_tags": ["example copyright"]
}
  • general_tags: counts, appearance, clothing, actions, composition, and scene attributes.
  • character_tags: character names recognized by the model.
  • copyright_tags: recognized works or franchises.
  • Each non-empty category contains one comma-separated string. An unknown category is returned as an empty array, [].

The included program can also combine all categories into a flat prompt:

1girl, long hair, blue eyes, example character, example copyright

Requirements

  • Python 3.10 or newer; Python 3.11 is recommended.
  • An NVIDIA GPU with at least 8 GB of VRAM is recommended. More VRAM provides additional headroom.
  • CPU inference is supported but slow; at least 16 GB of system RAM is recommended.
  • The weight file is larger than 4 GB. Use a large-file-capable filesystem such as NTFS, exFAT, APFS, or ext4 instead of FAT32.

Installation

Create a virtual environment inside the model directory:

python -m venv .venv

Windows PowerShell:

.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

Linux / macOS:

source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

If you need a specific CUDA build, install the PyTorch build matching your GPU driver from the official PyTorch selector before installing the remaining requirements.

Quick start

The script resides beside the model files, so no model path is required:

python inference.py /path/to/image.png

The default output is structured JSON. Save it to a file with:

python inference.py /path/to/image.png --output result.json

Print a flat, copy-ready prompt instead:

python inference.py /path/to/image.png --format prompt

Useful options:

# Force CPU inference
python inference.py image.png --device cpu

# Reduce image tokens and peak VRAM usage
python inference.py image.png --low-vram

# Show every option
python inference.py --help

The program applies EXIF orientation and RGB conversion automatically and accepts common image formats supported by Pillow. Model loading uses local_files_only=True, so it does not download additional weights.

Python API

from inference import AnimeImage2Prompt

tagger = AnimeImage2Prompt()
result = tagger.predict("image.png")

print(result)
print(tagger.to_prompt(result))

Reuse the same AnimeImage2Prompt instance for multiple images to avoid reloading the model.

Limitations

  • The model is intended primarily for anime and illustration images. Performance may degrade on photographs or images far outside its training distribution.
  • Tags are not guaranteed to be exhaustive or correct. Character and franchise recognition can be especially uncertain.
  • The model may return tags describing sensitive content. Apply content filtering appropriate to your use case and follow applicable laws and platform policies.
  • Do not use the model as the sole basis for safety moderation, identity decisions, or other high-impact decisions.

License

This repository is released under the Apache License 2.0. See LICENSE for details.


ไธญๆ–‡่ฏดๆ˜Ž

ๆจกๅž‹็ฎ€ไป‹

Anime_Image2Prompt ๆ˜ฏไธ€ไธชๅŸบไบŽ Qwen3.5-2B ็š„ๅŠจๆผซๅ›พๅƒ็†่งฃๆจกๅž‹๏ผŒๅฏๅฐ†ๅ•ๅผ ๅŠจๆผซใ€ๆ’็”ปๆˆ–ไบŒๆฌกๅ…ƒ้ฃŽๆ ผๅ›พ็‰‡่ฝฌๆขไธบ Danbooru ้ฃŽๆ ผ็š„ๆ็คบ่ฏใ€‚ๆจกๅž‹ไผšๅˆ†ๅˆซ่ฏ†ๅˆซ็”ป้ข้€š็”จ็‰นๅพใ€่ง’่‰ฒๅ็งฐๅ’Œไฝœๅ“ๆฅๆบ๏ผŒ้€‚ๅˆ็”จไบŽๅ›พ็‰‡ๅฝ’ๆกฃใ€ๆ•ฐๆฎ้›†ๆ ‡ๆณจๅ’Œ็”Ÿๆˆๅผๅ›พๅƒๅทฅไฝœๆตไธญ็š„ๆ็คบ่ฏๆๅ–ใ€‚

ๆจกๅž‹ๆƒ้‡ๅทฒๅฎŒๆ•ดๅŒ…ๅซๅœจๆœฌไป“ๅบ“ไธญ๏ผŒๆ— ้œ€้ขๅค–ไธ‹่ฝฝๅŸบ็ก€ๆจกๅž‹ๆˆ–้€‚้…ๅ™จใ€‚ๆƒ้‡ไปฅ BF16 ไฟๅญ˜๏ผŒ็บฆ 4.12 GiB๏ผŒๅ…ฑ 2,213,241,664 ไธชๅ‚ๆ•ฐใ€‚ๆŽจ็†็จ‹ๅบ้ป˜่ฎคๅช่ฏปๅ–ๅฝ“ๅ‰็›ฎๅฝ•ไธญ็š„ๆœฌๅœฐๆ–‡ไปถใ€‚

ๅŽŸๅ›พไธŽๆ็คบ่ฏ้‡็ป˜ๅฏนๆฏ”

ไธ‹้ขๅฑ•็คบไธค็ป„็ซฏๅˆฐ็ซฏๆ•ˆๆžœๅฏนๆฏ”ใ€‚01.png ๅ’Œ 02.png ๆ˜ฏๅŽŸๅ›พ๏ผ›ๅค„็†ๆต็จ‹ไธบ๏ผšๅฐ†ๅŽŸๅ›พ่พ“ๅ…ฅ Anime_Image2Prompt๏ผŒๆŠŠๆจกๅž‹ๆๅ–ๅ‡บ็š„ๆ็คบ่ฏไธ็ปไบบๅทฅๆ”นๅ†™๏ผŒ็›ดๆŽฅไบค็ป™ WAI-illustrious-SDXL v15.0 ็ป˜ๅˆถ๏ผŒๅฏนๅบ”็ป“ๆžœๅˆ†ๅˆซไธบ 01-regen.png ๅ’Œ 02-regen.pngใ€‚

01 ยท ๅŽŸๅ›พ 01 ยท ๆ็คบ่ฏ้‡็ป˜
็คบไพ‹ 01 ๅŽŸๅ›พ ็คบไพ‹ 01 ๆ็คบ่ฏ้‡็ป˜็ป“ๆžœ
02 ยท ๅŽŸๅ›พ 02 ยท ๆ็คบ่ฏ้‡็ป˜
็คบไพ‹ 02 ๅŽŸๅ›พ ็คบไพ‹ 02 ๆ็คบ่ฏ้‡็ป˜็ป“ๆžœ

่ฟ™ไบ›็คบไพ‹็”จไบŽ่ง‚ๅฏŸๆจกๅž‹ๅฏน่ง’่‰ฒใ€ๆœ้ฅฐใ€ๅœบๆ™ฏๅ’Œๆž„ๅ›พ็ญ‰ไธป่ฆ่ฏญไน‰็š„ๆๅ–่ƒฝๅŠ›ใ€‚ๆ็คบ่ฏ้‡็ป˜ๅนถ้žๅ›พ็”Ÿๅ›พๆˆ–ๅƒ็ด ็บงๅคๅˆป๏ผŒๅ…ทไฝ“็”ป้ขไปไผšๅ—ๅˆฐ็ป˜ๅ›พๆจกๅž‹ใ€้šๆœบ็งๅญๅ’Œ้‡‡ๆ ทๅ‚ๆ•ฐๅฝฑๅ“ใ€‚

่พ“ๅ‡บๆ ผๅผ

ๆจกๅž‹ๅŽŸ็”Ÿ่พ“ๅ‡บๅ›บๅฎšไธบ JSON๏ผš

{
  "general_tags": ["1girl,long hair,blue eyes"],
  "character_tags": ["example character"],
  "copyright_tags": ["example copyright"]
}
  • general_tags๏ผšไบบ็‰ฉๆ•ฐ้‡ใ€ๅค–่ง‚ใ€ๆœ้ฅฐใ€ๅŠจไฝœใ€ๆž„ๅ›พๅ’Œๅœบๆ™ฏ็ญ‰้€š็”จๆ ‡็ญพใ€‚
  • character_tags๏ผšๆจกๅž‹่ƒฝๅคŸ่ฏ†ๅˆซ็š„่ง’่‰ฒๅ็งฐใ€‚
  • copyright_tags๏ผšๆจกๅž‹่ƒฝๅคŸ่ฏ†ๅˆซ็š„ไฝœๅ“ๆˆ–็ณปๅˆ—ๅ็งฐใ€‚
  • ๆฏไธช้ž็ฉบ็ฑปๅˆซๅŒ…ๅซไธ€ไธชไปฅ่‹ฑๆ–‡้€—ๅท่ฟžๆŽฅ็š„ๅญ—็ฌฆไธฒ๏ผ›ๆ— ๆณ•่ฏ†ๅˆซๆ—ถ่ฟ”ๅ›ž็ฉบๆ•ฐ็ป„ []ใ€‚

้š้™„็จ‹ๅบไนŸๅฏไปฅๆŠŠไธ‰ไธช็ฑปๅˆซๅˆๅนถไธบๅธธ็”จ็š„ๆ‰ๅนณๆ็คบ่ฏ๏ผš

1girl, long hair, blue eyes, example character, example copyright

็Žฏๅขƒ่ฆๆฑ‚

  • Python 3.10 ๆˆ–ๆ›ด้ซ˜็‰ˆๆœฌ๏ผŒๆŽจ่ Python 3.11ใ€‚
  • ๆŽจ่ไฝฟ็”จๅ…ทๆœ‰ 8 GB ๆˆ–ๆ›ดๅคšๆ˜พๅญ˜็š„ NVIDIA GPU๏ผ›ๆ˜พๅญ˜่ถŠๅคง๏ผŒ่ฟ่กŒ่ถŠ็จณๅฎšใ€‚
  • CPU ๅฏไปฅ่ฟ่กŒ๏ผŒไฝ†้€Ÿๅบฆ่พƒๆ…ข๏ผŒๅปบ่ฎฎ่‡ณๅฐ‘ๅ‡†ๅค‡ 16 GB ็ณป็ปŸๅ†…ๅญ˜ใ€‚
  • ๆจกๅž‹ๆ–‡ไปถๅคงไบŽ 4 GB๏ผŒ่ฏทไฝฟ็”จ NTFSใ€exFATใ€APFSใ€ext4 ็ญ‰ๆ”ฏๆŒๅคงๆ–‡ไปถ็š„ๆ–‡ไปถ็ณป็ปŸ๏ผŒไธ่ฆไฝฟ็”จ FAT32ใ€‚

ๅฎ‰่ฃ…

ๅœจๆจกๅž‹็›ฎๅฝ•ไธญๅˆ›ๅปบ่™šๆ‹Ÿ็Žฏๅขƒๅนถๅฎ‰่ฃ…ไพ่ต–๏ผš

python -m venv .venv

Windows PowerShell๏ผš

.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

Linux / macOS๏ผš

source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

ๅฆ‚ๆžœ้œ€่ฆ็‰นๅฎš CUDA ็‰ˆๆœฌ๏ผŒ่ฏทๅ…ˆๆŒ‰็…ง PyTorch ๅฎ˜ๆ–นๅฎ‰่ฃ…่ฏดๆ˜Ž ๅฎ‰่ฃ…ไธŽๆ˜พๅก้ฉฑๅŠจๅŒน้…็š„ PyTorch๏ผŒๅ†ๆ‰ง่กŒไพ่ต–ๅฎ‰่ฃ…ๅ‘ฝไปคใ€‚

ๅฟซ้€Ÿไฝฟ็”จ

ๆŽจ็†่„šๆœฌไธŽๆจกๅž‹ๆ”พๅœจๅŒไธ€็›ฎๅฝ•๏ผŒๅ› ๆญคๆ— ้œ€ๅกซๅ†™ๆจกๅž‹่ทฏๅพ„๏ผš

python inference.py /path/to/image.png

้ป˜่ฎคๅœจ็ปˆ็ซฏ่พ“ๅ‡บ็ป“ๆž„ๅŒ– JSONใ€‚ไฟๅญ˜็ป“ๆžœ๏ผš

python inference.py /path/to/image.png --output result.json

็›ดๆŽฅ่พ“ๅ‡บๅฏๅคๅˆถ็š„ๆ‰ๅนณๆ็คบ่ฏ๏ผš

python inference.py /path/to/image.png --format prompt

ๅธธ็”จ้€‰้กน๏ผš

# ๅผบๅˆถไฝฟ็”จ CPU
python inference.py image.png --device cpu

# ้™ไฝŽๅ›พๅƒ token ๆ•ฐไปฅๅ‡ๅฐ‘ๅณฐๅ€ผๆ˜พๅญ˜ๅ ็”จ
python inference.py image.png --low-vram

# ๆŸฅ็œ‹ๅ…จ้ƒจๅ‚ๆ•ฐ
python inference.py --help

็จ‹ๅบไผš่‡ชๅŠจๅค„็†ๅ›พ็‰‡็š„ EXIF ๆ–นๅ‘ๅนถ่ฝฌๆขไธบ RGB๏ผŒๆ”ฏๆŒ Pillow ๅฏ่ฏปๅ–็š„ๅธธ่งๅ›พ็‰‡ๆ ผๅผใ€‚ๅŠ ่ฝฝๆจกๅž‹ๆ—ถไฝฟ็”จ local_files_only=True๏ผŒไธไผš่”็ฝ‘ไธ‹่ฝฝๅ…ถไป–ๆƒ้‡ใ€‚

Python ่ฐƒ็”จ

from inference import AnimeImage2Prompt

tagger = AnimeImage2Prompt()
result = tagger.predict("image.png")

print(result)
print(tagger.to_prompt(result))

ๅŒไธ€ไธช AnimeImage2Prompt ๅฎžไพ‹ๅฏ่ฟž็ปญๅค„็†ๅคšๅผ ๅ›พ็‰‡๏ผŒๆจกๅž‹ๅชไผšๅŠ ่ฝฝไธ€ๆฌกใ€‚

ไฝฟ็”จ้™ๅˆถ

  • ๆœฌๆจกๅž‹ไธป่ฆ้ขๅ‘ๅŠจๆผซๅ’Œๆ’็”ปๅ›พ็‰‡๏ผŒ็œŸๅฎž็…ง็‰‡ๆˆ–ไธŽ่ฎญ็ปƒๅˆ†ๅธƒๅทฎๅผ‚่พƒๅคง็š„ๅ›พ็‰‡ๅฏ่ƒฝ่กจ็Žฐ่พƒๅทฎใ€‚
  • ๆ ‡็ญพๅนถไธไฟ่ฏๅฎŒๆ•ดๆˆ–ๅฎŒๅ…จๅ‡†็กฎ๏ผŒ่ง’่‰ฒไธŽไฝœๅ“ๆฅๆบๅฐคๅ…ถๅฏ่ƒฝๅ‘็”Ÿ่ฏฏ่ฏ†ๅˆซใ€‚
  • ๆจกๅž‹ๅฏ่ƒฝ่พ“ๅ‡บๆ•ๆ„Ÿๅ†…ๅฎนๆ ‡็ญพใ€‚ไฝฟ็”จ่€…ๅบ”ๆ นๆฎๅบ”็”จๅœบๆ™ฏ่ฟ›่กŒๅ†…ๅฎน่ฟ‡ๆปค๏ผŒๅนถ้ตๅฎˆๅฝ“ๅœฐๆณ•ๅพ‹ๅŠๅนณๅฐ่ง„ๅˆ™ใ€‚
  • ๆœฌๆจกๅž‹ไธๅบ”ไฝœไธบๅฎ‰ๅ…จๅฎกๆ ธใ€่บซไปฝๅˆคๆ–ญๆˆ–ๅ…ถไป–้ซ˜้ฃŽ้™ฉๅ†ณ็ญ–็š„ๅ”ฏไธ€ไพๆฎใ€‚

่ฎธๅฏ่ฏ

ๆœฌไป“ๅบ“ไพๆฎ Apache License 2.0 ๅ‘ๅธƒ๏ผŒ่ฏฆๆƒ…่ง LICENSEใ€‚

Downloads last month
10
Safetensors
Model size
2B params
Tensor type
BF16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Space using damoncao/Anime_Image2Prompt 1