Cluster/core/nodes/simple_input_node.py
2025-07-17 17:04:56 +08:00

129 lines
3.8 KiB
Python

"""
Simple Input node implementation compatible with NodeGraphQt.
This is a simplified version that ensures compatibility with the NodeGraphQt
registration system.
"""
try:
from NodeGraphQt import BaseNode
NODEGRAPH_AVAILABLE = True
except ImportError:
NODEGRAPH_AVAILABLE = False
# Create a mock base class
class BaseNode:
def __init__(self):
pass
class SimpleInputNode(BaseNode):
"""Simple Input node for data sources."""
__identifier__ = 'com.cluster.input_node'
NODE_NAME = 'Input Node'
def __init__(self):
super().__init__()
if NODEGRAPH_AVAILABLE:
# Setup node connections
self.add_output('output', color=(0, 255, 0))
self.set_color(83, 133, 204)
# Add basic properties
self.create_property('source_type', 'Camera')
self.create_property('device_id', 0)
self.create_property('resolution', '1920x1080')
self.create_property('fps', 30)
class SimpleModelNode(BaseNode):
"""Simple Model node for AI inference."""
__identifier__ = 'com.cluster.model_node'
NODE_NAME = 'Model Node'
def __init__(self):
super().__init__()
if NODEGRAPH_AVAILABLE:
# Setup node connections
self.add_input('input', multi_input=False, color=(255, 140, 0))
self.add_output('output', color=(0, 255, 0))
self.set_color(65, 84, 102)
# Add basic properties
self.create_property('model_path', '')
self.create_property('dongle_series', '720')
self.create_property('num_dongles', 1)
class SimplePreprocessNode(BaseNode):
"""Simple Preprocessing node."""
__identifier__ = 'com.cluster.preprocess_node'
NODE_NAME = 'Preprocess Node'
def __init__(self):
super().__init__()
if NODEGRAPH_AVAILABLE:
# Setup node connections
self.add_input('input', multi_input=False, color=(255, 140, 0))
self.add_output('output', color=(0, 255, 0))
self.set_color(45, 126, 72)
# Add basic properties
self.create_property('resize_width', 640)
self.create_property('resize_height', 480)
self.create_property('normalize', True)
class SimplePostprocessNode(BaseNode):
"""Simple Postprocessing node."""
__identifier__ = 'com.cluster.postprocess_node'
NODE_NAME = 'Postprocess Node'
def __init__(self):
super().__init__()
if NODEGRAPH_AVAILABLE:
# Setup node connections
self.add_input('input', multi_input=False, color=(255, 140, 0))
self.add_output('output', color=(0, 255, 0))
self.set_color(153, 51, 51)
# Add basic properties
self.create_property('output_format', 'JSON')
self.create_property('confidence_threshold', 0.5)
class SimpleOutputNode(BaseNode):
"""Simple Output node for data sinks."""
__identifier__ = 'com.cluster.output_node'
NODE_NAME = 'Output Node'
def __init__(self):
super().__init__()
if NODEGRAPH_AVAILABLE:
# Setup node connections
self.add_input('input', multi_input=False, color=(255, 140, 0))
self.set_color(255, 140, 0)
# Add basic properties
self.create_property('output_type', 'File')
self.create_property('destination', '')
self.create_property('format', 'JSON')
# Export the simple nodes
SIMPLE_NODE_TYPES = {
'Input Node': SimpleInputNode,
'Model Node': SimpleModelNode,
'Preprocess Node': SimplePreprocessNode,
'Postprocess Node': SimplePostprocessNode,
'Output Node': SimpleOutputNode
}