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

#381 Feature/sg 000 connect to lab

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:feature/sg-000_connect_to_lab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  1. import inspect
  2. from typing import Callable, Optional
  3. from super_gradients.training.models.all_architectures import ARCHITECTURES
  4. def register_model(name: Optional[str] = None) -> Callable:
  5. def model_decorator(model: Callable) -> Callable:
  6. if name is not None:
  7. model_name = name
  8. else:
  9. model_name = model.__name__
  10. if model_name in ARCHITECTURES:
  11. ref = ARCHITECTURES[model_name]
  12. raise Exception(
  13. f"`{model_name}` is already registered and points to `{inspect.getmodule(ref).__name__}.{ref.__name__}"
  14. )
  15. ARCHITECTURES[model_name] = model
  16. return model
  17. return model_decorator
Discard
Tip!

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