From f5e017b099f4ab7c8284bf6ba1d928b3d1815cd7 Mon Sep 17 00:00:00 2001 From: Masonmason Date: Wed, 16 Jul 2025 20:53:41 +0800 Subject: [PATCH] Fix DataProcessor missing class error in pipeline deployment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- cluster4npu_ui/core/functions/Multidongle.py | 27 +++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/cluster4npu_ui/core/functions/Multidongle.py b/cluster4npu_ui/core/functions/Multidongle.py index 0dfb2df..bdacb7c 100644 --- a/cluster4npu_ui/core/functions/Multidongle.py +++ b/cluster4npu_ui/core/functions/Multidongle.py @@ -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 = {