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

我安装的是图形化界面,在我点击Translate后出现了问题 #523

Open
AshtonChan11 opened this issue Jan 24, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@AshtonChan11
Copy link

(Lerobot) robot@chase:~$ pdf2zh -i
(…)ayout_yolo_docstructbench_imgsz1024.onnx: 100%|█| 75.3M/75.3M [00:47<00:00, 1
Running on local URL:  http://0.0.0.0:7860

To create a public link, set `share=True` in `launch()`.
Traceback (most recent call last):
  File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/gradio/queueing.py", line 536, in process_events
    response = await route_utils.call_process_api(
  File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/gradio/route_utils.py", line 322, in call_process_api
    output = await app.get_blocks().process_api(
  File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/gradio/blocks.py", line 1935, in process_api
    result = await self.call_function(
  File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/gradio/blocks.py", line 1520, in call_function
    prediction = await anyio.to_thread.run_sync(  # type: ignore
  File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/anyio/to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
  File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 2461, in run_sync_in_worker_thread
    return await future
  File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 962, in run
    result = context.run(func, *args)
  File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/gradio/utils.py", line 826, in wrapper
    response = f(*args, **kwargs)
  File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/pdf2zh/gui.py", line 213, in translate_file
    cancellation_event_map[session_id] = asyncio.Event()
  File "/home/robot/.conda/envs/Lerobot/lib/python3.9/asyncio/locks.py", line 177, in __init__
    self._loop = events.get_event_loop()
  File "/home/robot/.conda/envs/Lerobot/lib/python3.9/asyncio/events.py", line 642, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'AnyIO worker thread'.

你好,请问这该如何解决呢?谢谢。
这是我的pdf文档:

Lerobot.pdf

@AshtonChan11 AshtonChan11 added the bug Something isn't working label Jan 24, 2025
@1325871795
Copy link

请问解决了吗

@1325871795
Copy link

实在不行的话可以尝试一下直接使用代码运行:
pdf2zh 你的文档.pdf
我尝试成功了。
也希望有人能够解决交互图形界面的问题,非常感谢。

@AshtonChan11
Copy link
Author

非常感谢❤️,用命令行确实可以成功翻译。不过很遗憾,能力有限,无法解决我先前的问题。
但现在又出了一点小问题:

pdf2zh example.pdf -s deepseek
set DEEPSEEK_API_KEY=sk-xxxxxxxxxxxxxxxx
set DEEPSEEK_MODEL=deepseek-chat

这样输入为什么会出现这样的错误呢:

> Namespace(files=['/home/robot/Downloads/Lerobot.pdf'], debug=False, pages=None, vfont='', vchar='', lang_in='en', lang_out='zh', service='deepseek', output='', thread=4, interactive=False, share=False, flask=False, celery=False, authorized=None, prompt=None, compatible=False, onnx=None, serverport=None, dir=False, config=None)
> Traceback (most recent call last):
>   File "/home/robot/.conda/envs/Lerobot/bin/pdf2zh", line 8, in <module>
>     sys.exit(main())
>   File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/pdf2zh/pdf2zh.py", line 264, in main
>     translate(model=ModelInstance.value, **vars(parsed_args))
>   File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/pdf2zh/high_level.py", line 355, in translate
>     s_mono, s_dual = translate_stream(
>   File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/pdf2zh/high_level.py", line 215, in translate_stream
>     obj_patch: dict = translate_patch(fp, **locals())
>   File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/pdf2zh/high_level.py", line 86, in translate_patch
>     device = TranslateConverter(
>   File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/pdf2zh/converter.py", line 167, in __init__
>     self.translator = translator(lang_in, lang_out, service_model, envs=envs, prompt=prompt)
>   File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/pdf2zh/translator.py", line 773, in __init__
>     super().__init__(lang_in, lang_out, model, base_url=base_url, api_key=api_key)
>   File "/home/robot/.conda/envs/Lerobot/lib/python3.9/site-packages/pdf2zh/translator.py", line 372, in __init__
>     api_key=api_key or self.envs["OPENAI_API_KEY"],
> KeyError: 'OPENAI_API_KEY'
> 

感谢🙏

@ramliu
Copy link

ramliu commented Jan 26, 2025

我和你遇到的问题一模一样,不知道如何解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants