mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-27 19:02:31 +08:00
comfy_api: Add datatype for ImageStreams
This commit is contained in:
parent
acd718598e
commit
1f0c02eb6c
@ -51,6 +51,7 @@ class IO(StrEnum):
|
|||||||
BBOX = "BBOX"
|
BBOX = "BBOX"
|
||||||
SEGS = "SEGS"
|
SEGS = "SEGS"
|
||||||
VIDEO = "VIDEO"
|
VIDEO = "VIDEO"
|
||||||
|
IMAGE_STREAM = "IMAGE_STREAM"
|
||||||
|
|
||||||
ANY = "*"
|
ANY = "*"
|
||||||
"""Always matches any type, but at a price.
|
"""Always matches any type, but at a price.
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
from comfy_api.latest._input import (
|
from comfy_api.latest._input import (
|
||||||
ImageInput,
|
ImageInput,
|
||||||
AudioInput,
|
AudioInput,
|
||||||
|
ImageStreamInput,
|
||||||
MaskInput,
|
MaskInput,
|
||||||
LatentInput,
|
LatentInput,
|
||||||
VideoInput,
|
VideoInput,
|
||||||
@ -14,6 +15,7 @@ from comfy_api.latest._input import (
|
|||||||
__all__ = [
|
__all__ = [
|
||||||
"ImageInput",
|
"ImageInput",
|
||||||
"AudioInput",
|
"AudioInput",
|
||||||
|
"ImageStreamInput",
|
||||||
"MaskInput",
|
"MaskInput",
|
||||||
"LatentInput",
|
"LatentInput",
|
||||||
"VideoInput",
|
"VideoInput",
|
||||||
|
|||||||
6
comfy_api/input/image_stream_types.py
Normal file
6
comfy_api/input/image_stream_types.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# This file only exists for backwards compatibility.
|
||||||
|
from comfy_api.latest._input.image_stream_types import ImageStreamInput
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"ImageStreamInput",
|
||||||
|
]
|
||||||
@ -5,7 +5,7 @@ from typing import TYPE_CHECKING
|
|||||||
from comfy_api.internal import ComfyAPIBase
|
from comfy_api.internal import ComfyAPIBase
|
||||||
from comfy_api.internal.singleton import ProxiedSingleton
|
from comfy_api.internal.singleton import ProxiedSingleton
|
||||||
from comfy_api.internal.async_to_sync import create_sync_class
|
from comfy_api.internal.async_to_sync import create_sync_class
|
||||||
from ._input import ImageInput, AudioInput, MaskInput, LatentInput, VideoInput
|
from ._input import ImageInput, AudioInput, ImageStreamInput, MaskInput, LatentInput, VideoInput
|
||||||
from ._input_impl import VideoFromFile, VideoFromComponents
|
from ._input_impl import VideoFromFile, VideoFromComponents
|
||||||
from ._util import VideoCodec, VideoContainer, VideoComponents, MESH, VOXEL, File3D
|
from ._util import VideoCodec, VideoContainer, VideoComponents, MESH, VOXEL, File3D
|
||||||
from . import _io_public as io
|
from . import _io_public as io
|
||||||
@ -131,6 +131,7 @@ class ComfyExtension(ABC):
|
|||||||
class Input:
|
class Input:
|
||||||
Image = ImageInput
|
Image = ImageInput
|
||||||
Audio = AudioInput
|
Audio = AudioInput
|
||||||
|
ImageStream = ImageStreamInput
|
||||||
Mask = MaskInput
|
Mask = MaskInput
|
||||||
Latent = LatentInput
|
Latent = LatentInput
|
||||||
Video = VideoInput
|
Video = VideoInput
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
from .basic_types import ImageInput, AudioInput, MaskInput, LatentInput
|
from .basic_types import ImageInput, AudioInput, MaskInput, LatentInput
|
||||||
from .curve_types import CurvePoint, CurveInput, MonotoneCubicCurve, LinearCurve
|
from .curve_types import CurvePoint, CurveInput, MonotoneCubicCurve, LinearCurve
|
||||||
|
from .image_stream_types import ImageStreamInput
|
||||||
from .video_types import VideoInput
|
from .video_types import VideoInput
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"ImageInput",
|
"ImageInput",
|
||||||
"AudioInput",
|
"AudioInput",
|
||||||
|
"ImageStreamInput",
|
||||||
"VideoInput",
|
"VideoInput",
|
||||||
"MaskInput",
|
"MaskInput",
|
||||||
"LatentInput",
|
"LatentInput",
|
||||||
|
|||||||
48
comfy_api/latest/_input/image_stream_types.py
Normal file
48
comfy_api/latest/_input/image_stream_types.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
|
from .basic_types import ImageInput
|
||||||
|
|
||||||
|
|
||||||
|
class ImageStreamInput(ABC):
|
||||||
|
"""Abstract base class for pull-based image stream inputs.
|
||||||
|
|
||||||
|
Consumers request up to ``max_frames`` frames at a time. Producers must not
|
||||||
|
over-return; a batch with fewer than ``max_frames`` frames signals EOF.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
#Subclasses must call this init for future core ComfyUI change compatibilty
|
||||||
|
pass
|
||||||
|
|
||||||
|
def reset(self) -> None:
|
||||||
|
#This API is final. Subclasses must NOT override this for future core ComfyUI
|
||||||
|
#change compatability. Override do_reset instead.
|
||||||
|
return self.do_reset()
|
||||||
|
|
||||||
|
def pull(self, max_frames: int) -> ImageInput:
|
||||||
|
#This API is final. Subclasses must NOT override this for future core ComfyUI
|
||||||
|
#change compatability. Override do_pull instead.
|
||||||
|
return self.do_pull(max_frames)
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_dimensions(self) -> tuple[int, int]:
|
||||||
|
"""Return the stream frame dimensions as ``(width, height)``."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def do_reset(self) -> None:
|
||||||
|
"""Reset the stream so the next pull starts from frame 0."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def do_pull(self, max_frames: int) -> ImageInput:
|
||||||
|
"""Return up to ``max_frames`` images.
|
||||||
|
|
||||||
|
The returned tensor uses the normal ``IMAGE`` batch shape. A short
|
||||||
|
return, where the batch dimension is less than ``max_frames``, is the
|
||||||
|
EOF signal. Sources are expected to short-return at least once before
|
||||||
|
exhaustion, including returning an empty batch.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
@ -23,7 +23,7 @@ if TYPE_CHECKING:
|
|||||||
from comfy.samplers import CFGGuider, Sampler
|
from comfy.samplers import CFGGuider, Sampler
|
||||||
from comfy.sd import CLIP, VAE
|
from comfy.sd import CLIP, VAE
|
||||||
from comfy.sd import StyleModel as StyleModel_
|
from comfy.sd import StyleModel as StyleModel_
|
||||||
from comfy_api.input import VideoInput, CurveInput as CurveInput_
|
from comfy_api.input import ImageStreamInput, VideoInput, CurveInput as CurveInput_
|
||||||
from comfy_api.internal import (_ComfyNodeInternal, _NodeOutputInternal, classproperty, copy_class, first_real_override, is_class,
|
from comfy_api.internal import (_ComfyNodeInternal, _NodeOutputInternal, classproperty, copy_class, first_real_override, is_class,
|
||||||
prune_dict, shallow_clone_class)
|
prune_dict, shallow_clone_class)
|
||||||
from comfy_execution.graph_utils import ExecutionBlocker
|
from comfy_execution.graph_utils import ExecutionBlocker
|
||||||
@ -420,6 +420,12 @@ class Image(ComfyTypeIO):
|
|||||||
Type = torch.Tensor
|
Type = torch.Tensor
|
||||||
|
|
||||||
|
|
||||||
|
@comfytype(io_type="IMAGE_STREAM")
|
||||||
|
class ImageStream(ComfyTypeIO):
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
Type = ImageStreamInput
|
||||||
|
|
||||||
|
|
||||||
@comfytype(io_type="WAN_CAMERA_EMBEDDING")
|
@comfytype(io_type="WAN_CAMERA_EMBEDDING")
|
||||||
class WanCameraEmbedding(ComfyTypeIO):
|
class WanCameraEmbedding(ComfyTypeIO):
|
||||||
Type = torch.Tensor
|
Type = torch.Tensor
|
||||||
@ -2203,6 +2209,7 @@ __all__ = [
|
|||||||
"Combo",
|
"Combo",
|
||||||
"MultiCombo",
|
"MultiCombo",
|
||||||
"Image",
|
"Image",
|
||||||
|
"ImageStream",
|
||||||
"WanCameraEmbedding",
|
"WanCameraEmbedding",
|
||||||
"Webcam",
|
"Webcam",
|
||||||
"Mask",
|
"Mask",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user