Fix DataProcessor missing class error in pipeline deployment

- Add DataProcessor abstract base class with process method
- Add PostProcessor class for handling inference output data
- Fix PreProcessor inheritance from DataProcessor
- Resolves "name 'DataProcessor' is not defined" error during pipeline deployment

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Masonmason 2025-07-16 20:53:41 +08:00
parent b5e3227b0e
commit f5e017b099

View File

@ -13,7 +13,16 @@ from abc import ABC, abstractmethod
from typing import Callable, Optional, Any, Dict
class PreProcessor(DataProcessor): # type: ignore
class DataProcessor(ABC):
"""Abstract base class for data processors in the pipeline"""
@abstractmethod
def process(self, data: Any, *args, **kwargs) -> Any:
"""Process data and return result"""
pass
class PreProcessor(DataProcessor):
def __init__(self, resize_fn: Optional[Callable] = None,
format_convert_fn: Optional[Callable] = None):
self.resize_fn = resize_fn or self._default_resize
@ -36,6 +45,22 @@ class PreProcessor(DataProcessor): # type: ignore
return cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA)
return frame
class PostProcessor(DataProcessor):
"""Post-processor for handling output data from inference stages"""
def __init__(self, process_fn: Optional[Callable] = None):
self.process_fn = process_fn or self._default_process
def process(self, data: Any, *args, **kwargs) -> Any:
"""Process inference output data"""
return self.process_fn(data, *args, **kwargs)
def _default_process(self, data: Any, *args, **kwargs) -> Any:
"""Default post-processing - returns data unchanged"""
return data
class MultiDongle:
# Curently, only BGR565, RGB8888, YUYV, and RAW8 formats are supported
_FORMAT_MAPPING = {