-
I want to load a model from a byte array per the
This throws an exception:
What am I missing here? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Do you store the initializer as external data? If so, you can convert external data to normal data by following this example: 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.save(onnx_model, "path/to/model") |
Beta Was this translation helpful? Give feedback.
-
I'm not sure. I got this model from hf: https://huggingface.co/nenkoru/alpaca-lora-7b-onnx-fp32-no-past It loads fine if I use by the way, I'm using ONNX in c# not python. |
Beta Was this translation helpful? Give feedback.
-
I check that model. It indeed uses external data. Per ONNX spec, a path is required in such case. The current workaround is to use the above Python script to More specifically, import onnx
from onnx.external_data_helper import load_external_data_for_model
onnx_model = onnx.load("decoder_model.onnx", load_external_data=False)
# Not sure if it's `decoder_model.onnx_data` or the folder containing `decoder_model.onnx_data`.
# Please try both.
load_external_data_for_model(onnx_model, "decoder_model.onnx_data")
# Then the onnx_model has loaded the external data from the specific directory
onnx.save(onnx_model, "desired_model.onnx") Then, in your C# code, use |
Beta Was this translation helpful? Give feedback.
-
Humm, it's protobuf limitation. There are several potential solutions/workarounds.
Not sure which one fits best to your scenario. |
Beta Was this translation helpful? Give feedback.
-
Hi guys Hi @wschin I have same issue : Is there a way to call ORTModelForCausalLM from optimum.onnxruntime inside pipeline of transformers.js (this is in python, )does it exit in transformers.js? example : import { pipeline, ORTModelForCausalLM } from ‘@xenova/transformers’; ?? let pipe = await pipeline(‘text-generation’,repo_id from huggingface); i have onnx files Is the concept of a "PrePackedWeightsContainer" exist in standard ONNX? some of my files : decoder_model.onnx_data. decoder_model.onnx (and samee with past model) , tokenizer.model, tokenizer.json, config.json...etc Thank you |
Beta Was this translation helpful? Give feedback.
Humm, it's protobuf limitation. There are several potential solutions/workarounds.
PrePackedWeightsContainer
.onnx_model.graph.initializer
toonnx_model.graph.input
and feed thoseinitializers
asinputs
when launchingInferenceSession
.Not sure which one fits best to your scenario.