Péter Gergely Dániel
[Add & Upd] Derived all modules/abstract modules from BaseModule; Derived all module output types from DataObject; Added batch processing support for all modules and pipeline
64fab87 Download src/preprocessing/grayscale_alt.py from slityak/minyuuu: direct link, hf CLI and curl.
- Browser
- Download file 659 Bytes
-
https://huggingface.co/spaces/slityak/minyuuu/resolve/main/src/preprocessing/grayscale_alt.py
- Command line
-
hf download hf://spaces/slityak/minyuuu/src/preprocessing/grayscale_alt.py
-
curl -L -o grayscale_alt.py https://huggingface.co/spaces/slityak/minyuuu/resolve/main/src/preprocessing/grayscale_alt.py
659 Bytes
| """ | |
| Grayscale konverzió modul. | |
| Színes képet szürkeskálássá alakít. 1 csatornás képet ad vissza. | |
| (Base Modulból származtatott modul minta implementáció.) | |
| """ | |
| import cv2 | |
| import numpy as np | |
| from core import BaseModule, DataObject | |
| from constraints import TypeConstraint | |
| class GrayscaleConverterDemo(BaseModule): | |
| def __init__(self): | |
| super().__init__(name="Grayscale") | |
| self.add_constraint(TypeConstraint(np.uint8)) | |
| def _process(self, input: DataObject) -> DataObject: | |
| if len(input.shape) == 3 and input.shape[2] == 3: | |
| return DataObject(cv2.cvtColor(input.data, cv2.COLOR_BGR2GRAY)) | |
| return input |