comfy_mtb icon indicating copy to clipboard operation
comfy_mtb copied to clipboard

[bug] faceenhance RuntimeError: start (12) + length (1) exceeds dimension size (12).

Open drmbt opened this issue 1 year ago • 3 comments

Describe the bug

ace restore breaks on default workflow. Using stability matrix

Reproduction

I finally got the first part of the face-swap workflow working after installing your wheels, and following this advice: https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/13985#issuecomment-1814243471

just trying to run faceswap example workflow

Expected behavior

it runs faceenhance.py successfully

Operating System

Windows (Default)

Comfy Mode

Other (online services, containers etc..)

Console output

occurred when executing Restore Face (mtb):

start (12) + length (1) exceeds dimension size (12).

File "D:\AI\StabilityMatrix-win-x64\Data\Packages\ComfyUI-clean\execution.py", line 317, in execute
output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
File "D:\AI\StabilityMatrix-win-x64\Data\Packages\ComfyUI-clean\execution.py", line 192, in get_output_data
return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
File "D:\AI\StabilityMatrix-win-x64\Data\Packages\ComfyUI-clean\execution.py", line 169, in _map_node_over_list
process_inputs(input_dict, i)
File "D:\AI\StabilityMatrix-win-x64\Data\Packages\ComfyUI-clean\execution.py", line 158, in process_inputs
results.append(getattr(obj, func)(**inputs))
File "D:\AI\StabilityMatrix-win-x64\Data\Packages\ComfyUI-clean\custom_nodes\comfy_mtb\nodes\faceenhance.py", line 247, in restore
out = [
File "D:\AI\StabilityMatrix-win-x64\Data\Packages\ComfyUI-clean\custom_nodes\comfy_mtb\nodes\faceenhance.py", line 248, in
self.do_restore(
File "D:\AI\StabilityMatrix-win-x64\Data\Packages\ComfyUI-clean\custom_nodes\comfy_mtb\nodes\faceenhance.py", line 208, in do_restore
cropped_faces, restored_faces, restored_img = model.enhance(
File "D:\AI\StabilityMatrix-win-x64\Data\Packages\ComfyUI-clean\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "D:\AI/StabilityMatrix-win-x64/Data/Packages/ComfyUI-clean/custom_nodes/comfy_mtb/extern/GFPGAN\gfpgan\utils.py", line 139, in enhance
bg_img = self.bg_upsampler.enhance(img, outscale=self.upscale)[0]
File "D:\AI\StabilityMatrix-win-x64\Data\Packages\ComfyUI-clean\custom_nodes\comfy_mtb\nodes\faceenhance.py", line 139, in enhance
s = comfy.utils.tiled_scale(
File "D:\AI\StabilityMatrix-win-x64\Data\Packages\ComfyUI-clean\comfy\utils.py", line 761, in tiled_scale
return tiled_scale_multidim(samples, function, (tile_y, tile_x), overlap, upscale_amount, out_channels, output_device, pbar)
File "D:\AI\StabilityMatrix-win-x64\Data\Packages\ComfyUI-clean\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "D:\AI\StabilityMatrix-win-x64\Data\Packages\ComfyUI-clean\comfy\utils.py", line 740, in tiled_scale_multidim
m = mask.narrow(d, t, 1)

Additional context

No response

drmbt avatar Aug 30 '24 16:08 drmbt

I'm going to look into it, can you share your workflow?

melMass avatar Sep 04 '24 14:09 melMass

I can @melMass

ClothingAI avatar Oct 27 '24 02:10 ClothingAI

RuntimeError start (12) length (1) exceeds dimension size (12).json

The thing is I had this error: https://github.com/xinntao/Real-ESRGAN/issues/841 At LOAD FACE ENHANCE MODEL so I did this change: ..\python_embeded\Lib\site-packages\basicsr\data\degradations.py And modified this:

# from torchvision.transforms.functional_tensor import rgb_to_grayscale 
from torchvision.transforms._functional_tensor import rgb_to_grayscale

now you can reproduce.

ClothingAI avatar Oct 27 '24 02:10 ClothingAI