Example #1
0
    def __init__(self,
                 csw_path: lib_csw.Paths.Client,
                 reflect_state_widgets=None):
        """
        Implements lib_csw.Paths control as LineEdit with Button to manage the Path
        """
        if not isinstance(csw_path, lib_csw.Paths.Client):
            raise ValueError('csw_path must be an instance of Paths.Client')

        self._csw_path = csw_path
        self._dlg = None

        csw_path.call_on_config(self.on_csw_config)
        csw_path.call_on_paths(self._on_csw_paths)

        lineedit = self._lineedit = qtx.QXLineEdit(
            font=QXFontDB.get_fixedwidth_font(),
            placeholder_text='...',
            size_policy=('expanding', 'fixed'),
            editingFinished=self.on_lineedit_editingFinished)

        btn_open = self._btn_open = qtx.QXPushButton(
            image=QXImageDB.folder_open_outline(color='light gray'),
            tooltip_text='Open',
            released=self._on_btn_open_released,
            fixed_size=(24, 22))

        btn_reveal = self._btn_reveal = qtx.QXPushButton(
            image=QXImageDB.eye_outline(color='light gray'),
            tooltip_text='Reveal in explorer',
            released=self._on_btn_reveal_released,
            fixed_size=(24, 22))

        btn_erase = self._btn_erase = qtx.QXPushButton(
            image=QXImageDB.close_outline(color='light gray'),
            tooltip_text='Erase',
            released=self._on_btn_erase_released,
            fixed_size=(24, 22))
        super().__init__(csw_control=csw_path,
                         reflect_state_widgets=reflect_state_widgets,
                         layout=qtx.QXHBoxLayout(
                             [lineedit, 2, btn_open, btn_reveal, btn_erase]))
Example #2
0
    def _on_backend_state_change(self, backend, started, starting, stopping, stopped, busy):
        btn_on_off = self._btn_on_off

        if started or starting or stopping:
            btn_on_off.setToolTip(L('@QBackendPanel.stop'))
        if stopped:
            btn_on_off.setToolTip(L('@QBackendPanel.start'))

        if busy or starting or stopping:
            btn_on_off.set_image_sequence(QXImageSequenceDB.icon_loading('yellow'), loop_count=0)
        elif started:
            btn_on_off.set_image( QXImageDB.power_outline('lime') )
        elif stopped:
            btn_on_off.set_image( QXImageDB.power_outline('red') )

        if started and not busy:
            qtx.show_and_enable([self._content_widget, self._fps_label])
            self._fps_label.setText(None)
        else:
            qtx.hide_and_disable([self._content_widget, self._fps_label])
            self._fps_label.setText(None)
Example #3
0
    def __init__(self, backend : BackendHost, name : str, layout, content_align_top=False):
        super().__init__()
        if not isinstance(backend, BackendHost):
            raise ValueError('backend must be an instance of BackendHost')

        self._backend = backend
        self._name = name

        backend.call_on_state_change(self._on_backend_state_change)
        backend.call_on_profile_timing(self._on_backend_profile_timing)

        btn_on_off = self._btn_on_off = qtx.QXPushButton(tooltip_text=L('@QBackendPanel.start'),
                                                         released=self._on_btn_on_off_released,
                                                         fixed_width=20)

        btn_reset_state = self._btn_reset_state = qtx.QXPushButton(image=QXImageDB.settings_reset_outline('gray'),
                                                                   released=self._on_btn_reset_state_released, tooltip_text=L('@QBackendPanel.reset_settings'),
                                                                   fixed_width=20)

        fps_label = self._fps_label = qtx.QXLabel()

        bar_widget = self._bar_widget = \
            qtx.QXFrameHBox(widgets=[btn_on_off, 1, btn_reset_state, 2,
                                     qtx.QXLabel(name, font=QXFontDB.get_default_font(10)),
                                     (fps_label, qtx.AlignRight), 2],
                            size_policy=('expanding', 'fixed'), fixed_height=24)

        content_widget = self._content_widget = qtx.QXFrameHBox([layout], contents_margins=2, enabled=False)

        l_widgets = [bar_widget, 1]

        if not content_align_top:
            l_widgets += [ qtx.QXFrame(size_policy=('expanding','expanding') ) ]

        l_widgets += [content_widget]
        l_widgets += [ qtx.QXFrame(size_policy=('expanding', 'expanding') ) ]

        self.setLayout(qtx.QXVBoxLayout(l_widgets))

        btn_on_off.set_image( QXImageDB.power_outline('red') )
Example #4
0
    def __init__(self, userdata_path):
        self.userdata_path = userdata_path
        settings_dirpath = self.settings_dirpath = userdata_path / 'settings'
        if not settings_dirpath.exists():
            settings_dirpath.mkdir(parents=True)
        super().__init__(app_name='DeepFaceLive',
                         settings_dirpath=settings_dirpath)

        self.setFont(QXFontDB.get_default_font())
        self.setWindowIcon(QXImageDB.app_icon().as_QIcon())

        splash_wnd = self.splash_wnd =\
            qtx.QXSplashWindow(layout=qtx.QXVBoxLayout([ (qtx.QXLabel(image=QXImageDB.splash_deepfacelive()), qtx.AlignCenter)
                                                       ], contents_margins=20))
        splash_wnd.show()
        splash_wnd.center_on_screen()

        self._dfl_wnd = None
        self._t = qtx.QXTimer(interval=1666,
                              timeout=self._on_splash_wnd_expired,
                              single_shot=True,
                              start=True)
        self.initialize()
Example #5
0
    def __init__(self,  csw_error : lib_csw.Error.Client):
        if not isinstance(csw_error, lib_csw.Error.Client):
            raise ValueError('csw_error must be an instance of Error.Client')

        self._csw_error = csw_error
        csw_error.call_on_error(self._on_csw_error)

        self._label_warning = qtx.QXLabel(image=QXImageDB.warning_outline('red'),
                                          scaled_contents=True,
                                          size_policy=('fixed', 'fixed'),
                                          fixed_size=(32,32) )

        self._label = qtx.QXTextEdit( font=QXFontDB.get_default_font(size=7), read_only=True, fixed_height=80)

        super().__init__(csw_control=csw_error,
                         layout=qtx.QXHBoxLayout([self._label_warning, self._label]) )
Example #6
0
    def __init__(self, label: str = None, popup_info_text=None):
        """
        text label with optional popup info on click
        """
        super().__init__()

        self._has_info_text = False

        self._label = qtx.QXLabel(text='', hided=True)

        wnd_text_label = self._popup_wnd_text_label = qtx.QXLabel(
            text='', font=QXFontDB.get_default_font())

        wnd = self._popup_wnd = qtx.QXPopupWindow(
            layout=qtx.QXHBoxLayout([
                qtx
                .QXFrame(bg_color=qtx.Qt.GlobalColor.black,
                         layout=qtx.QXHBoxLayout([
                             qtx.QXFrame(
                                 layout=qtx.QXHBoxLayout([
                                     qtx.QXLabel(image=QXImageDB
                                                 .information_circle_outline(
                                                     'yellow'),
                                                 scaled_contents=True,
                                                 fixed_size=(24, 24
                                                             )), wnd_text_label
                                 ],
                                                         contents_margins=2,
                                                         spacing=2)),
                         ],
                                                 contents_margins=2,
                                                 spacing=2),
                         size_policy=('fixed', 'fixed'))
            ],
                                    contents_margins=0))

        info_btn = self._info_btn = qtx.QXPushButton(
            image=QXImageDB.information_circle_outline('light gray'),
            released=self._on_info_btn_released,
            fixed_size=(24, 22),
            hided=True)

        self.setLayout(qtx.QXHBoxLayout([self._label, info_btn]))

        self.set_label(label)
        self.set_popup_info(popup_info_text)
Example #7
0
    def __init__(self, backend: FaceSwapper, dfm_models_path: Path):
        self._dfm_models_path = dfm_models_path

        cs = backend.get_control_sheet()

        btn_open_folder = self.btn_open_folder = qtx.QXPushButton(
            image=QXImageDB.eye_outline('light gray'),
            tooltip_text='Reveal in Explorer',
            released=self._btn_open_folder_released,
            fixed_size=(24, 22))

        q_device_label = QLabelPopupInfo(
            label=L('@common.device'),
            popup_info_text=L('@common.help.device'))
        q_device = QComboBoxCSWDynamicSingleSwitch(
            cs.device, reflect_state_widgets=[q_device_label])

        q_model_label = QLabelPopupInfo(
            label=L('@QFaceSwapper.model'),
            popup_info_text=L('@QFaceSwapper.help.model'))
        q_model = QComboBoxCSWDynamicSingleSwitch(
            cs.model, reflect_state_widgets=[q_model_label, btn_open_folder])

        q_model_dl_error = self._q_model_dl_error = QErrorCSWError(
            cs.model_dl_error)
        q_model_dl_progress = self._q_model_dl_progress = QProgressBarCSWProgress(
            cs.model_dl_progress)

        q_model_info_label = self._q_model_info_label = QLabelPopupInfoCSWInfoLabel(
            cs.model_info_label)

        q_swap_all_faces_label = QLabelPopupInfo(
            label=L('@QFaceSwapper.swap_all_faces'))
        q_swap_all_faces = QCheckBoxCSWFlag(
            cs.swap_all_faces, reflect_state_widgets=[q_swap_all_faces_label])

        q_face_id_label = QLabelPopupInfo(
            label=L('@QFaceSwapper.face_id'),
            popup_info_text=L('@QFaceSwapper.help.face_id'))
        q_face_id = QSpinBoxCSWNumber(cs.face_id,
                                      reflect_state_widgets=[q_face_id_label])

        q_morph_factor_label = QLabelPopupInfo(
            label=L('@QFaceSwapper.morph_factor'),
            popup_info_text=L('@QFaceSwapper.help.morph_factor'))
        q_morph_factor = QSliderCSWNumber(
            cs.morph_factor, reflect_state_widgets=[q_morph_factor_label])

        q_sharpen_amount_label = QLabelPopupInfo(
            label=L('@QFaceSwapper.presharpen_amount'),
            popup_info_text=L('@QFaceSwapper.help.presharpen_amount'))
        q_sharpen_amount = QSliderCSWNumber(
            cs.presharpen_amount,
            reflect_state_widgets=[q_sharpen_amount_label])

        q_pre_gamma_label = QLabelPopupInfo(
            label=L('@QFaceSwapper.pregamma'),
            popup_info_text=L('@QFaceSwapper.help.pregamma'))

        q_pre_gamma_red = QSpinBoxCSWNumber(
            cs.pre_gamma_red, reflect_state_widgets=[q_pre_gamma_label])
        q_pre_gamma_green = QSpinBoxCSWNumber(cs.pre_gamma_green)
        q_pre_gamma_blue = QSpinBoxCSWNumber(cs.pre_gamma_blue)

        q_post_gamma_label = QLabelPopupInfo(
            label=L('@QFaceSwapper.postgamma'))

        q_post_gamma_red = QSpinBoxCSWNumber(
            cs.post_gamma_red, reflect_state_widgets=[q_post_gamma_label])
        q_post_gamma_green = QSpinBoxCSWNumber(cs.post_gamma_green)
        q_post_gamma_blue = QSpinBoxCSWNumber(cs.post_gamma_blue)

        q_two_pass_label = QLabelPopupInfo(
            label=L('@QFaceSwapper.two_pass'),
            popup_info_text=L('@QFaceSwapper.help.two_pass'))
        q_two_pass = QCheckBoxCSWFlag(cs.two_pass,
                                      reflect_state_widgets=[q_two_pass_label])

        grid_l = qtx.QXGridLayout(spacing=5)
        row = 0
        grid_l.addWidget(q_device_label,
                         row,
                         0,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_device, row, 1, alignment=qtx.AlignLeft)
        row += 1
        grid_l.addWidget(q_model_label,
                         row,
                         0,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addLayout(
            qtx.QXHBoxLayout(
                [q_model, 2, btn_open_folder, 2, q_model_info_label]), row, 1)
        row += 1
        grid_l.addWidget(q_model_dl_progress, row, 0, 1, 2)
        row += 1
        grid_l.addWidget(q_model_dl_error, row, 0, 1, 2)
        row += 1
        grid_l.addWidget(q_swap_all_faces_label,
                         row,
                         0,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addLayout(qtx.QXHBoxLayout(
            [q_swap_all_faces, 4, q_face_id_label, 4, q_face_id]),
                         row,
                         1,
                         alignment=qtx.AlignLeft)
        row += 1
        grid_l.addWidget(q_morph_factor_label,
                         row,
                         0,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_morph_factor, row, 1)
        row += 1
        grid_l.addWidget(q_sharpen_amount_label,
                         row,
                         0,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_sharpen_amount, row, 1)
        row += 1
        grid_l.addWidget(q_pre_gamma_label,
                         row,
                         0,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addLayout(
            qtx.QXHBoxLayout(
                [q_pre_gamma_red, q_pre_gamma_green, q_pre_gamma_blue]), row,
            1)
        row += 1
        grid_l.addWidget(q_post_gamma_label,
                         row,
                         0,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addLayout(
            qtx.QXHBoxLayout(
                [q_post_gamma_red, q_post_gamma_green, q_post_gamma_blue]),
            row, 1)
        row += 1
        grid_l.addWidget(q_two_pass_label,
                         row,
                         0,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_two_pass, row, 1)
        row += 1

        super().__init__(backend,
                         L('@QFaceSwapper.module_title'),
                         layout=qtx.QXVBoxLayout([grid_l]))
Example #8
0
    def __init__(self, backend: FaceAnimator, animatables_path: Path):
        self._animatables_path = animatables_path

        cs = backend.get_control_sheet()

        btn_open_folder = self.btn_open_folder = qtx.QXPushButton(
            image=QXImageDB.eye_outline('light gray'),
            tooltip_text='Reveal in Explorer',
            released=self._btn_open_folder_released,
            fixed_size=(24, 22))

        q_device_label = QLabelPopupInfo(
            label=L('@common.device'),
            popup_info_text=L('@common.help.device'))
        q_device = QComboBoxCSWDynamicSingleSwitch(
            cs.device, reflect_state_widgets=[q_device_label])

        q_animatable_label = QLabelPopupInfo(
            label=L('@QFaceAnimator.animatable'))
        q_animatable = QComboBoxCSWDynamicSingleSwitch(
            cs.animatable,
            reflect_state_widgets=[q_animatable_label, btn_open_folder])

        q_animator_face_id_label = QLabelPopupInfo(
            label=L('@QFaceAnimator.animator_face_id'))
        q_animator_face_id = QSpinBoxCSWNumber(
            cs.animator_face_id,
            reflect_state_widgets=[q_animator_face_id_label])

        q_relative_mode_label = QLabelPopupInfo(
            label=L('@QFaceAnimator.relative_mode'))
        q_relative_mode = QCheckBoxCSWFlag(
            cs.relative_mode, reflect_state_widgets=[q_relative_mode_label])

        q_relative_power = QSliderCSWNumber(cs.relative_power)

        q_update_animatables = QXPushButtonCSWSignal(
            cs.update_animatables,
            image=QXImageDB.reload_outline('light gray'),
            button_size=(24, 22))

        q_reset_reference_pose = QXPushButtonCSWSignal(
            cs.reset_reference_pose,
            text=L('@QFaceAnimator.reset_reference_pose'))

        grid_l = qtx.QXGridLayout(spacing=5)
        row = 0
        grid_l.addWidget(q_device_label,
                         row,
                         0,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_device, row, 1, alignment=qtx.AlignLeft)
        row += 1
        grid_l.addWidget(q_animatable_label,
                         row,
                         0,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addLayout(
            qtx.QXHBoxLayout(
                [q_animatable, 2, btn_open_folder, 2, q_update_animatables]),
            row, 1)
        row += 1
        grid_l.addWidget(q_animator_face_id_label,
                         row,
                         0,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_animator_face_id, row, 1, alignment=qtx.AlignLeft)
        row += 1
        grid_l.addWidget(q_relative_mode_label,
                         row,
                         0,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addLayout(qtx.QXHBoxLayout(
            [q_relative_mode, 2, q_relative_power]),
                         row,
                         1,
                         alignment=qtx.AlignLeft)

        row += 1
        grid_l.addWidget(q_reset_reference_pose, row, 0, 1, 2)
        row += 1

        super().__init__(backend,
                         L('@QFaceAnimator.module_title'),
                         layout=qtx.QXVBoxLayout([grid_l]))
Example #9
0
    def __init__(self, backend: FileSource):
        cs = backend.get_control_sheet()

        q_input_type = QButtonCSWDynamicSingleSwitch(cs.input_type,
                                                     horizontal=True,
                                                     radio_buttons=True)
        q_input_paths = QPathEditCSWPaths(cs.input_paths)
        q_error = QErrorCSWError(cs.error)

        q_target_width_label = QLabelPopupInfo(
            label=L('@QFileSource.target_width'),
            popup_info_text=L('@QFileSource.help.target_width'))
        q_target_width = QSpinBoxCSWNumber(
            cs.target_width, reflect_state_widgets=[q_target_width_label])

        q_fps_label = QLabelPopupInfo(
            label=L('@QFileSource.fps'),
            popup_info_text=L('@QFileSource.help.fps'))
        q_fps = QSpinBoxCSWNumber(cs.fps, reflect_state_widgets=[q_fps_label])

        q_is_realtime_label = QLabelPopupInfo(
            label=L('@QFileSource.is_realtime'),
            popup_info_text=L('@QFileSource.help.is_realtime'))
        q_is_realtime = QCheckBoxCSWFlag(
            cs.is_realtime, reflect_state_widgets=[q_is_realtime_label])

        q_is_autorewind_label = QLabelPopupInfo(
            label=L('@QFileSource.is_autorewind'))
        q_is_autorewind = QCheckBoxCSWFlag(
            cs.is_autorewind, reflect_state_widgets=[q_is_autorewind_label])

        btn_size = (32, 32)
        btn_color = '#E01010'
        btn_seek_begin = QXPushButtonCSWSignal(
            cs.seek_begin,
            image=QXImageDB.play_skip_back_circle_outline(btn_color),
            button_size=btn_size)
        btn_seek_backward = QXPushButtonCSWSignal(
            cs.seek_backward,
            image=QXImageDB.play_back_circle_outline(btn_color),
            button_size=btn_size)
        btn_play = QXPushButtonCSWSignal(
            cs.play,
            image=QXImageDB.play_circle_outline(btn_color),
            button_size=btn_size)
        btn_pause = QXPushButtonCSWSignal(
            cs.pause,
            image=QXImageDB.pause_circle_outline(btn_color),
            button_size=btn_size)
        btn_seek_forward = QXPushButtonCSWSignal(
            cs.seek_forward,
            image=QXImageDB.play_forward_circle_outline(btn_color),
            button_size=btn_size)
        btn_seek_end = QXPushButtonCSWSignal(
            cs.seek_end,
            image=QXImageDB.play_skip_forward_circle_outline(btn_color),
            button_size=btn_size)

        q_frame_slider = QSliderCSWNumbers(cs.frame_index, cs.frame_count)

        grid_l = qtx.QXGridLayout(spacing=5)
        row = 0
        grid_l.addWidget(q_target_width_label,
                         row,
                         0,
                         1,
                         2,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_target_width, row, 2, 1, 2, alignment=qtx.AlignLeft)
        row += 1
        grid_l.addLayout(qtx.QXHBoxLayout(
            [q_is_realtime_label, 5, q_is_realtime, 5, q_fps_label]),
                         row,
                         0,
                         1,
                         2,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_fps, row, 2, 1, 2, alignment=qtx.AlignLeft)
        row += 1
        grid_l.addWidget(q_is_autorewind_label,
                         row,
                         0,
                         1,
                         2,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_is_autorewind,
                         row,
                         2,
                         1,
                         2,
                         alignment=qtx.AlignLeft)
        row += 1
        grid_l.addWidget(qtx.QXFrameHBox([
            btn_seek_begin, btn_seek_backward, btn_play, btn_pause,
            btn_seek_forward, btn_seek_end
        ],
                                         spacing=1),
                         row,
                         0,
                         1,
                         4,
                         alignment=qtx.AlignCenter)
        row += 1
        grid_l.addWidget(q_frame_slider, row, 0, 1, 4)
        row += 1

        main_l = qtx.QXVBoxLayout(
            [q_input_type, q_input_paths, q_error, grid_l], spacing=5)

        super().__init__(backend,
                         L('@QFileSource.module_title'),
                         layout=main_l,
                         content_align_top=True)