报错信息如下
File "/root/app/app.py", line 9, in <module>
model = ORTModelForSequenceClassification.from_pretrained(file_name, local_files_only=True, force_download=False,
File "/opt/conda/lib/python3.9/site-packages/optimum/modeling_base.py", line 183, in from_pretrained
config_file = hf_hub_download(
File "/opt/conda/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 1022, in hf_hub_download
cache_dir, repo_folder_name(repo_id=repo_id, repo_type=repo_type)
File "/opt/conda/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py", line 92, in _inner_fn
validate_repo_id(arg_value)
File "/opt/conda/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py", line 136, in validate_repo_id
raise HFValidationError(
huggingface_hub.utils._validators.HFValidationError: Repo id must be in the form 'repo_name' or 'namespace/repo_name': '/root/app/emoji.onnx'. Use `repo_type` argument if needed.
代码如下
file_name = "/root/app/emoji.onnx"
model = ORTModelForSequenceClassification.from_pretrained(file_name, local_files_only=True, force_download=False,repo_type='local')
tokenizer = AutoTokenizer.from_pretrained(file_name, local_files_only=True, force_download=False, repo_type='local')
onnx_classifier = pipeline(
task="text-classification",
model=model,
tokenizer=tokenizer,
top_k=None,
function_to_apply="sigmoid", # optional as is the default for the task
)