Skip to content

Commit 234e999

Browse files
authored
fix export dir
1 parent ee1b712 commit 234e999

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import dataclasses
1111
from typing import List, Tuple
1212
from collections import defaultdict
13+
import os
1314

1415
import cv2
1516
from skimage import io as skimageio
@@ -70,10 +71,12 @@ def __init__(self, model: str, model_dir: str, export_dir: str, device: str):
7071
try:
7172
model_path = f"{model_dir}/{model}"
7273
self.model = YOLO(model_path)
73-
exported_model_path = f"${export_dir}/${model}.engine"
74+
exported_model_path = f"{export_dir}/{model}.engine"
7475
should_export = device != "cpu" and not Path(exported_model_path).exists()
7576
if should_export:
76-
self.model.export(format="engine", device=device, half=True)
77+
path = self.model.export(format="engine", device=device, half=True)
78+
os.makedirs(os.path.dirname(exported_model_path), exist_ok=True)
79+
os.rename(path, exported_model_path)
7780
self.model = YOLO(exported_model_path)
7881
model_path = exported_model_path
7982
logging.info(f"Loaded {model_path} model")

0 commit comments

Comments
 (0)