Git Product home page Git Product logo

comfyui-image-selector's Introduction

ComfyUI-Image-Selector

A custom node for ComfyUI, which can select one or some of images from a batch.

Background

ComfyUI dosn't handle batch generation seeds like A1111 WebUI do (See Issue #165), so you can't simply increase the generation seed to get the desire image from a batch generation.

So here is a simple node that can select some of the images from a batch and pipe through for further use, such as scaling up or "hires fix".

Or you can use PreviewImage Node to go through all the images, and then rewire SaveImage with ImageSelector to save the one you want.

Install

Clone this repo into custom_nodes directory of ComfyUI location

Usage

ImageSelector & ImageDuplicator

Both nodes can be found in image category.

Selector takes a list of selected indexes, start with 1 (not 0, sorry), seperated by comma, and outputs only the selected images from input images.

New in 2023/12/2: Support range selection with left bound included and right bound excluded, see example below.

For example:

  1. 1: select the first image
  2. 1,3,4,6,7: select the 1st, 3rd, 4th, 6th and 7th image
  3. 2:: select 2nd, 3rd, ..., till the last image (omit the first image)
  4. :0: select 1st, 2nd, ..., till the second last image (omit the last image)
  5. 3:-1: select 3rd, 4th, ..., till the third last image (omit first two and last two images)

All indexes that cannot convert to integer or out of bounds will be ignored.

Duplicator takes a number and duplicates input images by given times.

Snipaste_2023-08-14_23-42-04

LatentSelector & LatentDuplicator

Both nodes can be found in latent category.

The parameters and functionality is just like the image counterpart, but for latents

Snipaste_2023-08-14_23-44-02

Tips

VAE Decode & Encode takes time and vram, so better avoid uneccessary VAE node. If must, do it with as few images/latents as possible. In general,

  • encode/decode -> duplicator is better than duplicator -> encode/decode
  • selector -> encode/decode is better than encode/decode -> selector

comfyui-image-selector's People

Contributors

mihaibirsan avatar slapaper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

comfyui-image-selector's Issues

Runpod docker error

2023-12-11T11:03:36.971474729Z File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed 2023-12-11T11:03:36.971475839Z File "/app/ComfyUI/custom_nodes/ComfyUI-Image-Selector/_init_.py", line 162, in <module> 2023-12-11T11:03:36.971477679Z class LatentSelector: 2023-12-11T11:03:36.971479039Z File "/app/ComfyUI/custom_nodes/ComfyUI-Image-Selector/_init_.py", line 196, in LatentSelector 2023-12-11T11:03:36.971480359Z def run(self, latent_image: clabc.Mapping[str, torch.Tensor], 2023-12-11T11:03:36.971481489Z TypeError: 'ABCMeta' object is not subscriptable 2023-12-11T11:03:36.971482529Z 2023-12-11T11:03:36.971483639Z Cannot import /app/ComfyUI/custom_nodes/ComfyUI-Image-Selector module for custom nodes: 'ABCMeta' object is not subscriptable 2023-12-11T11:03:36.972591206Z ### Loading: ComfyUI-Impact-Pack (V4.38.2) 2023-12-11T11:03:37.205819679Z INFO | f4fa13c1-c456-4dd5-8b3d-d4664250057a-e1 | Started 2023-12-11T11:03:37.631362134Z ### Loading: ComfyUI-Impact-Pack (Subpack: V0.3.2) 2023-12-11T11:03:37.699103709Z ### Loading: ComfyUI-Manager (V1.8.3) 2023-12-11T11:03:37.874995478Z ### ComfyUI Revision: 1793 [cdff0810] | Released on '2023-12-07' 2023-12-11T11:03:37.875759426Z 2023-12-11T11:03:37.875765196Z Import times for custom nodes: 2023-12-11T11:03:37.875830546Z 0.0 seconds (IMPORT FAILED): /app/ComfyUI/custom_nodes/ComfyUI-Image-Selector 2023-12-11T11:03:37.875849256Z 0.2 seconds: /app/ComfyUI/custom_nodes/ComfyUI-Manager 2023-12-11T11:03:37.875854736Z 0.7 seconds: /app/ComfyUI/custom_nodes/ComfyUI-Impact-Pack 2023-12-11T11:03:37.875856586Z 2023-12-11T11:03:37.877481251Z Starting server 2023-12-11T11:03:37.877486701Z 2023-12-11T11:03:37.877488221Z To see the GUI go to: http://127.0.0.1:8188 2023-12-11T11:03:39.211407053Z got prompt 2023-12-11T11:03:39.212964258Z Error handling request 2023-12-11T11:03:39.212977668Z Traceback (most recent call last): 2023-12-11T11:03:39.212979408Z File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_protocol.py", line 433, in _handle_request 2023-12-11T11:03:39.212981158Z resp = await request_handler(request) 2023-12-11T11:03:39.212982128Z File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_app.py", line 504, in _handle 2023-12-11T11:03:39.212983358Z resp = await handler(request) 2023-12-11T11:03:39.212984208Z File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_middlewares.py", line 117, in impl 2023-12-11T11:03:39.212985378Z return await handler(request) 2023-12-11T11:03:39.212986348Z File "/app/ComfyUI/server.py", line 46, in cache_control 2023-12-11T11:03:39.212988148Z response: web.Response = await handler(request) 2023-12-11T11:03:39.212989248Z File "/app/ComfyUI/server.py", line 472, in post_prompt 2023-12-11T11:03:39.212990238Z valid = execution.validate_prompt(prompt) 2023-12-11T11:03:39.212991048Z File "/app/ComfyUI/execution.py", line 598, in validate_prompt 2023-12-11T11:03:39.213000498Z class_ = nodes.NODE_CLASS_MAPPINGS[prompt[x]['class_type']] 2023-12-11T11:03:39.213001448Z KeyError: 'ImageSelector' 2023-12-11T11:03:39.277386933Z Could not connect to ComfyUI because it is not up yet. Sleeping for 2 seconds before trying again. 2023-12-11T11:03:39.277402513Z INFO | f4fa13c1-c456-4dd5-8b3d-d4664250057a-e1 | Finished

Please help me with this.

Selector does not recognize nested nodes after pressing Cancel run > Progress (...)

"Unknown error" is displayed, the console says:

got prompt
ERROR:aiohttp.server:Error handling request
Traceback (most recent call last):
  File "P:\cui\python_embeded\lib\site-packages\aiohttp\web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "P:\cui\python_embeded\lib\site-packages\aiohttp\web_app.py", line 504, in _handle
    resp = await handler(request)
  File "P:\cui\python_embeded\lib\site-packages\aiohttp\web_middlewares.py", line 117, in impl
    return await handler(request)
  File "P:\cui\ComfyUI\server.py", line 46, in cache_control
    response: web.Response = await handler(request)
  File "P:\cui\ComfyUI\server.py", line 472, in post_prompt
    valid = execution.validate_prompt(prompt)
  File "P:\cui\ComfyUI\execution.py", line 598, in validate_prompt
    class_ = nodes.NODE_CLASS_MAPPINGS[prompt[x]['class_type']]
KeyError: 'MyNode'

The MyNode isnt the first one after / before the selector, it is an unrelated one to the part where I press the buttons

Otherwise it works fine and it is a really great addition to workflows

Image Selector Crops Images to Ratio of 1st Image in Batch - Minor

This is a very minor issue that only affects weird use cases, but just so it's documented somewhere I wanted to put it here.

The Image selector will crop all images in a batch to fit the ratio of the first image loaded into the batch. So if you do something weird like load images of different aspect ratios, they will all be cropped to the 1st image's ratio. Example in pictures.

image21

image22

Is it possible to feed an image selection into Apply Controlnet (advanced)?

I am attempting to do a batch initial gen and use latent and image selectors to send a selection to be upscaled using controlnet tile. Attempting to send a list of image selections to controlnet results in an error:

Error occurred when executing ControlNetApplyAdvanced:

'list' object has no attribute 'movedim'

On the surface this doesn't feel like it should be possible. If there is a way I would like to know it. Thank you for any support and I apologize for my lack of technical knowledge.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.