Fannovel16 / ComfyUI-Frame-Interpolation

A custom node set for Video Frame Interpolation in ComfyUI.
MIT License
405 stars 41 forks source link

how to run on Mac m2, thx #47

Open hike2008 opened 6 months ago

hike2008 commented 6 months ago

RuntimeError: MPS: Unsupported Border padding mode

I have tried the config to taichi,but error the same above

yanhangr commented 6 months ago

same error

ERROR:root:!!! Exception during processing !!! ERROR:root:Traceback (most recent call last): File "/Users/yanhangr/program/ComfyUI/execution.py", line 152, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/yanhangr/program/ComfyUI/execution.py", line 82, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/yanhangr/program/ComfyUI/execution.py", line 75, in map_node_over_list results.append(getattr(obj, func)(slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/yanhangr/program/ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation/vfi_models/rife/init.py", line 104, in vfi generic_frame_loop(frames, clear_cache_after_n_frames, multiplier, return_middle_frame, args, File "/Users/yanhangr/program/ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation/vfi_utils.py", line 167, in generic_frame_loop middle_frame = return_middle_frame_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/yanhangr/program/ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation/vfi_models/rife/init.py", line 98, in return_middle_frame return model(frame_0, frame_1, timestep, scale_list, in_fast_mode, in_ensemble) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl return self._call_impl(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/yanhangr/program/ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation/vfi_models/rife/rife_arch.py", line 563, in forward warped_img0 = warp(img0, flow[:, :2]) ^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/yanhangr/program/ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation/vfi_models/rife/rife_arch.py", line 59, in warp return torch.nn.functional.grid_sample( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/nn/functional.py", line 4351, in grid_sample return torch.grid_sampler(input, grid, mode_enum, padding_mode_enum, align_corners) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: MPS: Unsupported Border padding mode

Mackay031 commented 6 months ago

Just wondering if there are any Mac hacks to get Film working on a Mac? Getting a 'failed in the Torchscript interpreter' error. Thanks

dimagrechkin commented 5 months ago

Hey there! Same for me! MPS backend, configed to taichi

tamler commented 5 months ago

Same - MBP M2 Max with 64gb ram

Following this tutorial in case knowing what other nodes or settings are in use: https://www.youtube.com/watch?v=DKfz0skc2oM ~5 min in

Error: RuntimeError: MPS: Unsupported Border padding mode

I've changed the config.yaml to taichi: https://github.com/Fannovel16/ComfyUI-Frame-Interpolation?tab=readme-ov-file#support-for-non-cuda-device-experimental

I've tried changing the padding mode: warped = F.grid_sample(image, normalized_flow2, mode='bilinear', padding_mode='zeros', align_corners=False)

Tried this: pip install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu

!!! Exception during processing !!! Traceback (most recent call last): File "/Users/NAME/ComfyUI/execution.py", line 151, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/NAME/ComfyUI/execution.py", line 81, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/NAME/ComfyUI/execution.py", line 74, in map_node_over_list results.append(getattr(obj, func)(slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/NAME/ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation/vfi_models/film/init.py", line 88, in vfi relust = inference(model, frame_0, frame_1, multiplier - 1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/NAME/ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation/vfi_models/film/init.py", line 36, in inference prediction = model(x0, x1, dt) ^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniconda/base/envs/ComfyUI/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniconda/base/envs/ComfyUI/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl return forward_call(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: The following operation failed in the TorchScript interpreter. Traceback of TorchScript, serialized code (most recent call last): File "code/torch/interpolator.py", line 15, in forward x1: Tensor, batch_dt: Tensor) -> Tensor: _0 = (self).debug_forward(x0, x1, batch_dt, )


    return (_0["image"])[0]
  def debug_forward(self: __torch__.interpolator.Interpolator,
  File "code/__torch__/interpolator.py", line 29, in debug_forward
    feature_pyramids = [_2, _3]
    predict_flow = self.predict_flow
    forward_residual_flow_pyramid = (predict_flow).forward(feature_pyramids[0], feature_pyramids[1], )
                                     ~~~~~~~~~~~~~~~~~~~~~ <--- HERE
    predict_flow0 = self.predict_flow
    backward_residual_flow_pyramid = (predict_flow0).forward(feature_pyramids[1], feature_pyramids[0], )
  File "code/__torch__/pyramid_flow_estimator.py", line 24, in forward
      level_size = torch.slice(torch.size(feature_pyramid_a[i]), 2, 4)
      v1 = _0(torch.mul(v0, 2), level_size, None, "bilinear", None, None, False, )
      warped = __torch__.util.warp(feature_pyramid_b[i], v1, )
               ~~~~~~~~~~~~~~~~~~~ <--- HERE
      _predictor0 = self._predictor
      v_residual = (_predictor0).forward(feature_pyramid_a[i], warped, )
  File "code/__torch__/util.py", line 78, in warp
  _31 = torch.sub(torch.unsqueeze(_30, 2), torch.select(normalized_flow2, -1, 0))
  normalized_flow20 = torch.stack([_28, _31], 3)
  warped = _20(image, normalized_flow20, "bilinear", "border", False, )
           ~~~ <--- HERE
  _32 = torch.reshape(warped, torch.size(image))
  return _32
  File "code/__torch__/torch/nn/functional.py", line 83, in grid_sample
  else:
    align_corners0 = unchecked_cast(bool, align_corners)
  _12 = torch.grid_sampler(input, grid, mode_enum, padding_mode_enum, align_corners0)
        ~~~~~~~~~~~~~~~~~~ <--- HERE
  return _12

Traceback of TorchScript, original code (most recent call last):
  File "C:\Users\Danylo\PycharmProjects\frame-interpolation-pytorch\interpolator.py", line 160, in forward
    @torch.jit.export
    def forward(self, x0, x1, batch_dt) -> torch.Tensor:
        return self.debug_forward(x0, x1, batch_dt)['image'][0]
               ~~~~~~~~~~~~~~~~~~ <--- HERE
  File "C:\Users\Danylo\PycharmProjects\frame-interpolation-pytorch\interpolator.py", line 109, in debug_forward

        # Predict forward flow.
        forward_residual_flow_pyramid = self.predict_flow(feature_pyramids[0], feature_pyramids[1])
                                        ~~~~~~~~~~~~~~~~~ <--- HERE

        # Predict backward flow.
  File "C:\Users\Danylo\PycharmProjects\frame-interpolation-pytorch\util.py", line 85, in warp
    ], dim=3)

    warped = F.grid_sample(image, normalized_flow2,
             ~~~~~~~~~~~~~ <--- HERE
                           mode='bilinear', padding_mode='border', align_corners=False)
    return warped.reshape(image.shape)
  File "C:\Users\Danylo\anaconda3\envs\research\lib\site-packages\torch\nn\functional.py", line 4223, in grid_sample
        align_corners = False

    return torch.grid_sampler(input, grid, mode_enum, padding_mode_enum, align_corners)
           ~~~~~~~~~~~~~~~~~~ <--- HERE
RuntimeError: MPS: Unsupported Border padding mode
deadcat000 commented 4 months ago

Seems to me like someone forgot to use relative paths? "C:\Users\Danylo..." clearly does not exist on a Mac.

gioferreira commented 4 months ago

I'm getting the same error on an M1 and M2, clean comfyui install. Tried with Taichi, Taichi Nightly, the error is always the same:

MPS: Unsupported Border padding mode

Python 3.10

Here's the full error:

!!! Exception during processing !!! Traceback (most recent call last): File "/Users/giovani/repos/ComfyUI/execution.py", line 151, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) File "/Users/giovani/repos/ComfyUI/execution.py", line 81, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) File "/Users/giovani/repos/ComfyUI/execution.py", line 74, in map_node_over_list results.append(getattr(obj, func)(slice_dict(input_data_all, i))) File "/Users/giovani/repos/ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation/vfi_models/rife/init.py", line 104, in vfi generic_frame_loop(frames, clear_cache_after_n_frames, multiplier, return_middle_frame, args, File "/Users/giovani/repos/ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation/vfi_utils.py", line 170, in generic_frame_loop middle_frame = return_middle_frame_function( File "/Users/giovani/repos/ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation/vfi_models/rife/init.py", line 98, in return_middle_frame return model(frame_0, frame_1, timestep, scale_list, in_fast_mode, in_ensemble) File "/Users/giovani/miniforge3/envs/comfy2024/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl return self._call_impl(args, kwargs) File "/Users/giovani/miniforge3/envs/comfy2024/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl return forward_call(*args, **kwargs) File "/Users/giovani/repos/ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation/vfi_models/rife/rife_arch.py", line 563, in forward warped_img0 = warp(img0, flow[:, :2]) File "/Users/giovani/repos/ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation/vfi_models/rife/rife_arch.py", line 59, in warp return torch.nn.functional.grid_sample( File "/Users/giovani/miniforge3/envs/comfy2024/lib/python3.10/site-packages/torch/nn/functional.py", line 4368, in grid_sample return torch.grid_sampler(input, grid, mode_enum, padding_mode_enum, align_corners) RuntimeError: MPS: Unsupported Border padding mode

tamler commented 4 months ago

I posted an issue on the potential issue: C:\PATH

deadcat000 commented 4 months ago

For anyone wanting to do frame interpolation on a Mac you could use these old nodes in the meantime https://github.com/melMass/comfy_mtb?tab=readme-ov-file#image-interpolation-animation download the FILM models here https://drive.google.com/drive/folders/1q8110-qp225asX3DQvZnfLfJPkCHmDpy But beware that it will fall back to CPU and be pretty slow.

h0x91b commented 3 months ago

I am changed ".../ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation/vfi_models/rife/rife_arch.py" line 63 from "border" to padding_mode="reflection", ("zeros" also works)

have no idea what result with border should be like, but with reflection it's acceptable for me at least...

michele-fadda commented 2 months ago

this unfortunately, for FILM rather than RIFE, cannot be solved by editing the custom mode code in Python, as the problem seems to be about the model itself.