2026-02-06
neat-ly organize multiline strings for print()
def neat(s, indent=''):
min_spaces = 1000
lines = s.splitlines()
# Drop the first line.
if len(lines) and len(lines[0].strip()) == 0:
lines.pop(0)
# Drop the last line.
if len(lines) and len(lines[-1].strip()) == 0:
lines.pop(-1)
# Find initial indent.
for line in lines:
space_cnt = len(line) - len(line.lstrip(' '))
if len(line) > 1 and space_cnt < min_spaces:
min_spaces = space_cnt
# Remove indent.
new_lines = []
for line in s.splitlines():
new_lines.append(indent + line[min_spaces:])
return '\n'.join(new_lines)
def info_yolo5(args):
print(neat('''
Some text that I want to be clearly indented
with the code. Here is a list:
- Item 1
- Item 2
+ Another sublist
''', indent=' '))
Output:
Some text that I want to be clearly indented
with the code. Here is a list:
- Item 1
- Item 2
+ Another sublist
Yolo Generation via Ultralytics Docker
From outside container:
docker pull ultralytics/ultralytics:8.4.8-python-export
docker run -it --rm \
-v $(pwd):/workspace \
ultralytics/ultralytics:8.4.8-python-export \
bash
From inside container:
cd /workspace
# Dump a tflite (implicitly based on onnx opset 22)
yolo export model=/workspace/yolov5su.pt format=tflite
# Explicitly dump onnx with opset 14.
yolo export model=yolov5su.pt format=onnx opset=14