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

#399 Feature/sg 326 replace function with class in architectures

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:feature/sg-326-replace_function_with_class_in_architectures
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  1. from typing import Union, Mapping
  2. from omegaconf import ListConfig
  3. from super_gradients.common.factories.base_factory import BaseFactory
  4. from super_gradients.common.factories.list_factory import ListFactory
  5. from super_gradients.training.transforms import TRANSFORMS
  6. class TransformsFactory(BaseFactory):
  7. def __init__(self):
  8. super().__init__(TRANSFORMS)
  9. def get(self, conf: Union[str, dict]):
  10. # SPECIAL HANDLING FOR COMPOSE
  11. if isinstance(conf, Mapping) and 'Compose' in conf:
  12. conf['Compose']['transforms'] = ListFactory(TransformsFactory()).get(conf['Compose']['transforms'])
  13. elif isinstance(conf, (list, ListConfig)):
  14. conf = ListFactory(TransformsFactory()).get(conf)
  15. return super().get(conf)
Discard
Tip!

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