Gourieff / comfyui-reactor-node

Fast and Simple Face Swap Extension Node for ComfyUI
GNU General Public License v3.0
1.57k stars 155 forks source link

Possible outdated installation instructions #92

Closed noytam closed 11 months ago

noytam commented 1 year ago

First, confirm

What happened?

I installed on a Windows 10 machine following the instructions saying it's possible to install only VS C++ Build Tools, however when I tried this it resulted in the error "ImportError: DLL load failed while importing mesh_core_cython: The specified module could not be found".

Only the method currently found under Troubleshooting->I. worked successfully. If this issue with installing after installing only VS C++ Build Tools reproduces consistently, I think the Troubleshooting->I. instructions should be moved to the official Installation section for Windows, and the line saying only VS C++ Build Tools are possible should be removed.

Steps to reproduce the problem

Installing on Windows 10 machine following instructions in the Installation section, installing only VS C++ Build Tools.

Sysinfo

Windows 10 22H2 OS build 19045.3570

Relevant console log

Traceback (most recent call last):
  File "C:\Program Files\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1735, in load_custom_node
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Program Files\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-reactor-node\__init__.py", line 25, in <module>
    from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
  File "C:\Program Files\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-reactor-node\nodes.py", line 4, in <module>
    from scripts.reactor_faceswap import FaceSwapScript, get_models
  File "C:\Program Files\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-reactor-node\scripts\reactor_faceswap.py", line 13, in <module>
    from scripts.reactor_swapper import swap_face
  File "C:\Program Files\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-reactor-node\scripts\reactor_swapper.py", line 11, in <module>
    import insightface
  File "C:\Program Files\ComfyUI_windows_portable\python_embeded\Lib\site-packages\insightface\__init__.py", line 18, in <module>
    from . import app
  File "C:\Program Files\ComfyUI_windows_portable\python_embeded\Lib\site-packages\insightface\app\__init__.py", line 2, in <module>
    from .mask_renderer import *
  File "C:\Program Files\ComfyUI_windows_portable\python_embeded\Lib\site-packages\insightface\app\mask_renderer.py", line 8, in <module>
    from ..thirdparty import face3d
  File "C:\Program Files\ComfyUI_windows_portable\python_embeded\Lib\site-packages\insightface\thirdparty\face3d\__init__.py", line 3, in <module>
    from . import mesh
  File "C:\Program Files\ComfyUI_windows_portable\python_embeded\Lib\site-packages\insightface\thirdparty\face3d\mesh\__init__.py", line 9, in <module>
    from .cython import mesh_core_cython
ImportError: DLL load failed while importing mesh_core_cython: The specified module could not be found.

Additional information

No response

Gourieff commented 1 year ago

Yes, it happens sometimes that Insightface cannot be built even if C++ BT installed, but normally it works ok

SachDana commented 10 months ago

I had this issue but i think it was more related to me lazily installing Python multiple times and then not even declaring paths properly. However in the interest of trying to figure things out i decided to try to create workarounds without uninstalling Python everywhere.

This assumes you've followed the troubleshooting guide and installed everything.

To Fix: If you haven't set your Path or used a venv then the insightface installed files may be wherever your Python is installed. For example mine i found in C:/Users/GigaNerd/AppData/Roaming/Python/Python311/site-packages/ Copy this folder to the python folder in Python_Embeded N.B Make sure in thirdparty\face3d\mesh\cython there are 3 folders called build, dist and mesh_core_cython.egg-info

This should solve your issue.

If however you have royally screwed up like i did and you are being told continually that you cannot find things even after these moves, you can change some .py files to declare locations manually.

Here are the files i've changed and it all now works: Issue 1. Error : albumenations at A Folder : ComfyUI_windows_portable/python_embeded/python311/Insightface/app/ file: mask_renderer.py Fix : Changed the first section of the file to this:

import os, sys, datetime
import numpy as np
import os.path as osp
from .face_analysis import FaceAnalysis
from ..utils import get_model_dir
from ..thirdparty import face3d
from ..data import get_image as ins_get_image
from ..utils import DEFAULT_MP_NAME
import cv2
sys.path.insert(0, 'C:/Users/GigaNerd/AppData/Roaming/Python/Python311/site-packages/')
import albumentations as A
from ..albumentations.core.transforms_interface import ImageOnlyTransform

Issue 2 Error: Issue with importlib.util.module_from_spec(spec) for some reason Folder: ComfyUI_windows_portable/python_embeded/python311/thirdparty/face3d/mesh/cython/ File: mesh_core_cython.py Fix : Changed to declare the file to use as follows

def __bootstrap__():
    global __bootstrap__, __loader__, __file__
    import sys, importlib.util

    # Put mesh_core_cython.cp311-win_amd64.pyd in this location
    __file__ = 'C:/Comfy/ComfyUI_windows_portable/python_embeded/python311/insightface/thirdparty/face3d/mesh/cython/mesh_core_cython.cp311-win_amd64.pyd'

    __loader__ = None; del __bootstrap__, __loader__
    spec = importlib.util.spec_from_file_location(__name__, __file__)
    mod = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(mod)

__bootstrap__()

Issue 3 - cannot remember what error i had that made me do this so Error : don't remember Folder : ComfyUI_windows_portable/python_embeded/python311/thirdparty/face3d/ File : init Fix replaced the whole file

import os, sys, datetime
#import mesh
#import morphable_model
sys.path.insert(0, 'C:/Comfy/ComfyUI_windows_portable/python_embeded/insightface/')
from . import mesh
from . import morphable_model