(*input)
| 684 | |
| 685 | |
| 686 | def colorstr(*input): |
| 687 | # Colors a string https://en.wikipedia.org/wiki/ANSI_escape_code, i.e. colorstr('blue', 'hello world') |
| 688 | *args, string = input if len(input) > 1 else ('blue', 'bold', input[0]) # color arguments, string |
| 689 | colors = { |
| 690 | 'black': '\033[30m', # basic colors |
| 691 | 'red': '\033[31m', |
| 692 | 'green': '\033[32m', |
| 693 | 'yellow': '\033[33m', |
| 694 | 'blue': '\033[34m', |
| 695 | 'magenta': '\033[35m', |
| 696 | 'cyan': '\033[36m', |
| 697 | 'white': '\033[37m', |
| 698 | 'bright_black': '\033[90m', # bright colors |
| 699 | 'bright_red': '\033[91m', |
| 700 | 'bright_green': '\033[92m', |
| 701 | 'bright_yellow': '\033[93m', |
| 702 | 'bright_blue': '\033[94m', |
| 703 | 'bright_magenta': '\033[95m', |
| 704 | 'bright_cyan': '\033[96m', |
| 705 | 'bright_white': '\033[97m', |
| 706 | 'end': '\033[0m', # misc |
| 707 | 'bold': '\033[1m', |
| 708 | 'underline': '\033[4m'} |
| 709 | return ''.join(colors[x] for x in args) + f'{string}' + colors['end'] |
| 710 | |
| 711 | |
| 712 | def labels_to_class_weights(labels, nc=80): |
no outgoing calls
no test coverage detected