🤣外部数据
External Data
import onnx
onnx_model = onnx.load("path/to/the/model.onnx")import onnx
from onnx.external_data_helper import load_external_data_for_model
onnx_model = onnx.load("path/to/the/model.onnx", load_external_data=False)
load_external_data_for_model(onnx_model, "data/directory/path/")
# Then the onnx_model has loaded the external data from the specific directory将 ONNX 模型转换为外部数据
import onnx
from onnx.external_data_helper import convert_model_to_external_data
onnx_model = ... # Your model in memory as ModelProto
convert_model_to_external_data(onnx_model, all_tensors_to_one_file=True, location="filename", size_threshold=1024, convert_attribute=False)
# Must be followed by save_model to save the converted model to a specific path
onnx.save_model(onnx_model, "path/to/save/the/model.onnx")
# Then the onnx_model has converted raw data as external data and saved to specific directory将 ONNX 模型转换为外部数据并保存
onnx.checker 用于带有外部数据的模型
onnx.checker 用于带有外部数据的模型Models with External Data (<2GB)
Large models >2GB
TensorProto: data_location and external_data fields
data_location field
external_data field
External data files
Last updated