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

#578 Feature/sg 516 support head replacement for local pretrained weights unknown dataset

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:feature/SG-516_support_head_replacement_for_local_pretrained_weights_unknown_dataset
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
  1. import json
  2. from termcolor import colored
  3. def indent_string(txt: str, indent_size: int) -> str:
  4. """Add an indentation to a string."""
  5. indent = " " * indent_size
  6. return indent + txt.replace("\n", "\n" + indent)
  7. def fmt_txt(txt: str, bold: bool = False, color: str = "", indent: int = 0) -> str:
  8. """Format a text for the console."""
  9. if bold:
  10. BOLD = "\033[1m"
  11. END = "\033[0m"
  12. txt = BOLD + txt + END
  13. if color:
  14. txt = colored(txt, color)
  15. if indent:
  16. txt = indent_string(txt, indent_size=indent)
  17. return txt
  18. def json_str_to_dict(json_str: str) -> dict:
  19. """Build a dictionary from a string in some sort of format."""
  20. json_str = json_str.replace("None", '"None"').replace("'", '"')
  21. return json.loads(json_str)
Discard
Tip!

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