Spaces:
Sleeping

File size: 1,054 Bytes
2e036a2
 
64fab87
 
2e036a2
64fab87
2e036a2
64fab87
 
2e036a2
 
64fab87
 
 
2e036a2
64fab87
2e036a2
64fab87
 
2e036a2
 
64fab87
 
2e036a2
64fab87
 
 
 
 
2e036a2
 
 
 
 
 
 
64fab87
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
Előfeldolgozó modulok ősosztálya.
Tartalmazott korlátozások:
- ImageLikeConstraint

Példa használat: Gauss-szűrés 1 képre
    class MyPreprocessor(PreprocessingModule):
        def _process(self, input: DataObject) -> DataObject:
            return Dataobject(cv2.GaussianBlur(input.data, (5, 5), 0))
"""

from .base_module import BaseModule
from constraints import ImageLikeConstraint
from typing import Any, Dict, List, final

from .data_object import DataObject


class PreprocessingModule(BaseModule):

    def __init__(self, name: str):
        super().__init__(name)
        self.add_constraint(ImageLikeConstraint())

        self.params: Dict[str, Any] = {}
    
    @final
    def preprocess(self, image: DataObject | List[DataObject]) -> DataObject | List[DataObject]:
        return self.process(image)

    def get_parameters(self) -> Dict[str, Any]:
        return {}

    def set_parameters(self, **kwargs):
        for key, value in kwargs.items():
            if key in self.params:
                self.params[key] = value