Spaces:
Runtime error
Runtime error
Download DeepFakeAI/uis/components/processors.py from DAVIGABRIELA/video-face-swap: direct link, hf CLI and curl.
- Browser
- Download file 1.77 kB
-
https://huggingface.co/spaces/DAVIGABRIELA/video-face-swap/resolve/5cf6da6c994b090b227c20e9f348cb80c0c7e9f7/DeepFakeAI/uis/components/processors.py
- Command line
-
hf download hf://spaces/DAVIGABRIELA/video-face-swap@5cf6da6c994b090b227c20e9f348cb80c0c7e9f7/DeepFakeAI/uis/components/processors.py
-
curl -L -o processors.py https://huggingface.co/spaces/DAVIGABRIELA/video-face-swap/resolve/5cf6da6c994b090b227c20e9f348cb80c0c7e9f7/DeepFakeAI/uis/components/processors.py
1.77 kB
| from typing import List, Optional | |
| import gradio | |
| import DeepFakeAI.globals | |
| from DeepFakeAI import wording | |
| from DeepFakeAI.processors.frame.core import load_frame_processor_module, clear_frame_processors_modules | |
| from DeepFakeAI.uis import core as ui | |
| from DeepFakeAI.uis.typing import Update | |
| from DeepFakeAI.utilities import list_module_names | |
| FRAME_PROCESSORS_CHECKBOX_GROUP : Optional[gradio.CheckboxGroup] = None | |
| def render() -> None: | |
| global FRAME_PROCESSORS_CHECKBOX_GROUP | |
| with gradio.Box(): | |
| FRAME_PROCESSORS_CHECKBOX_GROUP = gradio.CheckboxGroup( | |
| label = wording.get('frame_processors_checkbox_group_label'), | |
| choices = sort_frame_processors(DeepFakeAI.globals.frame_processors), | |
| value = DeepFakeAI.globals.frame_processors | |
| ) | |
| ui.register_component('frame_processors_checkbox_group', FRAME_PROCESSORS_CHECKBOX_GROUP) | |
| def listen() -> None: | |
| FRAME_PROCESSORS_CHECKBOX_GROUP.change(update_frame_processors, inputs = FRAME_PROCESSORS_CHECKBOX_GROUP, outputs = FRAME_PROCESSORS_CHECKBOX_GROUP) | |
| def update_frame_processors(frame_processors : List[str]) -> Update: | |
| clear_frame_processors_modules() | |
| DeepFakeAI.globals.frame_processors = frame_processors | |
| for frame_processor in DeepFakeAI.globals.frame_processors: | |
| frame_processor_module = load_frame_processor_module(frame_processor) | |
| frame_processor_module.pre_check() | |
| return gradio.update(value = frame_processors, choices = sort_frame_processors(frame_processors)) | |
| def sort_frame_processors(frame_processors : List[str]) -> list[str]: | |
| frame_processors_names = list_module_names('DeepFakeAI/processors/frame/modules') | |
| return sorted(frame_processors_names, key = lambda frame_processor : frame_processors.index(frame_processor) if frame_processor in frame_processors else len(frame_processors)) | |