基础训练
This commit is contained in:
21
path.py
Normal file
21
path.py
Normal file
@ -0,0 +1,21 @@
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
def update_data_yml_path():
|
||||
root_dir = Path(__file__).parent.absolute()
|
||||
images_dir = root_dir / "data" / "images"
|
||||
data_yml_path = root_dir / "data.yaml"
|
||||
with open(data_yml_path, "r", encoding="utf-8") as f:
|
||||
yaml_data = yaml.safe_load(f)
|
||||
if yaml_data is None:
|
||||
yaml_data = {}
|
||||
yaml_data["path"] = str(images_dir.absolute())
|
||||
with open(data_yml_path, "w", encoding="utf-8") as f:
|
||||
yaml.safe_dump(
|
||||
yaml_data,
|
||||
f,
|
||||
allow_unicode=True,
|
||||
default_flow_style=False
|
||||
)
|
||||
Reference in New Issue
Block a user