diffus-me / sd-webui-facefusion

Next generation face swapper and enhancer
https://join.facefusion.io
92 stars 11 forks source link

ModuleNotFoundError: No module named 'tensorflow' #11

Closed Zyin055 closed 1 year ago

Zyin055 commented 1 year ago

During first time setup on Automatic1111 1.6.0 I get these errors:

ERROR: Invalid requirement: "'opencv-python" ERROR: Invalid requirement: "'opennsfw2" ERROR: Invalid requirement: "'tensorflow" ERROR: Invalid requirement: "'tqdm" ModuleNotFoundError: No module named 'tensorflow'

Also is there anything special we need to do for ffmpeg on Windows? I already have it installed from a few years back from another project. ffmpeg is a recognized command in my cmd prompt.

venv "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: v1.6.0
Commit hash: 5ef669de080814067961f28357256e8fe27544f4
Installing sd-webui-facefusion requirement: changing opencv-python version from 4.8.0.74 to 4.8.1.78
Couldn't install sd-webui-facefusion requirement: changing opencv-python version from 4.8.0.74 to 4.8.1.78.
Command: "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\Scripts\python.exe" -m pip install -U 'opencv-python>=4.8.1.78' --prefer-binary
Error code: 1
stderr: ERROR: Invalid requirement: "'opencv-python"

[notice] A new release of pip available: 22.2.1 -> 23.3.1
[notice] To update, run: C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\Scripts\python.exe -m pip install --upgrade pip

Warning: Failed to install 'opencv-python>=4.8.1.78', some preprocessors may not work.
Installing sd-webui-facefusion requirement: changing opennsfw2 version from None to 0.10.2
Couldn't install sd-webui-facefusion requirement: changing opennsfw2 version from None to 0.10.2.
Command: "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\Scripts\python.exe" -m pip install -U 'opennsfw2>=0.10.2' --prefer-binary
Error code: 1
stderr: ERROR: Invalid requirement: "'opennsfw2"

[notice] A new release of pip available: 22.2.1 -> 23.3.1
[notice] To update, run: C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\Scripts\python.exe -m pip install --upgrade pip

Warning: Failed to install 'opennsfw2>=0.10.2', some preprocessors may not work.
Installing sd-webui-facefusion requirement: changing tensorflow version from None to 2.13.0
Couldn't install sd-webui-facefusion requirement: changing tensorflow version from None to 2.13.0.
Command: "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\Scripts\python.exe" -m pip install -U 'tensorflow>=2.13.0' --prefer-binary
Error code: 1
stderr: ERROR: Invalid requirement: "'tensorflow"

[notice] A new release of pip available: 22.2.1 -> 23.3.1
[notice] To update, run: C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\Scripts\python.exe -m pip install --upgrade pip

Warning: Failed to install 'tensorflow>=2.13.0', some preprocessors may not work.
Installing sd-webui-facefusion requirement: changing tqdm version from 4.65.0 to 4.66.1
Couldn't install sd-webui-facefusion requirement: changing tqdm version from 4.65.0 to 4.66.1.
Command: "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\Scripts\python.exe" -m pip install -U 'tqdm>=4.66.1' --prefer-binary
Error code: 1
stderr: ERROR: Invalid requirement: "'tqdm"

[notice] A new release of pip available: 22.2.1 -> 23.3.1
[notice] To update, run: C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\Scripts\python.exe -m pip install --upgrade pip

Warning: Failed to install 'tqdm>=4.66.1', some preprocessors may not work.
#######################################################################################################
Initializing Civitai Link
If submitting an issue on github, please provide the below text for debugging purposes:

Python revision: 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Civitai Link revision: 136983e89859fd0477b4a437ed333142a6aa29a4
SD-WebUI revision: 5ef669de080814067961f28357256e8fe27544f4

Checking Civitai Link requirements...
[!] python-socketio[client] version 5.7.2 NOT installed.

#######################################################################################################
Launching Web UI with arguments: --opt-sdp-attention --no-download-sd-model --no-half-vae
no module 'xformers'. Processing without...
no module 'xformers'. Processing without...
No module 'xformers'. Proceeding without it.
Tag Autocomplete: Could not locate model-keyword extension, Lora trigger word completion will be limited to those added through the extra networks menu.
[-] ADetailer initialized. version: 23.9.2, num models: 9
2023-11-09 11:45:20,715 - ControlNet - INFO - ControlNet v1.1.410
ControlNet preprocessor location: C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\extensions\sd-webui-controlnet\annotator\downloads
2023-11-09 11:45:20,934 - ControlNet - INFO - ControlNet v1.1.410
*** Error loading script: facefusion_ui.py
    Traceback (most recent call last):
      File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\modules\scripts.py", line 382, in load_scripts
        script_module = script_loading.load_module(scriptfile.path)
      File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\modules\script_loading.py", line 10, in load_module
        module_spec.loader.exec_module(module)
      File "<frozen importlib._bootstrap_external>", line 883, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\extensions\sd-webui-facefusion\scripts\facefusion_ui.py", line 6, in <module>
        from facefusion.core import apply_args, get_argument_parser, limit_resources, pre_check
      File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\extensions\sd-webui-facefusion\facefusion\core.py", line 12, in <module>
        import tensorflow
    ModuleNotFoundError: No module named 'tensorflow'

---
Civitai: API loaded
Loading weights [73f48afbdc] from C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\models\Stable-diffusion\02~sd1.5\01~photoreal\ICantBelieveItsNotPhotography_final.safetensors
2023-11-09 11:45:22,401 - AnimateDiff - INFO - Hacking i2i-batch.
Creating model from config: C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\configs\v1-inference.yaml
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Civitai: Check resources for missing info files
Civitai: Check resources for missing preview images
Startup time: 27.1s (prepare environment: 12.1s, import torch: 4.7s, import gradio: 1.4s, setup paths: 1.2s, initialize shared: 0.3s, other imports: 0.9s, setup codeformer: 0.2s, list SD models: 0.3s, load scripts: 4.4s, create ui: 1.0s, gradio launch: 0.5s).
Civitai: Found 823 resources missing preview images
Civitai: Found 854 resources missing info files
Loading VAE weights specified in settings: C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\models\VAE\vae-ft-mse-840000-ema-pruned.ckpt
Applying attention optimization: sdp... done.
Civitai: No info found on Civitai
Model loaded in 8.0s (load weights from disk: 0.8s, create model: 0.7s, apply weights to model: 3.2s, apply dtype to VAE: 1.5s, load VAE: 0.3s, calculate empty prompt: 1.4s).
Civitai: No preview images found on Civitai
linjiX commented 1 year ago

This issue should caused by the misuse of the double quotes and single quotes:

In Windows Command Prompt, only double quotes are interpreted correctly -- single quotes are treated as part of the value.

That is why it works on Linux and MaxOS, but fails on Windows.

Now it should be fixed in 282165a789cfe354e5f9d4661e24fa10e68592b8, but I don't have Windows machine in my hand. Could you please pull the latest version and help test it? @Zyin055

Zyin055 commented 1 year ago

That fixed the installation issue.

I tried it and it works when the target is an image, but if I set the target to a video it errors, but I guess that's an issue for the main repo.

Traceback (most recent call last):█████████████████████████████████████████████████▎ | 355/363 [00:03<00:00, 129.15it/s]
  File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\lib\site-packages\gradio\routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\lib\site-packages\gradio\blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\lib\site-packages\gradio\blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\lib\site-packages\gradio\utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\extensions\sd-webui-facefusion\facefusion\uis\components\output.py", line 51, in start
    conditional_process()
  File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\extensions\sd-webui-facefusion\facefusion\core.py", line 192, in conditional_process
    process_video()
  File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\extensions\sd-webui-facefusion\facefusion\core.py", line 216, in process_video
    if predict_video(facefusion.globals.target_path):
  File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\extensions\sd-webui-facefusion\facefusion\predictor.py", line 57, in predict_video
    _, probabilities = opennsfw2.predict_video_frames(video_path = video_path, frame_interval = FRAME_INTERVAL)
  File "C:\Stuff\AI\SD\stable-diffusion-webui-LATEST\venv\lib\site-packages\opennsfw2\_inference.py", line 184, in predict_video_frames
    cv2.destroyAllWindows()  # pylint: disable=no-member
cv2.error: OpenCV(4.8.1) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:1266: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvDestroyAllWindows'