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

#643 PPYolo-E

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:feature/SG-344-PP-Yolo-E-Training-Replicate-Recipe
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  1. import inspect
  2. import os
  3. saved_codes = {}
  4. def save_code(obj):
  5. """
  6. A decorator function which save the code of the class/function in a file (to be kept along with the training logs)
  7. File name will be according to the class/function name
  8. usage:
  9. @save_code
  10. MyClass():
  11. ...
  12. def foo():
  13. ...
  14. @save_code
  15. def do_something():
  16. ...
  17. This example will generate two files named MyClass.py and do_something.py, that will be saved in the checkpoint directory
  18. and uploaded to remote storage (if defined). the text of the class and the function will also be added to the tensorboard (or
  19. any other tracking service)
  20. """
  21. code = inspect.getsource(obj)
  22. name = obj.__name__
  23. saved_codes[name] = code
  24. return obj
  25. def save_file(obj):
  26. """
  27. A decorator function which save the code of the entire file (to be kept along with the training logs).
  28. one call to this decorator in the file is enough to save the entire file
  29. usage:
  30. @save_file
  31. MyClass():
  32. ...
  33. def foo():
  34. ...
  35. def do_something():
  36. ...
  37. This example will save the file containing this code in the checkpoint directory and uploaded to remote storage (if defined).
  38. the content of the file will also be added to the tensorboard (or any other tracking service)
  39. """
  40. path = inspect.getsourcefile(obj)
  41. name = os.path.split(path)[-1]
  42. with open(path, "r") as f:
  43. code = f.read()
  44. saved_codes[name] = code
  45. return obj
Discard
Tip!

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