Seed YOLO training font locally
This commit is contained in:
@@ -80,6 +80,25 @@ import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def seed_ultralytics_font() -> None:
|
||||
font_candidates = [
|
||||
Path("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"),
|
||||
Path("/usr/share/fonts/truetype/liberation2/LiberationSans-Regular.ttf"),
|
||||
Path("/usr/share/fonts/truetype/freefont/FreeSans.ttf"),
|
||||
]
|
||||
source_font = next((font for font in font_candidates if font.exists()), None)
|
||||
if source_font is None:
|
||||
return
|
||||
config_root = Path(os.environ.get("YOLO_CONFIG_DIR", str(Path.home() / ".config")))
|
||||
target_font = config_root / "Ultralytics" / "Arial.ttf"
|
||||
target_font.parent.mkdir(parents=True, exist_ok=True)
|
||||
if not target_font.exists():
|
||||
shutil.copy2(source_font, target_font)
|
||||
|
||||
|
||||
seed_ultralytics_font()
|
||||
|
||||
from ultralytics import YOLO
|
||||
|
||||
dataset_yaml = Path(os.environ["DATASET_YAML"])
|
||||
|
||||
Reference in New Issue
Block a user