chaiNNer-org / chaiNNer

A node-based image processing GUI aimed at making chaining image processing tasks easy and customizable. Born as an AI upscaling application, chaiNNer has grown into an extremely flexible and powerful programmatic image processing application.
https://chaiNNer.app
GNU General Public License v3.0
4.44k stars 278 forks source link

Bug report: Unable to Interpolate Models #1273

Closed infinitemonkeytheory closed 1 year ago

infinitemonkeytheory commented 1 year ago

Information:

Error

An error occurred in a PyTorch Interpolate Models node:

Input and output sizes should be greater than 0, but got input (H: 1, W: 1) output (H: 0, W: 0)

ChaiNNer: chaiNNer 0.15.2 OS: macOS 10.18

Description When attempting to interpolate models the above error is thrown.

Logs

[2022-11-24 14:56:57.864] [info]  Backend: [67906] [ERROR] Traceback (most recent call last):
  File "/Applications/chaiNNer.app/Contents/Resources/src/process.py", line 344, in __process
    raw_output, execution_time = await self.loop.run_in_executor(
  File "/Users/imt/Library/Application Support/chaiNNer/python/python/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Applications/chaiNNer.app/Contents/Resources/src/process.py", line 222, in wrapper
    result = supplier()
  File "/Applications/chaiNNer.app/Contents/Resources/src/nodes/nodes/pytorch/interpolate_models.py", line 101, in run
    if not self.check_can_interp(state_a, state_b):
  File "/Applications/chaiNNer.app/Contents/Resources/src/nodes/nodes/pytorch/interpolate_models.py", line 81, in check_can_interp
    t_out = model(img_tensor)
  File "/Users/imt/Library/Application Support/chaiNNer/python/python/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/Applications/chaiNNer.app/Contents/Resources/src/nodes/utils/architecture/GFPGAN/gfpganv1_clean_arch.py", line 335, in forward
    feat = self.conv_body_down[i](feat)
  File "/Users/imt/Library/Application Support/chaiNNer/python/python/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/Applications/chaiNNer.app/Contents/Resources/src/nodes/utils/architecture/GFPGAN/gfpganv1_clean_arch.py", line 162, in forward
    out = F.interpolate(
  File "/Users/imt/Library/Application Support/chaiNNer/python/python/lib/python3.9/site-packages/torch/nn/functional.py", line 3731, in interpolate
    return torch._C._nn.upsample_bilinear2d(input, output_size, align_corners, scale_factors)
RuntimeError: Input and output sizes should be greater than 0, but got input (H: 1, W: 1) output (H: 0, W: 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Applications/chaiNNer.app/Contents/Resources/src/run.py", line 243, in run
    await executor.run()
  File "/Applications/chaiNNer.app/Contents/Resources/src/process.py", line 487, in run
    await self.__process_nodes(self.__get_output_nodes())
  File "/Applications/chaiNNer.app/Contents/Resources/src/process.py", line 475, in __process_nodes
    await self.process(output_node)
  File "/Applications/chaiNNer.app/Contents/Resources/src/process.py", line 282, in process
    return await self.__process(node)
  File "/Applications/chaiNNer.app/Contents/Resources/src/process.py", line 309, in __process
    processed_input = await self.process(node_input.id)
  File "/Applications/chaiNNer.app/Contents/Resources/src/process.py", line 282, in process
    return await self.__process(node)
  File "/Applications/chaiNNer.app/Contents/Resources/src/process.py", line 365, in __process
    raise NodeExecutionError(node, str(e), input_dict) from e
process.NodeExecutionError: Input and output sizes should be greater than 0, but got input (H: 1, W: 1) output (H: 0, W: 0)
joeyballentine commented 1 year ago

I assume this was with SwinIR, Swin2SR, or hat?

infinitemonkeytheory commented 1 year ago

I assume this was with SwinIR, Swin2SR, or hat?

I should've included more data. I started out seeing about merging various GFPGAN models (out of curiosity), which is where I hit above error. And as predicted with, e.g., SwinIR or HAT I get essentially what I assume (perhaps totally incorrectly) is a similar error to above:

Argument #4: Padding size should be less than the corresponding input dimension, but got: padding (0, 5) at dimension 3 of input 4

and

Argument #4: Padding size should be less than the corresponding input dimension, but got: padding (0, 13) at dimension 3 of input 4

Real-ESRGAN Compact works as expected (e.g. tested merging realesr-general-x4v3.pth with realesr-general-wdn-x4v3.pth and encountered no issues plus was able to successfully use merged model).

I'm afraid that's all I've tested so far.

joeyballentine commented 1 year ago

Yeah then i know why this happens. Since interpolation between models that don't share a pretrained model produces broken models i do a small 3x3 upscale test to make sure it doesn't spit out a garbage result. However gfpgan requires a 512x512 image no matter what, and a similar thing is needed for those other models where they have size restrictions. I just need to update the interpolation check to either not happen for those models or simply use the correct sizes.