V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
wswlaz
V2EX  ›  程序员

从本地加载 huggingface 模型报错,大佬帮忙看看

  •  
  •   wswlaz · 355 天前 · 1073 次点击
    这是一个创建于 355 天前的主题,其中的信息可能已经有所发展或是发生改变。

    报错信息如下

      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
    )
    
    wswlaz
        1
    wswlaz  
    OP
       355 天前
    为啥子诶,帮看看
    wswlaz
        2
    wswlaz  
    OP
       355 天前
    放弃了本地加载,开了代理下载的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5779 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 02:28 · PVG 10:28 · LAX 18:28 · JFK 21:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.