neavo / KeywordGacha

使用 OpenAI 兼容接口自动生成小说、漫画、字幕、游戏脚本等内容文本中实体词语表的翻译辅助工具
115 stars 6 forks source link

运行时设置语言后,运行出错 #32

Closed jeshs closed 1 month ago

jeshs commented 1 month ago

1、git clone代码 2、调本地conda环境运行程序,运行脚本:

@echo off
REM 激活 Conda 环境
call "D:\Programs\miniconda3\Scripts\activate.bat" keywordgacha

REM 运行 Python 脚本
python main.py

REM 暂停以查看输出(可选)
pause

3、选择日文文本,然后出错 image

4、错误日志

[2024-07-20 16:04:32] [ERROR] Repo id must use alphanumeric chars or '-', '_', '.', '--' and '..' are forbidden, '-' and '.' cannot start or end the name, max length is 96: 'resource\kg_ner_ja_onnx_cpu'.
Traceback (most recent call last):
  File "D:\Code\KeywordGacha\main.py", line 479, in main
    await begin()
  File "D:\Code\KeywordGacha\main.py", line 383, in begin
    ner = NER()
          ^^^^^
  File "D:\Code\KeywordGacha\model\NER.py", line 72, in __init__
    model = ORTModelForTokenClassification.from_pretrained(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Programs\miniconda3\envs\keywordgacha\Lib\site-packages\optimum\onnxruntime\modeling_ort.py", line 720, in from_pretrained
    return super().from_pretrained(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Programs\miniconda3\envs\keywordgacha\Lib\site-packages\optimum\modeling_base.py", line 377, in from_pretrained
    library_name = TasksManager.infer_library_from_model(model_id, subfolder, revision, cache_dir, token=token)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Programs\miniconda3\envs\keywordgacha\Lib\site-packages\optimum\exporters\tasks.py", line 1762, in infer_library_from_model
    all_files, _ = TasksManager.get_model_files(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Programs\miniconda3\envs\keywordgacha\Lib\site-packages\optimum\exporters\tasks.py", line 1421, in get_model_files
    all_files = huggingface_hub.list_repo_files(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Programs\miniconda3\envs\keywordgacha\Lib\site-packages\huggingface_hub\utils\_validators.py", line 106, in _inner_fn
    validate_repo_id(arg_value)
  File "D:\Programs\miniconda3\envs\keywordgacha\Lib\site-packages\huggingface_hub\utils\_validators.py", line 160, in validate_repo_id
    raise HFValidationError(
huggingface_hub.errors.HFValidationError: Repo id must use alphanumeric chars or '-', '_', '.', '--' and '..' are forbidden, '-' and '.' cannot start or end the name, max length is 96: 'resource\kg_ner_ja_onnx_cpu'.
[2024-07-20 16:04:32] [ERROR] 出现严重错误,程序即将退出,错误信息已保存至日志文件 [green]KeywordGacha.log[/] ...
neavo commented 1 month ago

为了方便打包,本地开发环境没有使用conda等第三方虚拟环境,直接使用的官方的 py embed 将完整的运行环境打包进了项目,所以如果要从源码运行的话,可以直接使用 02.打包.bat 来建立环境,或者参考一下脚本里的步骤 我看你后面又发了一个 https://github.com/neavo/KeywordGacha/issues/33 所以后来是已经调通了吗?

jeshs commented 1 month ago

后面是用release下载的跑的

neavo commented 1 month ago

想从源码跑的话,最简单的方法就是运行一遍 02_打包.bat ,然后把 dist\KeywordGacha\ 里的文件都复制到根目录就可以了

其实主要就是模型没打包进去,模型在这里 https://github.com/neavo/KeywordGachaModel

手动下载以后放到 \resource\kg_ner_ja_onnx_cpu 也行

顺便问一下,https://github.com/neavo/KeywordGacha/issues/33 是一直都没跑通,还是只是一开始配置错误时出现的报错

jeshs commented 1 month ago

是配置问题,有时候是key失效了,有时候是待翻译的文件不是正确的json格式,修改后可以了