Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

#546 Features/sg 409 check all params used

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:features/SG-409-check-all-params-used
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
  1. from typing import Callable
  2. from abc import abstractmethod, ABC
  3. import numpy as np
  4. class TransformsPipelineAdaptorBase(ABC):
  5. def __init__(self, composed_transforms: Callable):
  6. self.composed_transforms = composed_transforms
  7. @abstractmethod
  8. def __call__(self, sample, *args, **kwargs):
  9. raise NotImplementedError
  10. @abstractmethod
  11. def prep_for_transforms(self, sample):
  12. raise NotImplementedError
  13. @abstractmethod
  14. def post_transforms_processing(self, sample):
  15. raise NotImplementedError
  16. class AlbumentationsAdaptor(TransformsPipelineAdaptorBase):
  17. def __init__(self, composed_transforms: Callable):
  18. super(AlbumentationsAdaptor, self).__init__(composed_transforms)
  19. def __call__(self, sample, *args, **kwargs):
  20. sample = self.prep_for_transforms(sample)
  21. sample = self.composed_transforms(**sample)["image"]
  22. sample = self.post_transforms_processing(sample)
  23. return sample
  24. def prep_for_transforms(self, sample):
  25. return {"image": np.array(sample)}
  26. def post_transforms_processing(self, sample):
  27. return sample
Discard
Tip!

Press p or to see the previous file or, n or to see the next file