Nodes/LF Nodes/LLM Image classifier
ComfyUI Node

LLM Image classifier

Ask a local LLM what's in your image, and get a verdict to branch on

By lucafoscili·Created 2 years ago·Updated 2 years ago· 50
LLM Image classifier
  • image
  • ui_widget
  • request_json
  • response_json
  • message
temperature0.7
max_tokens500
prompt
seed42
urlhttp://localhost:5001/v1/chat/completions
character_bio

Most image-classification nodes use a fixed model. LF_ImageClassifier instead sends your image to a local LLM running on your machine and asks it, in plain language, to classify the image. You write the prompt, the LLM answers, and the node hands you the response as a string plus the raw request/response JSON. It's the "vision model as a routing decision" pattern, and it's surprisingly powerful.

The name undersells it. This isn't just "cat or dog" - you can ask the model to judge composition, detect a watermark, identify whether the image is an anime style, decide if it's under- or over-exposed, or return any label you can describe in words. Whatever the LLM can see, it becomes a branch condition in your graph: wire the message output into a text matcher and your workflow routes itself.

How it works

The required inputs are the LLM controls: image, prompt (your question or classification instruction), temperature (0.1–1.9, randomness), max_tokens (verbosity cap), seed (reproducibility), and url - the local endpoint, defaulting to http://localhost:5001/v1/chat/completions. That default is the tell: it's the OpenAI-compatible API port, and the pack was tested against KoboldCpp. Any OpenAI-compatible endpoint that doesn't require an API key works.

There's also an optional character_bio - biographical text that shapes the tone and content of the answer, per the tooltip. Want the classifier to answer in a persona? That's the knob.

Outputs:

  • message - the LLM's text answer. The one you'll branch on.
  • request_json - exactly what was sent to the endpoint. Great for debugging.
  • response_json - the full endpoint response. Grab it if you need structured fields.

The setup that matters

This is the one node in this pack that needs something running outside ComfyUI. The README spells it out: the LLM nodes were tested with KoboldCpp, and the sample workflow used Llama-3-Instruct-8B-SPPO-Iter3 with the LLaVA-Llama-3-8B mmproj for vision. So for image classification you need a vision-capable (mmproj-enabled) build of your local LLM server. No API key - that's the point of the local endpoint - but you do need the server up before the node runs, or you'll get a connection error.

Installing it

Part of LF Nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/lucafoscili/comfyui-lf

Restart, or use ComfyUI Manager (search LF Nodes). Note the pack pins openai==1.12.0 in its requirements - that Python client is what talks to your endpoint, and the pin exists for a reason.

Gotchas

The most common failure is a dead endpoint - the node can't connect to localhost:5001, so the response comes back empty. Get your LLM server running first, confirm the port, and check request_json to see whether the request even went out. And if you hit the endpoint from a browser but not ComfyUI, check for a firewall or a localhost binding on IPv6.

Pack note: comfyui-lf is legacy, frozen at Feb 2025, with active development in lucafoscili/lf-nodes - the LLM node family got carried over there too.

Category✨ LF Nodes/LLM

Inputs (8)

NameTypeDefaultDescription
imageIMAGEThe image that the LLM will try to classify.
temperatureFLOAT0.70.1–1.901Controls the randomness of the generated text. Higher values make the output more random.
max_tokensINT50020–8000Limits the length of the generated text. Adjusting this value can help control the verbosity of the output.
promptSTRINGThe initial input or question that guides the generation process. Can be a single line or multiple lines of text.
seedINT420–18446744073709550000Determines the starting point for generating random numbers. Setting a specific seed ensures reproducibility of results.
urlSTRINGhttp://localhost:5001/v1/chat/completionsURL of the local endpoint where the request is sent.
character_biooptSTRINGBiographical details of the character to be impersonated. Helps in shaping the tone and content of the generated text.
ui_widgetoptKUL_CODE

Outputs (3)

NameTypeDescription
request_jsonJSON
response_jsonJSON
messageSTRING