Exemplo n.º 1
0
    def __init__(self,
                 csw_text: lib_csw.Text.Client,
                 font=None,
                 reflect_state_widgets=None):
        """
        Implements lib_csw.Text control as LineEdit
        """
        if not isinstance(csw_text, lib_csw.Text.Client):
            raise ValueError('csw_path must be an instance of Text.Client')

        self._csw_text = csw_text
        self._dlg = None

        csw_text.call_on_text(self._on_csw_text)

        if font is None:
            font = QXFontDB.get_default_font()
        lineedit = self._lineedit = qtx.QXLineEdit(
            font=font,
            placeholder_text='...',
            size_policy=('expanding', 'fixed'),
            editingFinished=self.on_lineedit_editingFinished)

        super().__init__(csw_control=csw_text,
                         reflect_state_widgets=reflect_state_widgets,
                         layout=qtx.QXHBoxLayout([lineedit]))
Exemplo n.º 2
0
    def __init__(self,
                 csw_number: lib_csw.Number.Client,
                 reflect_state_widgets=None):
        """
        Implements lib_csw.Number control as SpinBox
        """
        if not isinstance(csw_number, lib_csw.Number.Client):
            raise ValueError('csw_number must be an instance of Number.Client')

        self._csw_number = csw_number
        self._instant_update = False
        self._zero_is_auto = False
        self._read_only = True

        csw_number.call_on_number(self._on_csw_number)
        csw_number.call_on_config(self._on_csw_config)

        spinbox = self._spinbox = qtx.QXDoubleSpinBox(
            font=QXFontDB.Digital7_Mono(11, italic=True),
            min=0,
            max=999999999,
            step=1,
            decimals=0,
            readonly=self._read_only,
            valueChanged=self._on_spinbox_valueChanged,
            editingFinished=self._on_spinbox_editingFinished)
        btn_auto = self._btn_auto = qtx.QXPushButton(
            text=L('@misc.auto'),
            released=self._on_btn_auto_released,
            fixed_height=21,
            hided=True)

        super().__init__(csw_control=csw_number,
                         reflect_state_widgets=reflect_state_widgets,
                         layout=qtx.QXHBoxLayout([spinbox, 1, btn_auto]))
Exemplo n.º 3
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)
Exemplo n.º 4
0
    def __init__(self, backend : FaceAligner):
        cs = backend.get_control_sheet()

        q_align_mode_label = QLabelPopupInfo(label=L('@QFaceAligner.align_mode'), popup_info_text=L('@QFaceAligner.help.align_mode'))
        q_align_mode = QComboBoxCSWDynamicSingleSwitch(cs.align_mode, reflect_state_widgets=[q_align_mode_label])

        q_face_coverage_label = QLabelPopupInfo(label=L('@QFaceAligner.face_coverage'), popup_info_text=L('@QFaceAligner.help.face_coverage') )
        q_face_coverage       = QSpinBoxCSWNumber(cs.face_coverage, reflect_state_widgets=[q_face_coverage_label])

        q_resolution_label = QLabelPopupInfo(label=L('@QFaceAligner.resolution'), popup_info_text=L('@QFaceAligner.help.resolution') )
        q_resolution       = QSpinBoxCSWNumber(cs.resolution, reflect_state_widgets=[q_resolution_label])

        q_exclude_moving_parts_label = QLabelPopupInfo(label=L('@QFaceAligner.exclude_moving_parts'), popup_info_text=L('@QFaceAligner.help.exclude_moving_parts') )
        q_exclude_moving_parts = QCheckBoxCSWFlag(cs.exclude_moving_parts, reflect_state_widgets=[q_exclude_moving_parts_label])

        q_head_mode_label = QLabelPopupInfo(label=L('@QFaceAligner.head_mode'), popup_info_text=L('@QFaceAligner.help.head_mode') )
        q_head_mode = QCheckBoxCSWFlag(cs.head_mode, reflect_state_widgets=[q_head_mode_label])

        q_freeze_z_rotation_label = QLabelPopupInfo(label=L('@QFaceAligner.freeze_z_rotation') )
        q_freeze_z_rotation = QCheckBoxCSWFlag(cs.freeze_z_rotation, reflect_state_widgets=[q_freeze_z_rotation_label])

        q_x_offset_label = QLabelPopupInfo(label=L('@QFaceAligner.x_offset'))
        q_x_offset       = QSpinBoxCSWNumber(cs.x_offset, reflect_state_widgets=[q_x_offset_label])

        q_y_offset_label = QLabelPopupInfo(label=L('@QFaceAligner.y_offset'))
        q_y_offset       = QSpinBoxCSWNumber(cs.y_offset, reflect_state_widgets=[q_y_offset_label])

        grid_l = qtx.QXGridLayout(spacing=5)
        row = 0
        grid_l.addWidget(q_align_mode_label, row, 0, alignment=qtx.AlignRight | qtx.AlignVCenter  )
        grid_l.addWidget(q_align_mode, row, 1, alignment=qtx.AlignLeft )
        row += 1
        grid_l.addWidget(q_face_coverage_label, row, 0, alignment=qtx.AlignRight | qtx.AlignVCenter  )
        grid_l.addWidget(q_face_coverage, row, 1, alignment=qtx.AlignLeft )
        row += 1
        grid_l.addWidget(q_resolution_label, row, 0, alignment=qtx.AlignRight | qtx.AlignVCenter  )
        grid_l.addWidget(q_resolution, row, 1, alignment=qtx.AlignLeft )
        row += 1
        grid_l.addWidget(q_exclude_moving_parts_label, row, 0, alignment=qtx.AlignRight | qtx.AlignVCenter  )
        grid_l.addWidget(q_exclude_moving_parts, row, 1, alignment=qtx.AlignLeft )
        row += 1
        grid_l.addWidget(q_head_mode_label, row, 0, alignment=qtx.AlignRight | qtx.AlignVCenter  )
        grid_l.addWidget(q_head_mode, row, 1, alignment=qtx.AlignLeft )
        row += 1
        grid_l.addWidget(q_freeze_z_rotation_label, row, 0, alignment=qtx.AlignRight | qtx.AlignVCenter  )
        grid_l.addWidget(q_freeze_z_rotation, row, 1, alignment=qtx.AlignLeft )
        row += 1
        grid_l.addLayout( qtx.QXVBoxLayout([q_x_offset_label, q_y_offset_label]), row, 0, alignment=qtx.AlignRight | qtx.AlignVCenter  )
        grid_l.addLayout( qtx.QXHBoxLayout([q_x_offset, q_y_offset]), row, 1, alignment=qtx.AlignLeft )
        row += 1

        super().__init__(backend, L('@QFaceAligner.module_title'),
                         layout=qtx.QXVBoxLayout([grid_l]))
Exemplo n.º 5
0
    def __init__(self,
                 csw_flag: lib_csw.Flag.Client,
                 reflect_state_widgets=None):
        if not isinstance(csw_flag, lib_csw.Flag.Client):
            raise ValueError('csw_flag must be an instance of Flag.Client')

        self._csw_flag = csw_flag
        csw_flag.call_on_flag(self.on_csw_flag)

        chbox = self._chbox = qtx.QXCheckBox(clicked=self.on_chbox_clicked)

        super().__init__(csw_control=csw_flag,
                         reflect_state_widgets=reflect_state_widgets,
                         layout=qtx.QXHBoxLayout([chbox]))
Exemplo n.º 6
0
    def __init__(self,  csw_signal : lib_csw.Signal.Client, reflect_state_widgets=None,
                        image=None,
                        text=None, button_size=None, **kwargs):
        """
        Implements lib_csw.Signal control as QXPushButton
        """
        if not isinstance(csw_signal, lib_csw.Signal.Client):
            raise ValueError('csw_signal must be an instance of Signal.Client')

        self._csw_signal = csw_signal

        btn = self._btn = qtx.QXPushButton(image=image, text=text, released=self.on_btn_released, fixed_size=button_size)

        super().__init__(csw_control=csw_signal, reflect_state_widgets=reflect_state_widgets,
                         layout=qtx.QXHBoxLayout([btn]), **kwargs)
Exemplo n.º 7
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]) )
Exemplo n.º 8
0
    def __init__(self,
                 csw_switch: lib_csw.DynamicSingleSwitch.Client,
                 reflect_state_widgets=None):
        if not isinstance(csw_switch, lib_csw.DynamicSingleSwitch.Client):
            raise ValueError(
                'csw_switch must be an instance of DynamicSingleSwitch.Client')
        self._csw_switch = csw_switch
        self._has_none_choice = True

        csw_switch.call_on_selected(self._on_csw_switch_selected)
        csw_switch.call_on_choices(self._on_csw_choices)

        self._combobox = None
        self._main_l = qtx.QXHBoxLayout()
        super().__init__(csw_control=csw_switch,
                         reflect_state_widgets=reflect_state_widgets,
                         layout=self._main_l)
    def __init__(self, csw_switch: lib_csw.DynamicSingleSwitch.Client,
                 horizontal: bool, radio_buttons: bool):
        """
        Implements lib_csw.DynamicSingleSwitch control with radiobuttons or checkboxes
        """
        if not isinstance(csw_switch, lib_csw.DynamicSingleSwitch.Client):
            raise ValueError(
                'csw_switch must be an instance of DynamicSingleSwitch.Client')

        self._csw_switch = csw_switch
        self._is_radio_buttons = radio_buttons

        csw_switch.call_on_selected(self._on_csw_switch_selected)
        csw_switch.call_on_choices(self._on_csw_choices)

        self._btns = []
        self._main_l = qtx.QXHBoxLayout() if horizontal else qtx.QXVBoxLayout()
        super().__init__(csw_control=csw_switch, layout=self._main_l)
Exemplo n.º 10
0
    def __init__(self,
                 csw_number: lib_csw.Number.Client,
                 reflect_state_widgets=None):

        if not isinstance(csw_number, lib_csw.Number.Client):
            raise ValueError('csw_number must be an instance of Number.Client')

        self._csw_number = csw_number
        self._decimals = 0

        csw_number.call_on_number(self._on_csw_number)
        csw_number.call_on_config(self._on_csw_config)

        label = self._label = qtx.QXLabel(
            font=QXFontDB.Digital7_Mono(11, italic=True))

        super().__init__(csw_control=csw_number,
                         reflect_state_widgets=reflect_state_widgets,
                         layout=qtx.QXHBoxLayout([label]))
Exemplo n.º 11
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]))
Exemplo n.º 12
0
    def __init__(self, backend):
        cs = backend.get_control_sheet()

        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_face_x_offset_label = QLabelPopupInfo(label=L('@QFaceMerger.face_x_offset'))
        q_face_x_offset       = QSpinBoxCSWNumber(cs.face_x_offset, reflect_state_widgets=[q_face_x_offset_label])

        q_face_y_offset_label = QLabelPopupInfo(label=L('@QFaceMerger.face_y_offset'))
        q_face_y_offset       = QSpinBoxCSWNumber(cs.face_y_offset, reflect_state_widgets=[q_face_y_offset_label])

        q_face_scale_label = QLabelPopupInfo(label=L('@QFaceMerger.face_scale') )
        q_face_scale       = QSpinBoxCSWNumber(cs.face_scale, reflect_state_widgets=[q_face_scale_label])

        q_face_mask_type_label = QLabelPopupInfo(label=L('@QFaceMerger.face_mask_type') )
        q_face_mask_source_label = QLabelPopupInfo(label='SRC')
        q_face_mask_source       = QCheckBoxCSWFlag(cs.face_mask_source, reflect_state_widgets=[q_face_mask_type_label, q_face_mask_source_label])
        q_face_mask_celeb_label  = QLabelPopupInfo(label='CELEB')
        q_face_mask_celeb        = QCheckBoxCSWFlag(cs.face_mask_celeb, reflect_state_widgets=[q_face_mask_celeb_label, q_face_mask_source_label])
        q_face_mask_lmrks_label  = QLabelPopupInfo(label='LMRKS')
        q_face_mask_lmrks        = QCheckBoxCSWFlag(cs.face_mask_lmrks, reflect_state_widgets=[q_face_mask_lmrks_label, q_face_mask_source_label])

        q_face_mask_erode_label = QLabelPopupInfo(label=L('@QFaceMerger.face_mask_erode') )
        q_face_mask_erode       = QSpinBoxCSWNumber(cs.face_mask_erode, reflect_state_widgets=[q_face_mask_erode_label])

        q_face_mask_blur_label = QLabelPopupInfo(label=L('@QFaceMerger.face_mask_blur') )
        q_face_mask_blur       = QSpinBoxCSWNumber(cs.face_mask_blur, reflect_state_widgets=[q_face_mask_blur_label])

        q_color_transfer_label = QLabelPopupInfo(label=L('@QFaceMerger.color_transfer'), popup_info_text=L('@QFaceMerger.help.color_transfer'))
        q_color_transfer       = QComboBoxCSWDynamicSingleSwitch(cs.color_transfer, reflect_state_widgets=[q_color_transfer_label])

        q_interpolation_label = QLabelPopupInfo(label=L('@QFaceMerger.interpolation') )
        q_interpolation       = QComboBoxCSWDynamicSingleSwitch(cs.interpolation, reflect_state_widgets=[q_interpolation_label])

        q_color_compression_label = QLabelPopupInfo(label=L('@QFaceMerger.color_compression') )
        q_color_compression       = QSliderCSWNumber(cs.color_compression, reflect_state_widgets=[q_color_compression_label])

        q_face_opacity_label = QLabelPopupInfo(label=L('@QFaceMerger.face_opacity') )
        q_face_opacity       = QSliderCSWNumber(cs.face_opacity, reflect_state_widgets=[q_face_opacity_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.addLayout( qtx.QXVBoxLayout([q_face_x_offset_label, q_face_y_offset_label]), row, 0, alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addLayout( qtx.QXHBoxLayout([q_face_x_offset, q_face_y_offset]), row, 1, alignment=qtx.AlignLeft )
        row += 1
        grid_l.addWidget(q_face_scale_label, row, 0, alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_face_scale, row, 1, alignment=qtx.AlignLeft )
        row += 1
        grid_l.addWidget( q_face_mask_type_label, row, 0, alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addLayout( qtx.QXHBoxLayout([q_face_mask_source, q_face_mask_source_label, 5,
                                            q_face_mask_celeb, q_face_mask_celeb_label, 5,
                                            q_face_mask_lmrks, q_face_mask_lmrks_label]), row, 1, alignment=qtx.AlignLeft )
        row += 1
        grid_l.addLayout(qtx.QXVBoxLayout([q_face_mask_erode_label,q_face_mask_blur_label]), row, 0, alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addLayout(qtx.QXHBoxLayout([q_face_mask_erode,q_face_mask_blur], spacing=3), row, 1, alignment=qtx.AlignLeft )
        row += 1
        grid_l.addWidget(q_color_transfer_label, row, 0, alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_color_transfer, row, 1 )
        row += 1
        grid_l.addWidget(q_interpolation_label, row, 0, alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_interpolation, row, 1)
        row += 1
        grid_l.addWidget(q_color_compression_label, row, 0, alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_color_compression, row, 1)
        row += 1
        grid_l.addWidget(q_face_opacity_label, row, 0, alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_face_opacity, row, 1)
        row += 1

        super().__init__(backend, L('@QFaceMerger.module_title'),
                         layout=qtx.QXVBoxLayout([grid_l]) )
Exemplo n.º 13
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]))
Exemplo n.º 14
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]))
Exemplo n.º 15
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)
Exemplo n.º 16
0
    def __init__(self, backend: StreamOutput):
        cs = backend.get_control_sheet()

        q_average_fps_label = QLabelPopupInfo(
            label=L('@QStreamOutput.avg_fps'),
            popup_info_text=L('@QStreamOutput.help.avg_fps'))
        q_average_fps = QLabelCSWNumber(
            cs.avg_fps, reflect_state_widgets=[q_average_fps_label])

        q_source_type_label = QLabelPopupInfo(
            label=L('@QStreamOutput.source_type'))
        q_source_type = QComboBoxCSWDynamicSingleSwitch(
            cs.source_type, reflect_state_widgets=[q_source_type_label])

        q_show_hide_window = QXPushButtonCSWSignal(
            cs.show_hide_window,
            text=L('@QStreamOutput.show_hide_window'),
            button_size=(None, 22))

        q_aligned_face_id_label = QLabelPopupInfo(
            label=L('@QStreamOutput.aligned_face_id'),
            popup_info_text=L('@QStreamOutput.help.aligned_face_id'))
        q_aligned_face_id = QSpinBoxCSWNumber(
            cs.aligned_face_id,
            reflect_state_widgets=[q_aligned_face_id_label])

        q_target_delay_label = QLabelPopupInfo(
            label=L('@QStreamOutput.target_delay'),
            popup_info_text=L('@QStreamOutput.help.target_delay'))
        q_target_delay = QSpinBoxCSWNumber(
            cs.target_delay, reflect_state_widgets=[q_target_delay_label])

        q_save_sequence_path_label = QLabelPopupInfo(
            label=L('@QStreamOutput.save_sequence_path'),
            popup_info_text=L('@QStreamOutput.help.save_sequence_path'))
        q_save_sequence_path = QPathEditCSWPaths(cs.save_sequence_path,
                                                 reflect_state_widgets=[
                                                     q_target_delay_label,
                                                     q_save_sequence_path_label
                                                 ])
        q_save_sequence_path_error = QErrorCSWError(
            cs.save_sequence_path_error)

        q_save_fill_frame_gap_label = QLabelPopupInfo(
            label=L('@QStreamOutput.save_fill_frame_gap'),
            popup_info_text=L('@QStreamOutput.help.save_fill_frame_gap'))
        q_save_fill_frame_gap = QCheckBoxCSWFlag(
            cs.save_fill_frame_gap,
            reflect_state_widgets=[q_save_fill_frame_gap_label])

        q_is_streaming_label = QLabelPopupInfo(label='mpegts udp://')
        q_is_streaming = QCheckBoxCSWFlag(
            cs.is_streaming, reflect_state_widgets=[q_is_streaming_label])

        q_stream_addr = QLineEditCSWText(cs.stream_addr,
                                         font=QXFontDB.get_fixedwidth_font())
        q_stream_port = QSpinBoxCSWNumber(cs.stream_port)

        grid_l = qtx.QXGridLayout(spacing=5)
        row = 0
        grid_l.addWidget(q_average_fps_label,
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_average_fps,
                         row,
                         1,
                         1,
                         2,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        row += 1
        grid_l.addWidget(q_source_type_label,
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_source_type,
                         row,
                         1,
                         1,
                         1,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        grid_l.addWidget(q_show_hide_window, row, 2, 1, 1)

        row += 1
        grid_l.addWidget(q_aligned_face_id_label,
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_aligned_face_id,
                         row,
                         1,
                         1,
                         2,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        row += 1
        grid_l.addWidget(q_target_delay_label,
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_target_delay,
                         row,
                         1,
                         1,
                         2,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        row += 1

        grid_l.addWidget(q_save_sequence_path_label,
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_save_sequence_path,
                         row,
                         1,
                         1,
                         2,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        row += 1
        grid_l.addLayout(qtx.QXHBoxLayout(
            [q_save_fill_frame_gap, 4, q_save_fill_frame_gap_label]),
                         row,
                         1,
                         1,
                         2,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        row += 1
        grid_l.addWidget(q_save_sequence_path_error, row, 0, 1, 3)
        row += 1
        grid_l.addLayout(qtx.QXHBoxLayout(
            [q_is_streaming, 4, q_is_streaming_label]),
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addLayout(qtx.QXHBoxLayout(
            [q_stream_addr,
             qtx.QXLabel(text=':'), q_stream_port]),
                         row,
                         1,
                         1,
                         2,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        row += 1

        super().__init__(backend,
                         L('@QStreamOutput.module_title'),
                         layout=grid_l)
Exemplo n.º 17
0
    def __init__(self, backend: FaceDetector):
        if not isinstance(backend, FaceDetector):
            raise ValueError('backend must be an instance of FaceDetector')

        self._backend = backend
        self._bc_out = backend.get_bc_out()
        self._weak_heap = backend.get_weak_heap()
        self._bcd_id = None
        self._timer = qtx.QXTimer(interval=10,
                                  timeout=self._on_timer_10ms,
                                  start=True)

        face_coords_label = self._q_face_coords_label = qtx.QXLabel(
            font=QXFontDB.get_fixedwidth_font(size=7), word_wrap=False)
        q_detected_faces = self._q_detected_faces = qtx.QXCollapsibleSection(
            title=L('@QFaceDetector.detected_faces'),
            content_layout=qtx.QXVBoxLayout([face_coords_label]),
            is_opened=True)

        cs = backend.get_control_sheet()

        q_detector_type_label = QLabelPopupInfo(
            label=L('@QFaceDetector.detector_type'),
            popup_info_text=L('@QFaceDetector.help.detector_type'))
        q_detector_type = QComboBoxCSWDynamicSingleSwitch(
            cs.detector_type, reflect_state_widgets=[q_detector_type_label])

        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_fixed_window_size_label = QLabelPopupInfo(
            label=L('@QFaceDetector.window_size'),
            popup_info_text=L('@QFaceDetector.help.window_size'))
        q_fixed_window_size = QSpinBoxCSWNumber(cs.fixed_window_size,
                                                reflect_state_widgets=[
                                                    q_fixed_window_size_label,
                                                    q_detected_faces
                                                ])

        q_threshold_label = QLabelPopupInfo(
            label=L('@QFaceDetector.threshold'),
            popup_info_text=L('@QFaceDetector.help.threshold'))
        q_threshold = QSpinBoxCSWNumber(
            cs.threshold, reflect_state_widgets=[q_threshold_label])

        q_max_faces_label = QLabelPopupInfo(
            label=L('@QFaceDetector.max_faces'),
            popup_info_text=L('@QFaceDetector.help.max_faces'))
        q_max_faces = QSpinBoxCSWNumber(
            cs.max_faces, reflect_state_widgets=[q_max_faces_label])

        q_sort_by_label = QLabelPopupInfo(
            label=L('@QFaceDetector.sort_by'),
            popup_info_text=L('@QFaceDetector.help.sort_by'))
        q_sort_by = QComboBoxCSWDynamicSingleSwitch(
            cs.sort_by, reflect_state_widgets=[q_sort_by_label])

        q_temporal_smoothing_label = QLabelPopupInfo(
            label=L('@QFaceDetector.temporal_smoothing'),
            popup_info_text=L('@QFaceDetector.help.temporal_smoothing'))
        q_temporal_smoothing = QSpinBoxCSWNumber(
            cs.temporal_smoothing,
            reflect_state_widgets=[q_temporal_smoothing_label])

        grid_l = qtx.QXGridLayout(vertical_spacing=5, horizontal_spacing=5)
        row = 0
        grid_l.addWidget(q_detector_type_label,
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_detector_type, row, 1, 1, 3)
        row += 1
        grid_l.addWidget(q_device_label,
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_device, row, 1, 1, 3)
        row += 1
        grid_l.addWidget(q_fixed_window_size_label,
                         row,
                         0,
                         1,
                         2,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_fixed_window_size,
                         row,
                         2,
                         1,
                         2,
                         alignment=qtx.AlignLeft)
        row += 1
        grid_l.addWidget(q_threshold_label,
                         row,
                         0,
                         1,
                         2,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_threshold, row, 2, 1, 2, alignment=qtx.AlignLeft)
        row += 1
        grid_l.addLayout(qtx.QXHBoxLayout([q_max_faces_label, 5, q_max_faces]),
                         row,
                         0,
                         1,
                         2,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addLayout(qtx.QXHBoxLayout([q_sort_by_label, 5, q_sort_by]),
                         row,
                         2,
                         1,
                         2,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        row += 1
        grid_l.addLayout(qtx.QXHBoxLayout(
            [q_temporal_smoothing_label, 5, q_temporal_smoothing]),
                         row,
                         0,
                         1,
                         4,
                         alignment=qtx.AlignCenter)
        row += 1
        grid_l.addWidget(q_detected_faces, row, 0, 1, 4)
        row += 1
        super().__init__(backend,
                         L('@QFaceDetector.module_title'),
                         layout=qtx.QXVBoxLayout([grid_l]))