Skip to content
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

Punctuation failed with CoreML #1448

Open
thewh1teagle opened this issue Oct 19, 2024 · 1 comment
Open

Punctuation failed with CoreML #1448

thewh1teagle opened this issue Oct 19, 2024 · 1 comment

Comments

@thewh1teagle
Copy link
Contributor

It failed with CoreML on macOS but works with CPU.

Log:

cargo run --example punctuate
   Compiling sherpa-rs v0.5.1-beta.0 (/Volumes/Internal/sherpa-rs)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.30s
     Running `target/debug/examples/punctuate`
/Users/runner/work/sherpa-onnx/sherpa-onnx/sherpa-onnx/c-api/c-api.cc:SherpaOnnxCreateOfflinePunctuation:1589 OfflinePunctuationConfig(model=OfflinePunctuationModelConfig(ct_transformer="./sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12/model.onnx", num_threads=1, debug=True, provider="coreml"))

/Users/runner/work/sherpa-onnx/sherpa-onnx/sherpa-onnx/csrc/offline-ct-transformer-model.cc:Init:117 
vocab_size: 272727
num_punctuations: 6
punctuations: <unk> _ , 。 ? 、 


--------------------
2024-10-20 02:46:26.496 punctuate[784:1415639] 2024-10-20 02:46:26.496798 [E:onnxruntime:, sequential_executor.cc:514 ExecuteKernel] Non-zero status code returned while running CoreML_15887252831431197149_7 node. Name:'CoreMLExecutionProvider_CoreML_15887252831431197149_7_7' Status Message: Error executing model: Unable to compute the prediction using a neural network model. It can be an invalid input data or broken/unsupported model (error code: -1).
fatal runtime error: Rust cannot catch foreign exceptions
[1]    784 abort      cargo run --example punctuate

Code:

/*
We assume you have pre-downloaded the model files for testing
from https://github.com/k2-fsa/sherpa-onnx/releases/tag/punctuation-models

wget https://github.com/k2-fsa/sherpa-onnx/releases/download/punctuation-models/sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2
tar xvf sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2
rm sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2

cargo run --example punctuate
*/

fn main() {
    let model = "./sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12/model.onnx";
    let sentences = [
        "这是一个测试你好吗How are you我很好thank you are you ok谢谢你", 
        "我们都是木头人不会说话不会动", 
        "The African blogosphere is rapidly expanding bringing more voices online in the form of commentaries opinions analyses rants and poetry"
    ];

    let config = sherpa_rs::punctuate::PunctuationConfig {
        model: model.into(),
        debug: true,
        ..Default::default()
    };
    let mut punctuate = sherpa_rs::punctuate::Punctuation::new(config).unwrap();

    println!("--------------------");
    for sentence in sentences {
        let punctuated = punctuate.add_punctuation(&sentence);
        println!("Input text: {}", sentence);
        println!("Output text: {}", punctuated);
        println!("--------------------");
    }
}
@csukuangfj
Copy link
Collaborator

I suggest that you use cpu at present.
Not every model supports coreml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants