mrhan1993 / Fooocus-API

FastAPI powered API for Fooocus
GNU General Public License v3.0
502 stars 131 forks source link

ModuleNotFoundError: No module named 'ldm_patched' when running main.py #351

Open carlosvillu opened 3 weeks ago

carlosvillu commented 3 weeks ago

Description: When attempting to run main.py with the command ['main.py', '--host', '0.0.0.0', '--port', '8888'], I encountered a ModuleNotFoundError related to ldm_patched. Below are the details of the error:

Error Message:

['main.py', '--host', '0.0.0.0', '--port', '8888']

[Fooocus API] Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]

[Fooocus API] Fooocus API version: 0.3.33

Traceback (most recent call last):
  File "/app/main.py", line 200, in <module>
    from fooocusapi.args import args
  File "/app/fooocusapi/args.py", line 2, in <module>
    import ldm_patched.modules.args_parser as args_parser
ModuleNotFoundError: No module named 'ldm_patched'

Steps to Reproduce:

  1. Run the command ['main.py', '--host', '0.0.0.0', '--port', '8888'] in the terminal.
  2. Observe the error message indicating that the ldm_patched module is not found.

Expected Behavior: The script should run without errors, initializing the Fooocus API as expected.

Actual Behavior: The script fails to run, raising a ModuleNotFoundError for the ldm_patched module.

Environment:

Additional Information: It appears that the ldm_patched module is either missing or not installed in the environment. Could you provide guidance on how to resolve this issue? Is there a specific package or dependency that needs to be installed?

Thank you for your assistance!

mrhan1993 commented 1 week ago

I would suggest you upgrade to the latest version.

carlosvillu commented 5 days ago

I have tested the current code in the repository, and it works perfectly on the first attempt.

However, the problem arises when I run this command:

docker run -d --name fooocus-api --restart unless-stopped --gpus=all \
    -e NVIDIA_DRIVER_CAPABILITIES=compute,utility \
    -e NVIDIA_VISIBLE_DEVICES=all \
    -v /home/carlosvillu/Development/Fooocus-API-docker/repositories:/app/repositories \
    -v ~/.cache/pip:/root/.cache/pip \
    -p 2025:8888 konieshadow/fooocus-api

I believe the issue is not with the repository itself but with the published Docker image.

Output:

[2024-06-25 14:24:24] INFO     [System ARGV] ['main.py', '--host', '0.0.0.0', '--port', '8888', '--skip-pip']
[2024-06-25 14:24:24] INFO     [Fooocus API] Python 3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0]
[2024-06-25 14:24:24] INFO     [Fooocus API] Fooocus API version: 0.4.0.6
Traceback (most recent call last):
  File "/app/main.py", line 195, in <module>
    from fooocusapi.args import args
  File "/app/fooocusapi/args.py", line 5, in <module>
    import ldm_patched.modules.args_parser as args_parser
ModuleNotFoundError: No module named 'ldm_patched'
mrhan1993 commented 5 days ago

我发布了一个新的 Docker 镜像,将 /home/carlosvillu/Development/Fooocus-API-docker 与仓库同步,然后再次使用你提供的命令重试。如果仍然不工作,尝试 -v /home/carlosvillu/Development/Fooocus-API-docker/repositories/Fooocus/models:/app/repositories/Fooocus/models , if any error, let me know. thx

I have released a new Docker image, and synchronizes /home/carloscillu/Development/Fooocus-API-docker with the repository, and then retry using the command you provided. If it still doesn't work, try -v /home/carlosvillu/Development/Fooocus-API-docker/repositories/Fooocus/models:/app/repositories/Fooocus/models , if any error, let me know. thx