Skip to content

Conversation

@chrisgoringe
Copy link

This PR adds a boolean input to the detailer nodes, return_images_by_cycle_step.

Default value is False, leaving behaviour unchanged.

If set to True, the image after each cycle step is returned in a batch.

This allows the user to specify a number of cycles, and then pick the best result.

(I use this in combination with https://github.com/chrisgoringe/cg-image-filter which allows me to pick the best image to continue with)

@ltdrdata
Copy link
Owner

It crashes when return_by_cycle_step is disabled.

: 640x384 1 face, 5.0ms
Speed: 0.8ms preprocess, 5.0ms inference, 2.9ms postprocess per image at shape (1, 3, 640, 384)
Detailer: segment upscale for ((np.float32(66.21362), np.float32(84.172455))) | crop region (198, 252) x 3.047865629196167 -> (603, 768)
 40%|██████████████████████████████████████████████████████████████████████████████████████████████████▍                                                                                                                                                   | 8/20 [00:00<00:00, 12.41it/s]FETCH ComfyRegistry Data: 75/107
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:01<00:00, 12.26it/s]
[Impact Pack] vae decoded in 0.1s
!!! Exception during processing !!! cannot access local variable 'refined_images_by_step' where it is not associated with a value
Traceback (most recent call last):
  File "/mnt/teratera/git/ComfyUI/execution.py", line 510, in execute
    output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, hidden_inputs=hidden_inputs)
                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/teratera/git/ComfyUI/execution.py", line 324, in get_output_data
    return_values = await _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, hidden_inputs=hidden_inputs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/teratera/git/ComfyUI/execution.py", line 298, in _async_map_node_over_list
    await process_inputs(input_dict, i)
  File "/mnt/teratera/git/ComfyUI/execution.py", line 286, in process_inputs
    result = f(**inputs)
             ^^^^^^^^^^^
  File "/mnt/teratera/git/ComfyUI/custom_nodes/comfyui-impact-pack/modules/impact/impact_pack.py", line 899, in doit
    enhanced_img, cropped_enhanced, cropped_enhanced_alpha, mask, cnet_pil_list = FaceDetailer.enhance_face(
                                                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/teratera/git/ComfyUI/custom_nodes/comfyui-impact-pack/modules/impact/impact_pack.py", line 853, in enhance_face
    DetailerForEach.do_detail(image, segs, model, clip, vae, guide_size, guide_size_for_bbox, max_size, seed, steps, cfg,
  File "/mnt/teratera/git/ComfyUI/custom_nodes/comfyui-impact-pack/modules/impact/impact_pack.py", line 365, in do_detail
    result = core.enhance_detail(cropped_image, model, clip, vae, guide_size, guide_size_for_bbox, max_size,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/teratera/git/ComfyUI/custom_nodes/comfyui-impact-pack/modules/impact/core.py", line 431, in enhance_detail
    refined_images_by_step = [ utils.tensor_resize(i,w,h) for i in refined_images_by_step ]
                                                                   ^^^^^^^^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'refined_images_by_step' where it is not associated with a value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants