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

face_enhancer isn't found. #940

Open
Uniqbank opened this issue Feb 15, 2025 · 8 comments
Open

face_enhancer isn't found. #940

Uniqbank opened this issue Feb 15, 2025 · 8 comments

Comments

@Uniqbank
Copy link

Hi @hacksider,

Great to e-meet you! I came across your project, and I must say it stands out among many others—it's incredibly clean and well-structured. Well done!

I have a quick question for anyone who may have encountered this issue.

When running python run.py, I’m getting the error:
Frame processor face_enhancer not found
However, face_swapper loads without any issues.

If anyone has faced this before, I’d appreciate any insights on what I might be missing.

Setup:
MacBook (Intel)

Thanks in advance!

@Uniqbank
Copy link
Author

I managed to resolve this, but getting another issue now:

With following settings:
Image

After click on 'Live' it does pop up a screen with source image as starting point with following issues:

  1. face part has a black square and its not rendering the target image's face properly in live mode as expected.
    2 fps rate is just 0.5.

I have followed the instruction steps but I am on a Macbook (Intel). Is there's something missing for mac setup? Thanks

@kirillbush91
Copy link

Hi @Uniqbank
How did u solve an issue with Frame processor face_enhancer not found ?

@luna-nightbyte
Copy link

luna-nightbyte commented Feb 17, 2025

Hi @Uniqbank How did u solve an issue with Frame processor face_enhancer not found ?

Try out this from the pinned #266 issue and see f that resolves your issue.

@Uniqbank
Copy link
Author

@kirillbush91 , sorry for delay. I also updated global constants and added list of frame processors in the list. Hope this helps, if not, let me know will send the code snippet.

@Alinus6
Copy link

Alinus6 commented Feb 20, 2025

@Uniqbank
please send the code

@x011
Copy link

x011 commented Feb 23, 2025

pip uninstall basicsr -y
install basicsr directly from its GitHub repository:
pip uninstall gfpgan -y
pip install git+https://github.com/TencentARC/GFPGAN.git@master

@Uniqbank
Copy link
Author

@Uniqbank please send the code

modules/globals.py

frame_processors: List[str] = ["face_swapper", "face_enhancer"]

modules/processors/frame
add init.py

from .face_enhancer import *
from .face_swapper import *

modules/processors/frame/core.py

import sys
import importlib
from concurrent.futures import ThreadPoolExecutor
from types import ModuleType
from typing import Any, List, Callable
from tqdm import tqdm

import modules
import modules.globals                   

FRAME_PROCESSORS_MODULES: List[ModuleType] = []
FRAME_PROCESSORS_INTERFACE = [
    'pre_check',
    'pre_start',
    'process_frame',
    'process_image',
    'process_video'
]


def load_frame_processor_module(frame_processor: str) -> Any:
    try:
        frame_processor_module = importlib.import_module(f'modules.processors.frame.{frame_processor}')
        for method_name in FRAME_PROCESSORS_INTERFACE:
            if not hasattr(frame_processor_module, method_name):
                sys.exit()
    except ImportError:
        print(f"Frame processor {frame_processor} not found")
        sys.exit()
    return frame_processor_module


def get_frame_processors_modules(frame_processors: List[str]) -> List[ModuleType]:
    global FRAME_PROCESSORS_MODULES

    if not FRAME_PROCESSORS_MODULES:
        for frame_processor in frame_processors:
            frame_processor_module = load_frame_processor_module(frame_processor)
            FRAME_PROCESSORS_MODULES.append(frame_processor_module)
    set_frame_processors_modules_from_ui(frame_processors)
    return FRAME_PROCESSORS_MODULES

def set_frame_processors_modules_from_ui(frame_processors: List[str]) -> None:
    global FRAME_PROCESSORS_MODULES
    for frame_processor, state in modules.globals.fp_ui.items():
        if state == True and frame_processor not in frame_processors:
            frame_processor_module = load_frame_processor_module(frame_processor)
            FRAME_PROCESSORS_MODULES.append(frame_processor_module)
            modules.globals.frame_processors.append(frame_processor)
        if state == False:
            try:
                frame_processor_module = load_frame_processor_module(frame_processor)
                FRAME_PROCESSORS_MODULES.remove(frame_processor_module)
                modules.globals.frame_processors.remove(frame_processor)
            except:
                pass

def multi_process_frame(source_path: str, temp_frame_paths: List[str], process_frames: Callable[[str, List[str], Any], None], progress: Any = None) -> None:
    with ThreadPoolExecutor(max_workers=modules.globals.execution_threads) as executor:
        futures = []
        for path in temp_frame_paths:
            future = executor.submit(process_frames, source_path, [path], progress)
            futures.append(future)
        for future in futures:
            future.result()


def process_video(source_path: str, frame_paths: list[str], process_frames: Callable[[str, List[str], Any], None]) -> None:
    progress_bar_format = '{l_bar}{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}{postfix}]'
    total = len(frame_paths)
    with tqdm(total=total, desc='Processing', unit='frame', dynamic_ncols=True, bar_format=progress_bar_format) as progress:
        progress.set_postfix({'execution_providers': modules.globals.execution_providers, 'execution_threads': modules.globals.execution_threads, 'max_memory': modules.globals.max_memory})
        multi_process_frame(source_path, frame_paths, process_frames, progress)

hope it helps.

@kniahnitskyi
Copy link

in my case, I needed torchvision==0.15.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants