-
Notifications
You must be signed in to change notification settings - Fork 736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't create a session (local model) #979
Comments
I've created a small snippet to check my onnx model is fine:
So it works with |
Hey, I've done some work with custom models. The most important thing to note when using pretrained models is to ensure the structure is correct.
It's also possible to have a Then to reference that model I have the following. import { env, AutoModel, AutoProcessor, RawImage } from '@xenova/transformers';
// Force transformers to only look locally and not make any fetch requests.
env.allowLocalModels = true;
env.allowRemoteModels = false;
async function main() {
// Create the processor.
// The name here, should match the name of the folder in `models`
const processor = await AutoProcessor.from_pretrained('u2netp')
.catch(error => new Error(error));
if (processor instanceof Error) {
console.log(processor.message);
return;
}
// U2Net is an image based model, so you might skip this step.
const url = 'https://example.com/test.png';
const image = await RawImage.fromURL(url)
.catch(error => new Error(error));
if (image instanceof Error) {
console.error(image.message);
return;
}
// Preprocess the image.
const processed = await processor(image);
// Create the model, again the name should match the name of the folder.
// I am passing quantized: false because I do not have a
// `model_quantized.onnx` within the folder.
const model = await AutoModel.from_pretrained('u2netp', {
quantized: false,
});
// Get the outputs of the model.
const outputs = await model({ 'input': processed });
}
main(); |
Thanks @BritishWerewolf I have the right structure now, but I still get this error. I think it's caused by the way the model is converted. I also get this warning before the error:
I've tried changing the opset value as well when exporting my model to onnx (from gguf) with the optimum-cli but could find a way to make it working. So maybe the problem is coming from the way I generate my original gguf mode. I'm using unsloth to train the model and export it to gguf. |
It looks like you have everything nearly there, but your ONNX model is using a under development opset. To be clear, are you saying you did something like this: optimum-cli export onnx --model path_to_gguf_model --output path_to_output_directory --opset 3 I think setting to opset 3 is important. Other than that, I have not worked with GGUF so not entirely sure how to help. |
I used I came to the conclusing I should use this value when reading https://onnxruntime.ai/docs/reference/compatibility.html#onnx-opset-support I've also tried with 3 because of the warning, but in that case I got:
|
I switched to
I'm also getting the same error if I try to use the onnxruntime-web package directly. |
What are the specifics of the model? Looking at the onnx-runtime the following issue was created:
Does any of that help? |
Thanks @BritishWerewolf I'm going to try to disable quantization. |
Same without quantization in the original gguf model |
Can you help me to understand GGUF? |
I'm using unsloth to train my model and export it to gguf. Here is the code I use:
|
System Info
transformers.js 2.17.2
Environment/Platform
Description
I have my model available under the
/models/tokenizer
and/models/onnx/onnx
paths.I'm loading the tokenizer with:
And the model with:
I have my model under the 2 paths because it always adds
/onnx
a second time. I also had to setquantized
to false because otherwise it was adding a suffix to the file.I found it very difficult to find a way to get it loading the model on the right path.
Anyway, it's now getting the tokenizer and model files correctly, but then I get this error in the browser console (same with chrome and firefox).
Reproduction
I can't provide full reproduction steps because I'm using a local model.
But the code is:
The text was updated successfully, but these errors were encountered: