* Cosmetic changes * Cosmetic changes * Run single warm up for the benchmark suite * Use latest version of Gradio * More testing * Introduce basic installer * Fix typo * Move more to installer file * Fix the installer with the uninstall all trick * Adjust wording * Fix coreml in installer * Allow Pyhton 3.9 * Add VENV to installer * Just some cosmetics * Just some cosmetics * Dedicated headless mode, Refine API of UI layouts * Use --headless for pytest * Fix testing for Windows * Normalize output path that lacks extension * Fix CI for Windows * Fix CI for Windows * UI to change output path * Add conda support for the installer * Improve installer quite a bit * Drop conda support * Install community wheels for coreml silicon * Improve output video component * Fix silicon wheel downloading * Remove venv from installer as we cannot activate via subprocess * Use join to create wheel name * Refine the output path normalization * Refine the output path normalization * Introduce ProcessMode and rename some methods * Introduce ProcessMode and rename some methods * Basic webcam integration and open_ffmpeg() * Basic webcam integration part2 * Benchmark resolutions now selectable * Rename benchmark resolution back to benchmark runs * Fix repeating output path in UI * Keep output_path untouched if not resolvable * Add more cases to normalize output path * None for those tests that don't take source path into account * Finish basic webcam integration, UI layout now with custom run() * Fix CI and hide link in webcam UI * Cosmetics on webcam UI * Move get_device to utilities * Fix CI * Introduce output-image-quality, Show and hide UI according to target media type * Benchmark with partial result updates * fix: trim frame sliders not appearing after draggin video * fix: output and temp frame setting inputs not appearing * Fix: set increased update delay to 250ms to let Gradio update conditional inputs properly * Reverted .gitignore * Adjust timings * Remove timeout hacks and get fully event driven * Update dependencies * Update dependencies * Revert NSFW library, Conditional unset trim args * Face selector works better on preview slider release * Add limit resources to UI * Introduce vision.py for all CV2 operations, Rename some methods * Add restoring audio failed * Decouple updates for preview image and preview frame slider, Move reduce_preview_frame to vision * Refactor detect_fps based on JSON output * Only webcam when open * More conditions to vision.py * Add udp and v4l2 streaming to webcam UI * Detect v4l2 device to be used * Refactor code a bit * Use static max memory for UI * Fix CI * Looks stable to me * Update preview * Update preview --------- Co-authored-by: Sumit <vizsumit@gmail.com>
70 lines
2.5 KiB
Python
70 lines
2.5 KiB
Python
import tempfile
|
|
from typing import Tuple, Optional
|
|
import gradio
|
|
|
|
import facefusion.globals
|
|
from facefusion import wording
|
|
from facefusion.core import limit_resources, conditional_process
|
|
from facefusion.uis.typing import Update
|
|
from facefusion.utilities import is_image, is_video, normalize_output_path, clear_temp
|
|
|
|
OUTPUT_IMAGE : Optional[gradio.Image] = None
|
|
OUTPUT_VIDEO : Optional[gradio.Video] = None
|
|
OUTPUT_PATH_TEXTBOX : Optional[gradio.Textbox] = None
|
|
OUTPUT_START_BUTTON : Optional[gradio.Button] = None
|
|
OUTPUT_CLEAR_BUTTON : Optional[gradio.Button] = None
|
|
|
|
|
|
def render() -> None:
|
|
global OUTPUT_IMAGE
|
|
global OUTPUT_VIDEO
|
|
global OUTPUT_PATH_TEXTBOX
|
|
global OUTPUT_START_BUTTON
|
|
global OUTPUT_CLEAR_BUTTON
|
|
|
|
with gradio.Row():
|
|
with gradio.Box():
|
|
OUTPUT_IMAGE = gradio.Image(
|
|
label = wording.get('output_image_or_video_label'),
|
|
visible = False
|
|
)
|
|
OUTPUT_VIDEO = gradio.Video(
|
|
label = wording.get('output_image_or_video_label')
|
|
)
|
|
OUTPUT_PATH_TEXTBOX = gradio.Textbox(
|
|
label = wording.get('output_path_textbox_label'),
|
|
value = facefusion.globals.output_path or tempfile.gettempdir(),
|
|
max_lines = 1
|
|
)
|
|
with gradio.Row():
|
|
OUTPUT_START_BUTTON = gradio.Button(wording.get('start_button_label'))
|
|
OUTPUT_CLEAR_BUTTON = gradio.Button(wording.get('clear_button_label'))
|
|
|
|
|
|
def listen() -> None:
|
|
OUTPUT_PATH_TEXTBOX.change(update_output_path, inputs = OUTPUT_PATH_TEXTBOX, outputs = OUTPUT_PATH_TEXTBOX)
|
|
OUTPUT_START_BUTTON.click(start, inputs = OUTPUT_PATH_TEXTBOX, outputs = [ OUTPUT_IMAGE, OUTPUT_VIDEO ])
|
|
OUTPUT_CLEAR_BUTTON.click(clear, outputs = [ OUTPUT_IMAGE, OUTPUT_VIDEO ])
|
|
|
|
|
|
def start(output_path : str) -> Tuple[Update, Update]:
|
|
facefusion.globals.output_path = normalize_output_path(facefusion.globals.source_path, facefusion.globals.target_path, output_path)
|
|
limit_resources()
|
|
conditional_process()
|
|
if is_image(facefusion.globals.output_path):
|
|
return gradio.update(value = facefusion.globals.output_path, visible = True), gradio.update(value = None, visible = False)
|
|
if is_video(facefusion.globals.output_path):
|
|
return gradio.update(value = None, visible = False), gradio.update(value = facefusion.globals.output_path, visible = True)
|
|
return gradio.update(), gradio.update()
|
|
|
|
|
|
def update_output_path(output_path : str) -> Update:
|
|
facefusion.globals.output_path = output_path
|
|
return gradio.update(value = output_path)
|
|
|
|
|
|
def clear() -> Tuple[Update, Update]:
|
|
if facefusion.globals.target_path:
|
|
clear_temp(facefusion.globals.target_path)
|
|
return gradio.update(value = None), gradio.update(value = None)
|