chichibunoc/dsh-anima-draw

dsh-anima-draw

DSH plugin + skill: generate anime images locally with ComfyUI + Anima from natural language. 5 tools, one skill, /draw command, batch driver, 6 workflows.

未分類animaanimecomfyui

dsh-anima-draw

在 DSH 里用自然语言描述画面,ComfyUI + Anima 立即出二次元图片。

写一句「白发红眼少女,和服,樱花,夜晚」→ 自动转成 Danbooru tag → 本地 CUDA 出图 → 图片直接回到对话里。

dsh-plugin dsh-skill deepseek-harness comfyui anima anime text-to-image


这是什么

DeepSeek Harness (DSH) 的一个公开插件 + 技能包,把 ComfyUI 上的 Anima 2B(CircleStone Labs × Comfy Org 合作的动漫扩散模型)封装成 DSH 原生工具。

配套的 Python 桥接层可以单独使用,不依赖 DSH。

功能

DSH 工具

工具作用
anima_draw文生图。中文描述 → Danbooru tag → 出图
anima_refine微调:图生图 / 局部重绘 / LoRA / 两遍高清放大
anima_status链路自检:ComfyUI 在线、GPU 显存、模型齐全、队列
anima_models列出已安装模型
anima_stop中断当前出图
/draw <描述>slash 命令快速出图

采样档位

preset底模stepsCFGsampler用途
turboanima-turbo101.0euler最快试错
draftanima-turbo121.0euler快速草稿
standardanima-aesthetic304.0er_sde默认
finalanima-aesthetic404.5er_sde交付成品
baseanima-base405.0er_sde最大自由度

微调能力

  • 图生图:--ref img.png --denoise 0.6
  • 局部重绘:--inpaint 底图.png --mask mask.png --grow-mask 16
  • LoRA:--lora name:0.85(可串联多个)
  • 两遍高清:--hires --scale 1.6 --upscaler 4x-UltraSharp.pth

安装

1. ComfyUI + Anima

git clone https://github.com/comfyanonymous/ComfyUI.git <COMFY_ROOT>
cd <COMFY_ROOT>
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126
.\.venv\Scripts\python.exe -m pip install -r requirements.txt

模型放到 <COMFY_ROOT>\models\(约 9.5 GB):

文件目标目录来源
anima-turbo-v1.1.safetensorsmodels\diffusion_models\HF circlestone-labs/Anima
anima-aesthetic-v1.1.safetensorsmodels\diffusion_models\同上
qwen_3_06b_base.safetensorsmodels\text_encoders\同上
qwen_image_vae.safetensorsmodels\vae\同上
anima-turbo-lora-v0.2.safetensorsmodels\loras\同上(可选)

注意:Anima 不是 SD1.5 系。不要用 vae-ft-mse-840000、CLIP-L 或 clip_vision。

国内下载:ModelScope 有官方镜像 circlestone-labs/Anima,速度明显快于 HF 镜像。见 scripts/dl_models.ps1。

启动:

cd <COMFY_ROOT>
.\.venv\Scripts\python.exe main.py --listen 127.0.0.1 --port 8188

2. DSH 插件

# 复制插件
$dst = "$env:USERPROFILE\.dsh\plugins\dsh-anima-draw"
Copy-Item -Recurse -Force .\dsh-plugin $dst

在 DSH profile 的 package.json(桌面版为 ~\.dsh\profiles\desktop\,Web 版为 ~\.dsh\profiles\web\):

{
  "dependencies": {
    "dsh-anima-draw": "file:../../plugins/dsh-anima-draw"
  },
  "dsh": {
    "profile": {
      "bundles": [ "...", "dsh-anima-draw" ]
    }
  }
}

然后用该 profile 自带的 pnpm 安装:

cd $env:USERPROFILE\.dsh\profiles\desktop
node "<DSH安装目录>\resources\runtime\pnpm\bin\pnpm.cjs" install

重启 DSH,5 个工具进入工具列表。

3. 技能(可选,推荐)

Copy-Item -Recurse -Force .\dsh-plugin\skills\anima-draw "$env:USERPROFILE\.dsh\skills\anima-draw"

技能的发现是热更新的,不用重启。

独立使用(不经过 DSH)

$py = "<COMFY_ROOT>\.venv\Scripts\python.exe"

# 单张
& $py dsh-pipeline\anima_gen.py "一个白发红眼少女,和服,樱花,夜晚,特写" --preset final --seed 42

# 批量(推荐:绕开 shell 转义问题,支持 JSON 计划文件)
& $py dsh-pipeline\batch_gen.py examples\plan_luoxia.json

batch_gen.py 的计划文件支持每张单独控制:

{
  "outDir": "<COMFY_ROOT>/output/my_batch",
  "jobs": [
    {
      "name": "01.png",
      "preset": "draft",
      "seed": 6001,
      "safety": "explicit",
      "tag": "1girl, solo, blonde hair, wolf ears, red cape, bare feet",
      "negative": "worst quality, low quality, bad hands, shoes, footwear",
      "lora": ["my_lora.safetensors:0.85"]
    }
  ]
}

完整参数见 examples/。

仓库结构

dsh-plugin/            DSH 插件(Cordis)
├─ lib/index.mjs       工具注册 + /draw 命令
├─ lib/comfy.mjs       ComfyUI HTTP 桥接(仅 node:* 内置模块)
├─ lib/selfcheck.mjs   部署自检
└─ skills/anima-draw/  技能定义

dsh-pipeline/          Python 桥接层(纯标准库)
├─ anima_prompt.py     中文→Danbooru tag(100+ 条映射)+ 官方 tag 顺序 + 负向模板
├─ anima_workflows.py  API 格式 prompt JSON 构建器(t2i / lora / i2i / inpaint / hires)
├─ anima_gen.py        单张 CLI
└─ batch_gen.py        批量驱动(计划文件)

workflows/             6 套 ComfyUI 工作流(API + UI 双格式)
scripts/               模型下载 / torch 分段下载 / 一键启动自检
examples/              示例计划文件

技术要点

节点接线(对齐官方 workflow)

UNETLoader(anima-*.safetensors)
  → ModelSamplingAuraFlow(shift=3.0)      # supported_models.py class Anima
  → KSampler(er_sde / simple)
CLIPLoader(qwen_3_06b_base, type="stable_diffusion")
  → CLIPTextEncode                        # comfy/sd.py 按 TEModel.QWEN3_06B 自动分派
VAELoader(qwen_image_vae)
  → VAEEncode / VAEDecode
EmptyLatentImage                          # 4ch @/8,自动扩到 Anima 的 16ch Wan21 latent

接线取自官方 anima_comparison.json,并与 ComfyUI 0.40.0 本地源码逐项核对。

Prompt 规则(来自官方 README)

  • tag 小写、空格代替下划线(score_* 例外,保留下划线)
  • 顺序:[质量/meta/年份/安全] [1girl/1boy] [角色] [作品] [画师 @] [一般 tag]
  • 权重比 SDXL 更钝:需要 (tag:1.5) 甚至 (tag:2) 才明显
  • 画师 tag 必须 @ 前缀,否则效果很弱
  • Anima-Aesthetic 版不要加 score_* 标签,容易过饱和
  • 自然语言也可以(≥2 句更好),能与 tag 混排

许可

模型权重不可商用(含托管到收费 API、嵌入商业化产品等)。 生成的图片可以商用 —— 官方 README 明确说明限制只针对 Model,不针对 Outputs。