Adding the RS Last Frame node
This commit is contained in:
@@ -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"
|
||||
}
|
||||
+2
-1
@@ -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"
|
||||
|
||||
+1
-1
@@ -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"]
|
||||
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user