add export to FP16

add inference with possibility to have different
This commit is contained in:
zxsanny
2025-03-28 12:54:25 +02:00
parent eaef1a9b66
commit 5b89a21b36
9 changed files with 365 additions and 242 deletions
+5 -14
View File
@@ -31,22 +31,13 @@ def export_onnx(model_path):
return Path(model_path).stem + '.onnx'
def export_tensorrt(model_path, dataset_yaml):
form_data_sample(path.join(path.dirname(dataset_yaml), 'minival', 'images'))
model = YOLO(model_path)
with open(dataset_yaml, 'r') as file:
yaml_data = yaml.safe_load(file) or {}
yaml_data['minival'] = 'minival/images'
with open(dataset_yaml, 'w') as file:
yaml.dump(yaml_data, file)
model.export(
def export_tensorrt(model_path):
YOLO(model_path).export(
format='engine',
batch=4,
half=True,
nms=True,
data=dataset_yaml,
split='minival'
simplify=True,
nms=True
)
def form_data_sample(destination_path, size=500, write_txt_log=False):
@@ -76,6 +67,6 @@ def show_model(model: str = None):
if __name__ == '__main__':
export_tensorrt('azaion-2025-03-10.pt', path.join(datasets_dir, 'azaion-2025-03-10', 'data.yaml'))
export_tensorrt('azaion-2025-03-10.pt')
# export_rknn('azaion-2025-03-10.pt')
# export_onnx('azaion-2025-03-10.pt')