Nodes/Recognize Anything Model (RAM) for ComfyUI/Recognize Anything Model (RAM)
ComfyUI Node

Recognize Anything Model (RAM)

RAM++ in ComfyUI

By Hangover3832·Created 2 years ago·Updated about a year ago· 22
Recognize Anything Model (RAM)
  • image
  • tags
  • spec_tags
  • caption
modelram_plus_swin_large_14m.pth
devicecpu
spec_tag2text

The name is not a lie. This node loads the Recognize Anything Model (RAM and its beefier sibling RAM++) and answers the oldest question in this hobby: what's actually in this picture? Feed it an image and it hands back a comma-separated list of tags - objects, scene content, the lot - and, if you pick the tag2text model instead, a natural-language caption. It's the stated counterpart to Segment Anything (SAM draws the mask, RAM names what's inside it), and a quiet workhorse for auto-tagging reference images and LoRA datasets.

Two honest caveats before you fall in love. The README opens with "This repository will no longer be maintained," so whatever breaks later stays broken. And ComfyUI already has more famous taggers: WD14 is still the right tool for Danbooru-style anime LoRA data, and Florence 2 is a great captioner. What RAM does that they don't is tag general images - photos, objects, non-anime content - because it was trained on 14 million image–text pairs and a fixed vocabulary of roughly 4,500 concepts, not on an image board's tag taxonomy. It's the one you reach for when the image is a cat on a couch, not a 1girl with a katana.

How it works

The node is a thin wrapper around the ram Python package (RAM++ by xinyu1205 and co-authors, June 2023 paper). It registers a rams model folder under ComfyUI/models/rams/, loads whichever checkpoint you pick into torch, and runs the model's own inference functions on your image. A nice touch in the source: it caches the loaded model and only reloads when you actually change the model or device, so swapping images doesn't re-read a multi-gigabyte checkpoint every time. Output tags are deduplicated and joined with ", ".

The three checkpoints differ in what they return:

  • RAM (ram_swin_large_14m.pth) - tags in English and Chinese.
  • RAM++ (ram_plus_swin_large_14m.pth) - same bilingual tags, better accuracy. This is the default, and the one to use.
  • tag2text (tag2text_swin_14m.pth) - tags plus an actual sentence caption, and it also respects the user-supplied tags below.

The inputs and outputs that matter

Only four inputs, and you'll touch maybe two:

  • image - any IMAGE tensor; feed a batch and you get one line of tags per image.
  • model - RAM, RAM++, or tag2text. Start with the default RAM++.
  • device - cpu or gpu. Note the dropdown only shows gpu if your torch can actually see CUDA, so CPU-only users get one choice. CPU tagging works, just slow.
  • spec_tag2text - ignored unless tag2text is selected; it's the author's way of passing candidate tags the model should consider.

Three STRING outputs, all of them plain text you can wire straight into a prompt input:

  • tags - the English tag list. This is the one you feed into your prompt.
  • spec_tags - the Chinese tag list (RAM and RAM++) or tag2text's second output. Useful if you prompt in Chinese; otherwise ignore it.
  • caption - empty unless you chose tag2text, which fills it with a prose sentence - handy as a seed for Flux-style natural-language prompting.

Installing it

Install via ComfyUI Manager (search "RAM") or clone manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Hangover3832/ComfyUI-Hangover-Recognize_Anything

Then the part that trips everyone up: the node imports from the ram package, which is not on PyPI. The README says to install it straight from a git repo:

pip install git+https://github.com/Hangover3832/recognize-anything.git

(On the Windows portable build, run that from inside python_embedded/.) Slightly confusingly, the pack's own requirements.txt points at the upstream xinyu1205/recognize-anything instead - either source supplies the same ram package, but git-URL dependencies are exactly what Manager's auto-install silently fumbles, so do it by hand and restart ComfyUI.

Finally the heavy part: download all three checkpoints into ComfyUI/models/rams/ (Manager's model downloader can do it, or grab them from xinyu1205 on Hugging Face). Each is a few gigabytes - RAM's alone is over 5 GB - budget disk and patience. You can point the folder elsewhere via extra_model_paths.yaml.

Troubleshooting

  • Node won't load / ImportError on ram - the package install above didn't happen or failed. Re-run it and restart.
  • Model '...' not found. Make sure it is in the '/models/rams' folder - that's the node talking directly to you: you skipped the downloads.
  • No "gpu" option in the dropdown - your torch build has no CUDA; that's a ComfyUI install issue, not this node's.
  • First run hangs - a multi-GB checkpoint is being read off disk; later runs on the same model skip the reload thanks to the cache.

For a pack nobody maintains, this one still does its one job well. Install it, pick RAM++, and stop hand-typing tags for your reference images.

CategoryHangover

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
modelCOMBOram_plus_swin_large_14m.pth3 options: ram_swin_large_14m.pth, ram_plus_swin_large_14m.pth, tag2text_swin_14m.pth
deviceCOMBOcpu2 options: cpu, gpu
spec_tag2textSTRING

Outputs (3)

NameTypeDescription
tagsSTRING
spec_tagsSTRING
captionSTRING