From f6e19b146e870a0ada77ea7144fc2a904ba75c64 Mon Sep 17 00:00:00 2001 From: ComplexRobot Date: Sun, 16 Mar 2025 00:52:19 -0700 Subject: [PATCH] Initial commit. Added Simple Frame Interpolation node. --- .gitignore | 1 + LICENSE | 21 +++++++++++++++++++++ README.MD | 21 +++++++++++++++++++++ __init__.py | 3 +++ nodes.py | 40 ++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 15 +++++++++++++++ 6 files changed, 101 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.MD create mode 100644 __init__.py create mode 100644 nodes.py create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bee8a64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d4f218e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 ComplexRobot + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..5d21c30 --- /dev/null +++ b/README.MD @@ -0,0 +1,21 @@ +# ComfyUI Simple VFI + +Nodes for basic frame interpolation without the use of AI. + +## Table of Contents + +* [Nodes](#nodes) + * [Simple Frame Interpolation (VFI)](#simple-frame-interpolation-vfi) + +## Nodes + +### Simple Frame Interpolation (VFI) + +A node for doing very simple frame interpolation operations. +Uses basic operations (bicubic, lanczos, etc.) to blend the frames together. + +| | | +|--------------|--------------------------------------------------------------------------| +| images | Image frames to interpolate. | +| scale_method | Method used to interpolate the frames. | +| multiplier | Value to multiply the number of frames by. Not limited to whole numbers. | \ No newline at end of file diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..2e96bd6 --- /dev/null +++ b/__init__.py @@ -0,0 +1,3 @@ +from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS + +__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"] \ No newline at end of file diff --git a/nodes.py b/nodes.py new file mode 100644 index 0000000..0daafe0 --- /dev/null +++ b/nodes.py @@ -0,0 +1,40 @@ +import torch + +from nodes import ImageScale + +class Simple_Frame_Interpolation: + scale_methods = ["nearest", "nearest-exact", "bilinear", "area", "bicubic", "lanczos", "bislerp"] + @classmethod + def INPUT_TYPES(s): + return {"required": { + "images": ("IMAGE", ), + "scale_method": (s.scale_methods, {"default": "bislerp"}), + "multiplier": ("FLOAT", {"default": 0.5, "min": 0.01, "max": 20.0, "step": 0.01}), + }, + } + + RETURN_TYPES = ("IMAGE",) + RETURN_NAMES =("images",) + FUNCTION = "process" + + CATEGORY = "Simple-VFI" + + @torch.no_grad() + def process(self, images, scale_method, multiplier): + B, H, W, C = images.shape + new_frame_count = max(round(B * multiplier), 1) + + images = images.flatten(0, 2).unflatten(0, (1, B, H * W)) + images, = ImageScale.upscale(self, images, scale_method, H * W, new_frame_count, crop="disabled") + images = images.flatten(0, 2).unflatten(0, (new_frame_count, H, W)) + + return (images,) + + +NODE_CLASS_MAPPINGS = { + "Simple_Frame_Interpolation": Simple_Frame_Interpolation, + +} +NODE_DISPLAY_NAME_MAPPINGS = { + "Simple_Frame_Interpolation": "Simple Frame Interpolation (VFI)", +} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7daa221 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,15 @@ +[project] +name = "ComfyUI-Simple-VFI" +description = "Nodes for simple frame interpolation without the use of AI. Uses standard image operations to blend frames together." +version = "1.0.0" +license = "LICENSE" +dependencies = ["open-clip-torch"] + +[project.urls] +Repository = "https://github.com/ComplexRobot/ComfyUI-Simple-VFI" +# Used by Comfy Registry https://comfyregistry.org + +[tool.comfy] +PublisherId = "ComplexRobot" +DisplayName = "ComfyUI-Simple-VFI" +Icon = ""