[REQUEST] ONNX fp16

#2
by jspsoli - opened

Sorry to bother you again.
Made a quick conversion of the .onnx model to fp16 and compared the results with fp32 on 5 imgs and they were exactly the same. Whatever precision is lost - is worth the VRAM tradeoff.
I want users of my script to be able to download the model directly from your page - if possible.

You can easily convert with this script:

import os
import onnx
from onnxconverter_common import float16
import argparse

if name == "main":
parser = argparse.ArgumentParser()
parser.add_argument("--fp32_model", type=str, required=True, help="Full path for the fp32 .onnx model.")
args = parser.parse_args()

if os.path.isfile(args.fp32_model) and args.fp32_model.lower().endswith(".onnx"):
    new_model_path = args.fp32_model.lower().replace(".onnx", "_fp16.onnx")
    model = onnx.load(args.fp32_model)
    model_fp16 = float16.convert_float_to_float16(model)
    onnx.save(model_fp16, new_model_path)
    print(f"Model successfully converted and stored in: {new_model_path}")
else:
    print("Invalid path!")

ONNX fp16 model added!

jspsoli changed discussion status to closed

Sign up or log in to comment