Skip to content

predict_g2p_bert.py报错 #23

@anaivebird

Description

@anaivebird

predict.sh:
python scripts/predict_g2p_bert.py
--config saved_models/CPP_BERT_M_DescWS-Sec-cLin-B_POSw01/config.py
--checkpoint saved_models/CPP_BERT_M_DescWS-Sec-cLin-B_POSw01/best_accuracy.pth
--sent_path cpp_dataset/test2.sent
--output_path output_pred.txt

(chatchat) root@a100:/home/data/tts/wetts/shtel/g2pW# sh predict.sh
Some weights of G2PW were not initialized from the model checkpoint at /home/nas/modelhub/llm/bert-base-chinese and are newly initialized: ['char_descriptor.weight', 'classifier.bias', 'pos_classifier.bias', 'second_order_descriptor.weight', 'classifier.weight', 'pos_classifier.weight', 'descriptor_bias.weight']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
Traceback (most recent call last):
File "/home/data/tts/wetts/shtel/g2pW/scripts/predict_g2p_bert.py", line 86, in
main(config, opt.checkpoint, opt.sent_path, output_path=opt.output_path)
File "/home/data/tts/wetts/shtel/g2pW/scripts/predict_g2p_bert.py", line 58, in main
preds, confidences = predict(model, dataloader, device, labels)
File "/home/data/tts/wetts/shtel/g2pW/./g2pw/api.py", line 29, in predict
probs = onnx_session.run(
File "/opt/conda/envs/chatchat/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1695, in getattr
raise AttributeError(f"'{type(self).name}' object has no attribute '{name}'")
AttributeError: 'G2PW' object has no attribute 'run'

看起来predict函数的第一个参数应该是一个onnx-session,但是predict_g2p_bert.py里传入predict第一个参数的是model = G2PW.from_pretrained

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions