From 92f10a163aff5657683cd6dee504d11192adfbbd Mon Sep 17 00:00:00 2001 From: Raykosan <71210053+Raykosan@users.noreply.github.com> Date: Sun, 5 Apr 2026 12:16:27 +0300 Subject: [PATCH] Adding the RS Last Frame node --- Rayko_Last_Frame.py | 90 +++++++++++++++++++++++++++++++++++++++ package.json | 3 +- pyproject.toml | 2 +- web/rs_last_frame_size.js | 10 +++++ 4 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 Rayko_Last_Frame.py create mode 100644 web/rs_last_frame_size.js diff --git a/Rayko_Last_Frame.py b/Rayko_Last_Frame.py new file mode 100644 index 0000000..3150303 --- /dev/null +++ b/Rayko_Last_Frame.py @@ -0,0 +1,90 @@ +import torch + +print("\033[93m🦊\033[0m \033[93mRaykoStudio - RS Last Frame \033[92mLOADED\033[0m") + +class RS_Last_Frame: + SIZE = (200, 40) + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "video_frames": ("*",), + } + } + + RETURN_TYPES = ("IMAGE",) + FUNCTION = "get_last_frame" + CATEGORY = "🦊 RaykoStudio" + + def get_last_frame(self, video_frames): + frames = None + + if isinstance(video_frames, torch.Tensor): + frames = video_frames + print(f"[RS_Last_Frame] ✅ Received ready IMAGE tensor: {frames.shape}") + + elif hasattr(video_frames, 'get_components'): + try: + comp = video_frames.get_components() + print(f"[RS_Last_Frame] 🔍 get_components returned type: {type(comp)}") + + if isinstance(comp, (tuple, list)) and len(comp) > 0: + frames = comp[0] + print(f"[RS_Last_Frame] 📦 Extracted from tuple[0]: {type(frames)}") + + elif isinstance(comp, dict): + frames = comp.get('video') or comp.get('frames') or comp.get('images') + print(f"[RS_Last_Frame] 📦 Extracted from dict: {type(frames)}") + + elif hasattr(comp, 'video'): + frames = comp.video + elif hasattr(comp, 'frames'): + frames = comp.frames + elif hasattr(comp, 'images'): + frames = comp.images + elif hasattr(comp, 'data'): + frames = comp.data + else: + frames = comp + print(f"[RS_Last_Frame] 📦 Direct assignment: {type(frames)}") + + if frames is not None: + print(f"[RS_Last_Frame] ✅ Successfully extracted frames: {type(frames)}, shape={getattr(frames, 'shape', 'N/A')}") + + except Exception as e: + print(f"[RS_Last_Frame] ❌ get_components error: {e}") + frames = None + + elif isinstance(video_frames, dict): + frames = video_frames.get('frames') or video_frames.get('images') or video_frames.get('video') + print(f"[RS_Last_Frame] 📦 Processed input dictionary") + + if frames is None: + raise ValueError( + f"❌ Failed to extract frames.\n" + f"Input type: {type(video_frames)}\n" + f"Available methods: {[m for m in dir(video_frames) if not m.startswith('_')]}" + ) + + if not isinstance(frames, torch.Tensor): + raise ValueError(f"Expected torch.Tensor, got {type(frames)}") + + if frames.dim() == 5: + frames = frames[0] + elif frames.dim() == 4 and frames.shape[1] <= 4: + frames = frames.permute(0, 2, 3, 1) + elif frames.dim() != 4: + raise ValueError(f"Unsupported tensor dimension: {frames.shape}") + + last_frame = frames[-1].unsqueeze(0) + print(f"[RS_Last_Frame] 🖼️ Returned last frame: {last_frame.shape}") + return (last_frame,) + +NODE_CLASS_MAPPINGS = { + "RS_Last_Frame": RS_Last_Frame +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "RS_Last_Frame": "🦊 RS Last Frame" +} \ No newline at end of file diff --git a/package.json b/package.json index 1e8068f..a4d063b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ComfyUI_RaykoStudio", - "version": "0.15.4", + "version": "0.15.5", "description": "Set of custom nodes for ComfyUI providing additional image processing capabilities", "author": "Raykosan", "license": "MIT", @@ -15,6 +15,7 @@ "Rayko_Image_Text.py" "Rayko_Insert_Crop.py" "Rayko_Intermediate_Spline_Mask.py" + "Rayko_Last_Frame.py" "Rayko_Loop_Switch.py" "Rayko_Models_Loader.py" "Rayko_Saturation.py" diff --git a/pyproject.toml b/pyproject.toml index 8544535..8a30d2a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "ComfyUI_RaykoStudio" description = "Set of custom nodes for ComfyUI providing additional image processing capabilities" -version = "0.15.4" +version = "0.15.5" license = { file = "LICENSE" } dependencies = ["torch>=1.7.0", "numpy>=1.19.0", "Pillow>=8.0.0", "freetype-py>=2.5.1"] diff --git a/web/rs_last_frame_size.js b/web/rs_last_frame_size.js new file mode 100644 index 0000000..6f98f47 --- /dev/null +++ b/web/rs_last_frame_size.js @@ -0,0 +1,10 @@ +import { app } from "/scripts/app.js"; + +app.registerExtension({ + name: "RaykoStudio.LastFrameSize", + nodeCreated(node) { + if (node.comfyClass === "RS_Last_Frame") { + node.setSize([200, 40]); + } + } +}); \ No newline at end of file