https://github.com/lucafoscili/comfyui-lf
Custom nodes with a touch of extra UX ✨ History for primitives, JSON manipulation, logic switches with visual feedback, LLM chat, analytics nodes, CivitAI metadata fetching... and more!
https://github.com/lucafoscili/comfyui-lf
comfyui comfyui-nodes javascript python sass typescript
Last synced: 5 months ago
JSON representation
Custom nodes with a touch of extra UX ✨ History for primitives, JSON manipulation, logic switches with visual feedback, LLM chat, analytics nodes, CivitAI metadata fetching... and more!
- Host: GitHub
- URL: https://github.com/lucafoscili/comfyui-lf
- Owner: lucafoscili
- License: mit
- Created: 2024-08-19T00:07:36.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2024-10-29T22:19:10.000Z (6 months ago)
- Last Synced: 2024-10-30T00:43:20.819Z (6 months ago)
- Topics: comfyui, comfyui-nodes, javascript, python, sass, typescript
- Language: JavaScript
- Homepage:
- Size: 259 MB
- Stars: 31
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
- awesome-comfyui - **LF Nodes**
README
# LF Nodes for ComfyUI



## Overview
A suite of custom nodes for [ComfyUI](https://github.com/comfyanonymous/ComfyUI) aimed at enhancing user experience with more interactive and visually engaging widgets.
Whether you're after quality-of-life improvements or specific functionalities, this collection has something for everyone.
Most UI elements used by the widgets come from the [Ketchup Lite web components library](https://github.com/lucafoscili/ketchup-lite).

## What kind of nodes does it offer?
That's a tough one—the nodes span quite a few categories. Here's a quick breakdown:
- **Analytics nodes**: Visualize and track data, like checkpoint/LoRA usage or image histograms.
- **Configuration nodes**: Manage CivitAI metadata, and control the suite via the Control Panel.
- **Image manipulation nodes**: Tools to manipulate images, such as filter and resize nodes.
- **IO Operations nodes**: Load and save files to/from the file system.
- **JSON nodes**: Tools to manipulate and display JSON data.
- **LLM nodes**: Interface with locally running LLMs, like the Messenger node, which also manages characters.
- **Logic nodes**: Control flow using simple switches.
- **Primitive nodes**: Work with primitive data types, offering features like history.
- **Seed generation nodes**: Generate seeds for complex workflows.
- **Selector nodes**: Resource selection widgets with metadata display for models.
## Table of Contents
- [LF Nodes for ComfyUI](#lf-nodes-for-comfyui)
- [Overview](#overview)
- [What kind of nodes does it offer?](#what-kind-of-nodes-does-it-offer)
- [Table of Contents](#table-of-contents)
- [Analytics nodes (`analytics.py`)](#analytics-nodes-analyticspy)
- [ImageHistogram](#imagehistogram)
- [KeywordCounter](#keywordcounter)
- [UpdateUsageStatistics](#updateusagestatistics)
- [UsageStatistics](#usagestatistics)
- [Configuration nodes (`configuration.py`)](#configuration-nodes-configurationpy)
- [CivitAIMetadataSetup](#civitaimetadatasetup)
- [ControlPanel](#controlpanel)
- [LoadLoraTags](#loadloratags)
- [Lora2Prompt](#lora2prompt)
- [LoraTag2Prompt](#loratag2prompt)
- [Notify](#notify)
- [Image manipulation nodes (`image.py`)](#image-manipulation-nodes-imagepy)
- [BlurImages](#blurimages)
- [ClarityEffect](#clarityeffect)
- [MultipleImageResizeForWeb](#multipleimageresizeforweb)
- [ResizeImageByEdge](#resizeimagebyedge)
- [ResizeImageToDimension](#resizeimagetodimension)
- [ResizeImageToSquare](#resizeimagetosquare)
- [IO Operations nodes (`io.py`)](#io-operations-nodes-iopy)
- [LoadFileOnce](#loadfileonce)
- [LoadImages](#loadimages)
- [LoadMetadata](#loadmetadata)
- [SaveImageForCivitAI](#saveimageforcivitai)
- [SaveJSON](#savejson)
- [JSON nodes (`json.py`)](#json-nodes-jsonpy)
- [DisplayJSON](#displayjson)
- [GetRandomKeyFromJSON](#getrandomkeyfromjson)
- [GetValueFromJSON](#getvaluefromjson)
- [ImageListFromJSON](#imagelistfromjson)
- [KeywordToggleFromJSON](#keywordtogglefromjson)
- [LoadLocalJSON](#loadlocaljson)
- [SetValueInJSON](#setvalueinjson)
- [ShuffleJSONKeys](#shufflejsonkeys)
- [SortJSONKeys](#sortjsonkeys)
- [StringToJSON](#stringtojson)
- [WriteJSON](#writejson)
- [Large Language Model nodes (`llm.py`)](#large-language-model-nodes-llmpy)
- [CharacterImpersonator](#characterimpersonator)
- [ImageClassifier](#imageclassifier)
- [LLMChat](#llmchat)
- [LLMMessenger](#llmmessenger)
- [Logic nodes (`logic.py`)](#logic-nodes-logicpy)
- [MathOperation](#mathoperation)
- [ResolutionSwitcher](#resolutionswitcher)
- [SwitchFloat](#switchfloat)
- [SwitchImage](#switchimage)
- [SwitchInteger](#switchinteger)
- [SwitchJSON](#switchjson)
- [SwitchString](#switchstring)
- [Primitive nodes (`primitives.py`)](#primitive-nodes-primitivespy)
- [Boolean](#boolean)
- [DisplayBoolean](#displayboolean)
- [DisplayFloat](#displayfloat)
- [DisplayInteger](#displayinteger)
- [DisplayPrimitiveAsJSON](#displayprimitiveasjson)
- [DisplayString](#displaystring)
- [Extractor](#extractor)
- [Float](#float)
- [Integer](#integer)
- [RandomBoolean](#randomboolean)
- [Something2Number](#something2number)
- [Something2String](#something2string)
- [String](#string)
- [WallOfText](#walloftext)
- [Seed generation nodes (`seeds.py`)](#seed-generation-nodes-seedspy)
- [SequentialSeedsGenerator](#sequentialseedsgenerator)
- [UrandomSeedGenerator](#urandomseedgenerator)
- [Selector nodes (`selectors.py`)](#selector-nodes-selectorspy)
- [CheckpointSelector](#checkpointselector)
- [EmbeddingSelector](#embeddingselector)
- [LoraSelector](#loraselector)
- [LoraAndEmbeddingSelector](#loraandembeddingselector)
- [SamplerSelector](#samplerselector)
- [SchedulerSelector](#schedulerselector)
- [UpscaleModelSelector](#upscalemodelselector)
- [VAESelector](#vaeselector)
- [Installation](#installation)
- [Using ComfyUI Manager](#using-comfyui-manager)
- [Manual](#manual)
- [Notes](#notes)
- [Contributing](#contributing)
- [License](#license)## Analytics nodes (`analytics.py`)
### ImageHistogram
Displays a widget that plots the RGB channels of a photo in tensor format on a line chart.
### KeywordCounter
Counts the number of each keyword in a prompt and displays a bar chart showing their distribution, a chip-shaped widget will also allow to copy one or more keywords in the clipboard.
### UpdateUsageStatistics
Keep tracks of the resources used by saving datasets in the input folder of ComfyUI. The datasets will be plotted on area/scatter charts inside the twin node UsageStatistics.
### UsageStatistics
Displays datasets tracking the usage of resources saved with the UpdateUsageStatistics node.
## Configuration nodes (`configuration.py`)
### CivitAIMetadataSetup
Allows to setup and generate [CivitAI](https://civitai.com)-compatible metadata information usable in the node SaveImageForCivitAI.
### ControlPanel
Utilities to debug nodes and to change the theme of Ketchup Lite webcomponents.
### LoadLoraTags
LoRA models are loaded in tag format, with a status widget displayed at the bottom indicating the loading progress.
### Lora2Prompt
Converts a prompt and LoRAs to a formatted string.
### LoraTag2Prompt
Processes a LoRA tag to extract keywords and count them. This node is useful for preparing prompts based on LoRA file names.
### Notify
Triggers a browser notification when executed. Optionally, when clicked, it can queue a new prompt or focus the workflow's tab.
## Image manipulation nodes (`image.py`)
### BlurImages
Applies the gaussian blur filter to a list of images and edits the filename of each image by adding the '_Blur' suffix.
### ClarityEffect
Applies a filter mimicking the clarity effect of Lightroom and Camera Raw.
### MultipleImageResizeForWeb
The node takes a list of images as input and generates eight additional images, each resized to common web resolutions (256px, 320px, 512px, 640px, 1024px, 1280px, 2048px, 2560px) along the longest edge.
### ResizeImageByEdge
Resizes one or more images in tensor format's longest or shortest edge to the specified size.
### ResizeImageToDimension
Resizes an image to the longest dimension and then crops it/pads it to fit the canvas.
### ResizeImageToSquare
Resizes one or more images in tensor format to fit a square (by cropping when the image is rectangular).
## IO Operations nodes (`io.py`)
### LoadFileOnce
Loads a file from a directory and then saves the name to the history. Files present in the history are skipped.
### LoadImages
Node used to load multiple images from the disk given a directory. Optionally, it can fetch images from subdirectories.
### LoadMetadata
Enables uploading files to the input directory of ComfyUI, then on the workflow's execution the metadata will be extracted from the files included in the uploading process.
### SaveImageForCivitAI
Saves images with [CivitAI](https://civitai.com)-compatible metadata generated by the node CivitAIMetadataSetup.
### SaveJSON
Saves a JSON file at the specified path.
## JSON nodes (`json.py`)
### DisplayJSON
Displays JSON data with a handy button to copy the content.
### GetRandomKeyFromJSON
Extracts a random key from a given JSON object. This can be used to introduce variability or select random elements from JSON data.
### GetValueFromJSON
Extracts a specific value from a JSON object based on a provided key. This node supports extracting various types of values including JSON objects, strings, numbers, integers, floats, and booleans.
### ImageListFromJSON
Creates a list of images with the number set by the number of keys inside the input JSON. It also outputs the list of keys themselves.
### KeywordToggleFromJSON
Allows the selection of keywords received from a Ketchup Lite compatible JSON dataset. Values are refreshed every time the input changes.
### LoadLocalJSON
Loads JSON data from a local file specified by a URL. This node is useful for importing static JSON configurations or datasets directly into ComfyUI workflows.
### SetValueInJSON
Sets a new key or updates an existing one with a new value.
### ShuffleJSONKeys
Sorts the keys at root level of a JSON, returning the sorted object. Optionally it can also sort the input JSON in place without making a copy of it.
### SortJSONKeys
Sorts the keys at root level of a JSON, returning the sorted object. Optionally it can also sort the input JSON in place without making a copy of it.
### StringToJSON
Converts a string to a JSON object.
### WriteJSON
A simple text area that lets the user input a JSON file which will be validated when the workflow is queued. Each 2500ms the text is formatted, if there is an error it will be displayed in the title of the textarea (visible on mouseover).

## Large Language Model nodes (`llm.py`)
### CharacterImpersonator
Utilizes a large language model to generate text responses as if coming from a character described by a provided biography. This node can be used for creative writing, role-playing scenarios, or generating dynamic content based on character traits.
### ImageClassifier
Utilizes a large language model to generate descriptions of images portraying characters.
### LLMChat
Real-time chat with an LLM model served through Koboldcpp ().
It's possible to select the last messages as an output, sending them to the next node.
### LLMMessenger
A user interface capable of loading characters through a Ketchup Lite-compatible JSON and then connects to your local Koboldcpp instance ().
The location, outfit and timeframe options are included in the system prompt to give more context to the LLM.
Together with the biography, they define the identity of the LLM.
## Logic nodes (`logic.py`)
### MathOperation
Performs mathematical operations involving up to four variables.
### ResolutionSwitcher
Selects a random resolution between portrait and landscape orientations. The chances for landscape to occur can be set with a percentage.
### SwitchFloat
Returns one of two float values depending on a boolean condition.
### SwitchImage
Returns one of two images in tensor format based on a boolean condition.
### SwitchInteger
Returns one of two integer values depending on a boolean condition.
### SwitchJSON
Returns one of two JSON objects depending on a boolean condition.
### SwitchString
Returns one of two string values based on a boolean condition.
## Primitive nodes (`primitives.py`)
### Boolean
Used to select a boolean. It keeps record of old values, displaying a clickable list below the widget.
### DisplayBoolean
Displays the value of a boolean in a widget.
### DisplayFloat
Displays the value of a float in a widget.
### DisplayInteger
Displays the value of a integer in a widget.
### DisplayPrimitiveAsJSON
Displays different primitive values as a JSON output or directly in-widget through a tree-like view.
### DisplayString
Displays the value of a string in a widget.
### Extractor
Extracts text enclosed by a starting and ending delimiter.
### Float
Used to select a float. It keeps record of old values, displaying a clickable list below the widget.
### Integer
Used to select an integer. It keeps record of old values, displaying a clickable list below the widget.
### RandomBoolean
Outputs False or True depending on the chances specified by the percentage widget. 0 always false, 100 always true.
### Something2Number
Converts multiple inputs to integers and floats, handling nested structures and mixed types. If multiple numbers are sent to the node, they are summed.
### Something2String
Converts multiple inputs to strings, handling nested structures and mixed types.
### String
Used to select a string. It keeps record of old prompts, displaying a clickable list below the textarea.
### WallOfText
Concatenates up to 10 strings, with the optional toggle to shuffle the order of concatenation.
## Seed generation nodes (`seeds.py`)
### SequentialSeedsGenerator
Generates a series of unique seeds based on a global seed value. This node is useful for creating reproducible random sequences in workflows.
### UrandomSeedGenerator
Generates up to 20 different seeds through the use of the Python urandom function which leverages CPU generated entropy for increased randomness.
## Selector nodes (`selectors.py`)
### CheckpointSelector
Used to select a checkpoint. It's possible to fetch additional data from CivitAI or by loading the related cover inside the checkpoints folder.
### EmbeddingSelector
Used to select an embedding. It's possible to fetch additional data from CivitAI or by loading the related cover inside the embeddings folder.
### LoraSelector
Used to select a LoRA. It's possible to fetch additional data from CivitAI or by loading the related cover inside the loras folder.
### LoraAndEmbeddingSelector
Using a LoRA name as pilot, it also selects its related embedding (it must have the same name). Useful for models trained with pivotal training.
### SamplerSelector
Used to select a sampler, the history widget allows for a quick swap between the most used samplers.
### SchedulerSelector
Used to select a scheduler, the history widget allows for a quick swap between the most used schedulers.
### UpscaleModelSelector
Used to select an upscale model, the history widget allows for a quick swap between the most used upscale models.
### VAESelector
Used to select a VAE, the history widget allows for a quick swap between the most used VAEs.
## Installation
### Using ComfyUI Manager
- Open ComfyUI Manager.
- Search LF Nodes.
- Install the node suite and restart ComfyUI.### Manual
- Go to the `ComfyUI/custom_nodes` folder.
- Open a terminal.
- Copy and paste this command `git clone https://github.com/lucafoscili/comfyui-lf.git`.## Notes
The LLM nodes are designed to work with [Koboldcpp](https://github.com/LostRuins/koboldcpp/tree/v1.73).
The model used in the workflows samples is [UCLA-AGI/Llama-3-Instruct-8B-SPPO-Iter3](https://huggingface.co/UCLA-AGI/Llama-3-Instruct-8B-SPPO-Iter3) with [ChaoticNeutrals/LLaVA-Llama-3-8B-mmproj-Updated](https://huggingface.co/ChaoticNeutrals/LLaVA-Llama-3-8B-mmproj-Updated).## Contributing
Contributions to this repository are welcome, feel free to submit pull requests or open issues for discussion!
To setup the environment clone this repository, then from the root open a terminal and run the command`pip install -r requirements.txt`
This will install all the required dependencies for the Python back-end.
`npm run setup`
This command will install all the frontend dependencies.
Note that the repository includes the compiled files directly to allow Comfy to load them, dependencies are only needed for actual development.`npm run build`
This command will compile all the frontend sources and generate/refresh the actual web directory.
## License
MIT License