Skip to content

Commit

Permalink
Add temp frame component to UI
Browse files Browse the repository at this point in the history
  • Loading branch information
henryruhs committed Aug 15, 2023
1 parent 9bfeb95 commit 638d95e
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 15 deletions.
2 changes: 1 addition & 1 deletion roop/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
FaceAnalyserGender = Literal['male', 'female']
TempFrameFormat = Literal['jpg', 'png']
OutputVideoEncoder = Literal['libx264', 'libx265', 'libvpx-vp9', 'h264_nvenc', 'hevc_nvenc']
LogLevel = Literal['error']
LogLevel = Literal['error']
17 changes: 9 additions & 8 deletions roop/uis/__components__/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ def render() -> None:
with gradio.Row():
START_BUTTON = gradio.Button('Start')
CLEAR_BUTTON = gradio.Button('Clear')
OUTPUT_IMAGE = gradio.Image(
label='OUTPUT',
visible=False
)
OUTPUT_VIDEO = gradio.Video(
label='OUTPUT',
visible=False
)
with gradio.Row():
with gradio.Box():
OUTPUT_IMAGE = gradio.Image(
label='OUTPUT'
)
OUTPUT_VIDEO = gradio.Video(
label='OUTPUT',
visible=False
)


def listen() -> None:
Expand Down
File renamed without changes.
43 changes: 43 additions & 0 deletions roop/uis/__components__/temp_frame.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from typing import List, Optional
import gradio

import roop.globals
from roop.processors.frame.core import list_frame_processors_names, load_frame_processor_module, clear_frame_processors_modules
from roop.typing import TempFrameFormat
from roop.uis import core as ui
from roop.uis.typing import Update

TEMP_FRAME_FORMAT_DROPDOWN: Optional[gradio.Dropdown] = None
TEMP_FRAME_QUALITY_SLIDER: Optional[gradio.Slider] = None


def render() -> None:
global TEMP_FRAME_FORMAT_DROPDOWN
global TEMP_FRAME_QUALITY_SLIDER

with gradio.Box():
TEMP_FRAME_FORMAT_DROPDOWN = gradio.Dropdown(
label='TEMP FRAME FORMAT',
choices=['jpg', 'png'],
value=roop.globals.temp_frame_format
)
TEMP_FRAME_QUALITY_SLIDER = gradio.Slider(
label='TEMP FRAME QUALITY',
value=roop.globals.temp_frame_quality,
step=1
)


def listen() -> None:
TEMP_FRAME_FORMAT_DROPDOWN.select(update_temp_frame_format, inputs=TEMP_FRAME_FORMAT_DROPDOWN, outputs=TEMP_FRAME_FORMAT_DROPDOWN)
TEMP_FRAME_QUALITY_SLIDER.change(update_temp_frame_quality, inputs=TEMP_FRAME_QUALITY_SLIDER, outputs=TEMP_FRAME_QUALITY_SLIDER)


def update_temp_frame_format(temp_frame_format: TempFrameFormat) -> Update:
roop.globals.temp_frame_format = temp_frame_format
return gradio.update(value=temp_frame_format)


def update_temp_frame_quality(temp_frame_quality: int) -> Update:
roop.globals.temp_frame_quality = temp_frame_quality
return gradio.update(value=temp_frame_quality)
11 changes: 6 additions & 5 deletions roop/uis/__layouts__/default.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
import gradio

from roop.uis.__components__ import processors, execution, settings, source, target, preview, trim_frame, face_analyser, face_selector, output
from roop.uis.__components__ import processor, execution, temp_frame, settings, source, target, preview, trim_frame, face_analyser, face_selector, output


def render() -> gradio.Blocks:
with gradio.Blocks() as layout:
with gradio.Row():
with gradio.Column(scale=2):
processors.render()
processor.render()
execution.render()
temp_frame.render()
settings.render()
with gradio.Column(scale=1):
source.render()
target.render()
output.render()
with gradio.Column(scale=3):
preview.render()
trim_frame.render()
face_selector.render()
face_analyser.render()
with gradio.Row():
output.render()
return layout


def listen() -> None:
processors.listen()
processor.listen()
execution.listen()
settings.listen()
temp_frame.listen()
source.listen()
target.listen()
preview.listen()
Expand Down
2 changes: 1 addition & 1 deletion roop/uis/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


def init() -> None:
with gradio.Blocks(theme=get_theme(), title=roop.metadata.name) as ui:
with gradio.Blocks(theme=get_theme(), title=roop.metadata.name + ' ' + roop.metadata.version) as ui:
for ui_layout in roop.globals.ui_layouts:
ui_layout_module = load_ui_layout_module(ui_layout)
ui_layout_module.render()
Expand Down

0 comments on commit 638d95e

Please sign in to comment.