Loading dl/inpaint/__init__.py +2 −2 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ class InpainterBase(ModuleParamParser): inpainted = np.copy(img) for blk in textblock_list: xyxy = blk.xyxy xyxy_e = enlarge_window(xyxy, im_w, im_h, ratio=2) xyxy_e = enlarge_window(xyxy, im_w, im_h, ratio=1.7) im = inpainted[xyxy_e[1]:xyxy_e[3], xyxy_e[0]:xyxy_e[2]] msk = mask[xyxy_e[1]:xyxy_e[3], xyxy_e[0]:xyxy_e[2]] need_inpaint = True Loading @@ -54,7 +54,7 @@ class InpainterBase(ModuleParamParser): inpaint_thresh = 7 if np.std(std_bgr) > 1 else 10 if std_max < inpaint_thresh: need_inpaint = False inpainted[xyxy_e[1]:xyxy_e[3], xyxy_e[0]:xyxy_e[2]][np.where(ballon_msk > 0)] = average_bg_color im[np.where(ballon_msk > 0)] = average_bg_color # cv2.imshow('im', im) # cv2.imshow('ballon', ballon_msk) # cv2.imshow('non_text', non_text_msk) Loading tests/test_inpainters.py +2 −5 Original line number Diff line number Diff line Loading @@ -63,8 +63,5 @@ if __name__ == '__main__': manga_proj = ProjImgTrans(manga_dir) comic_proj = ProjImgTrans(comic_dir) # comic_proj = ProjImgTrans(comic_dir2) # test_aot(manga_proj, device='cpu', inpaint_by_block=True) test_patchmatch(comic_proj, inpaint_by_block=True) test_aot(comic_proj, device='cpu', inpaint_by_block=True, inpaint_size=2048) # test_patchmatch(comic_proj, inpaint_by_block=False) No newline at end of file ui/configpanel.py +1 −2 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ class ConfigSubBlock(Widget): layout = QHBoxLayout(self) self.name = name if name is not None: textlabel = ConfigTextLabel(name, CONFIG_FONTSIZE_CONTENT, QFont.DemiBold) textlabel = ConfigTextLabel(name, CONFIG_FONTSIZE_CONTENT, QFont.Weight.Normal) layout.addWidget(textlabel) if discription is not None: layout.addWidget(ConfigTextLabel(discription, CONFIG_FONTSIZE_CONTENT-2)) Loading Loading @@ -108,7 +108,6 @@ class ConfigBlock(Widget): return checkbox def getSubBlockbyIdx(self, idx: int) -> ConfigSubBlock: print(idx) return self.subblock_list[idx] Loading ui/dl_manager.py +7 −0 Original line number Diff line number Diff line Loading @@ -449,6 +449,8 @@ class DLManager(QObject): inpainter_panel.setupModulesParamWidgets(inpainter_setup_params) inpainter_panel.paramwidget_edited.connect(self.on_inpainterparam_edited) inpainter_panel.inpainter_changed.connect(self.setInpainter) inpainter_panel.needInpaintChecker.checker_changed.connect(self.on_inpainter_checker_changed) inpainter_panel.needInpaintChecker.checker.setChecked(dl_config.check_need_inpaint) self.textdetect_panel = textdetector_panel = config_panel.detect_config_panel textdetector_setup_params = self.dl_config.textdetector_setup_params Loading Loading @@ -723,4 +725,9 @@ class DLManager(QObject): err.setDetailedText(detail) err.exec() def on_inpainter_checker_changed(self, is_checked: bool): self.dl_config.check_need_inpaint = is_checked InpainterBase.check_need_inpaint = is_checked ui/dlconfig_parse_widgets.py +27 −6 Original line number Diff line number Diff line from typing import List, Union, Tuple from PyQt5.QtWidgets import QLayout, QHBoxLayout, QVBoxLayout, QTreeView, QPlainTextEdit, QWidget, QFileDialog, QLabel, QSizePolicy, QComboBox, QListView, QToolBar, QMenu, QSpacerItem, QPushButton, QAction, QCheckBox, QToolButton, QSplitter, QStylePainter, QStyleOption, QStyle, QScrollArea, QLineEdit, QGroupBox, QGraphicsSimpleTextItem from PyQt5.QtWidgets import QHBoxLayout, QVBoxLayout, QTreeView, QPlainTextEdit, QWidget, QFileDialog, QLabel, QSizePolicy, QComboBox, QListView, QToolBar, QMenu, QSpacerItem, QPushButton, QAction, QCheckBox, QToolButton, QSplitter, QStylePainter, QStyleOption, QStyle, QScrollArea, QLineEdit, QGroupBox, QGraphicsSimpleTextItem from PyQt5.QtCore import Qt, QModelIndex, pyqtSignal, QPointF, QPoint, QSize, QSizeF, QObject, QEvent from PyQt5.QtGui import QStandardItemModel from PyQt5.QtGui import QStandardItemModel, QFontMetricsF from .stylewidgets import ConfigComboBox from .constants import CONFIG_FONTSIZE_TABLE, CONFIG_FONTSIZE_CONTENT, CONFIG_FONTSIZE_HEADER, CONFIG_COMBOBOX_LONG, CONFIG_COMBOBOX_MIDEAN, CONFIG_COMBOBOX_SHORT Loading @@ -10,15 +10,18 @@ from dl import VALID_INPAINTERS, VALID_TEXTDETECTORS, VALID_TRANSLATORS, VALID_O TranslatorBase, DEFAULT_DEVICE class ParamNameLabel(QLabel): def __init__(self, *args, **kwargs) -> None: def __init__(self, param_name: str, *args, **kwargs) -> None: super().__init__(*args, **kwargs) self.setAlignment(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter) font = self.font() font.setPointSizeF(CONFIG_FONTSIZE_CONTENT-2) self.setFont(font) labelwidth = 120 fm = QFontMetricsF(font) fmw = fm.width(param_name) labelwidth = max(fmw, labelwidth) self.setFixedWidth(labelwidth) self.setText(param_name) class ParamEditor(QLineEdit): Loading Loading @@ -49,6 +52,23 @@ class ParamComboBox(QComboBox): self.paramwidget_edited.emit(self.param_key, self.currentText()) class ParamCheckerBox(QWidget): checker_changed = pyqtSignal(bool) def __init__(self, param_key: str, *args, **kwargs): super().__init__(*args, **kwargs) self.param_key = param_key self.checker = QCheckBox() name_label = ParamNameLabel(param_key) hlayout = QHBoxLayout(self) hlayout.addWidget(name_label) hlayout.addWidget(self.checker) hlayout.setAlignment(Qt.AlignmentFlag.AlignLeft) self.checker.stateChanged.connect(self.on_checker_changed) def on_checker_changed(self): self.checker_changed.emit(self.checker.isChecked()) class ParamWidget(QWidget): paramwidget_edited = pyqtSignal(str, str) Loading Loading @@ -206,7 +226,8 @@ class InpaintConfigPanel(ModuleConfigParseWidget): self.inpainter_changed = self.module_changed self.inpainter_combobox = self.module_combobox self.setInpainter = self.setModule self.needInpaintChecker = ParamCheckerBox(self.tr('Let the program decide whether it is necessary to use the selected inpaint method.')) self.vlayout.addWidget(self.needInpaintChecker) class TextDetectConfigPanel(ModuleConfigParseWidget): def __init__(self, module_name: str, *args, **kwargs) -> None: Loading Loading
dl/inpaint/__init__.py +2 −2 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ class InpainterBase(ModuleParamParser): inpainted = np.copy(img) for blk in textblock_list: xyxy = blk.xyxy xyxy_e = enlarge_window(xyxy, im_w, im_h, ratio=2) xyxy_e = enlarge_window(xyxy, im_w, im_h, ratio=1.7) im = inpainted[xyxy_e[1]:xyxy_e[3], xyxy_e[0]:xyxy_e[2]] msk = mask[xyxy_e[1]:xyxy_e[3], xyxy_e[0]:xyxy_e[2]] need_inpaint = True Loading @@ -54,7 +54,7 @@ class InpainterBase(ModuleParamParser): inpaint_thresh = 7 if np.std(std_bgr) > 1 else 10 if std_max < inpaint_thresh: need_inpaint = False inpainted[xyxy_e[1]:xyxy_e[3], xyxy_e[0]:xyxy_e[2]][np.where(ballon_msk > 0)] = average_bg_color im[np.where(ballon_msk > 0)] = average_bg_color # cv2.imshow('im', im) # cv2.imshow('ballon', ballon_msk) # cv2.imshow('non_text', non_text_msk) Loading
tests/test_inpainters.py +2 −5 Original line number Diff line number Diff line Loading @@ -63,8 +63,5 @@ if __name__ == '__main__': manga_proj = ProjImgTrans(manga_dir) comic_proj = ProjImgTrans(comic_dir) # comic_proj = ProjImgTrans(comic_dir2) # test_aot(manga_proj, device='cpu', inpaint_by_block=True) test_patchmatch(comic_proj, inpaint_by_block=True) test_aot(comic_proj, device='cpu', inpaint_by_block=True, inpaint_size=2048) # test_patchmatch(comic_proj, inpaint_by_block=False) No newline at end of file
ui/configpanel.py +1 −2 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ class ConfigSubBlock(Widget): layout = QHBoxLayout(self) self.name = name if name is not None: textlabel = ConfigTextLabel(name, CONFIG_FONTSIZE_CONTENT, QFont.DemiBold) textlabel = ConfigTextLabel(name, CONFIG_FONTSIZE_CONTENT, QFont.Weight.Normal) layout.addWidget(textlabel) if discription is not None: layout.addWidget(ConfigTextLabel(discription, CONFIG_FONTSIZE_CONTENT-2)) Loading Loading @@ -108,7 +108,6 @@ class ConfigBlock(Widget): return checkbox def getSubBlockbyIdx(self, idx: int) -> ConfigSubBlock: print(idx) return self.subblock_list[idx] Loading
ui/dl_manager.py +7 −0 Original line number Diff line number Diff line Loading @@ -449,6 +449,8 @@ class DLManager(QObject): inpainter_panel.setupModulesParamWidgets(inpainter_setup_params) inpainter_panel.paramwidget_edited.connect(self.on_inpainterparam_edited) inpainter_panel.inpainter_changed.connect(self.setInpainter) inpainter_panel.needInpaintChecker.checker_changed.connect(self.on_inpainter_checker_changed) inpainter_panel.needInpaintChecker.checker.setChecked(dl_config.check_need_inpaint) self.textdetect_panel = textdetector_panel = config_panel.detect_config_panel textdetector_setup_params = self.dl_config.textdetector_setup_params Loading Loading @@ -723,4 +725,9 @@ class DLManager(QObject): err.setDetailedText(detail) err.exec() def on_inpainter_checker_changed(self, is_checked: bool): self.dl_config.check_need_inpaint = is_checked InpainterBase.check_need_inpaint = is_checked
ui/dlconfig_parse_widgets.py +27 −6 Original line number Diff line number Diff line from typing import List, Union, Tuple from PyQt5.QtWidgets import QLayout, QHBoxLayout, QVBoxLayout, QTreeView, QPlainTextEdit, QWidget, QFileDialog, QLabel, QSizePolicy, QComboBox, QListView, QToolBar, QMenu, QSpacerItem, QPushButton, QAction, QCheckBox, QToolButton, QSplitter, QStylePainter, QStyleOption, QStyle, QScrollArea, QLineEdit, QGroupBox, QGraphicsSimpleTextItem from PyQt5.QtWidgets import QHBoxLayout, QVBoxLayout, QTreeView, QPlainTextEdit, QWidget, QFileDialog, QLabel, QSizePolicy, QComboBox, QListView, QToolBar, QMenu, QSpacerItem, QPushButton, QAction, QCheckBox, QToolButton, QSplitter, QStylePainter, QStyleOption, QStyle, QScrollArea, QLineEdit, QGroupBox, QGraphicsSimpleTextItem from PyQt5.QtCore import Qt, QModelIndex, pyqtSignal, QPointF, QPoint, QSize, QSizeF, QObject, QEvent from PyQt5.QtGui import QStandardItemModel from PyQt5.QtGui import QStandardItemModel, QFontMetricsF from .stylewidgets import ConfigComboBox from .constants import CONFIG_FONTSIZE_TABLE, CONFIG_FONTSIZE_CONTENT, CONFIG_FONTSIZE_HEADER, CONFIG_COMBOBOX_LONG, CONFIG_COMBOBOX_MIDEAN, CONFIG_COMBOBOX_SHORT Loading @@ -10,15 +10,18 @@ from dl import VALID_INPAINTERS, VALID_TEXTDETECTORS, VALID_TRANSLATORS, VALID_O TranslatorBase, DEFAULT_DEVICE class ParamNameLabel(QLabel): def __init__(self, *args, **kwargs) -> None: def __init__(self, param_name: str, *args, **kwargs) -> None: super().__init__(*args, **kwargs) self.setAlignment(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter) font = self.font() font.setPointSizeF(CONFIG_FONTSIZE_CONTENT-2) self.setFont(font) labelwidth = 120 fm = QFontMetricsF(font) fmw = fm.width(param_name) labelwidth = max(fmw, labelwidth) self.setFixedWidth(labelwidth) self.setText(param_name) class ParamEditor(QLineEdit): Loading Loading @@ -49,6 +52,23 @@ class ParamComboBox(QComboBox): self.paramwidget_edited.emit(self.param_key, self.currentText()) class ParamCheckerBox(QWidget): checker_changed = pyqtSignal(bool) def __init__(self, param_key: str, *args, **kwargs): super().__init__(*args, **kwargs) self.param_key = param_key self.checker = QCheckBox() name_label = ParamNameLabel(param_key) hlayout = QHBoxLayout(self) hlayout.addWidget(name_label) hlayout.addWidget(self.checker) hlayout.setAlignment(Qt.AlignmentFlag.AlignLeft) self.checker.stateChanged.connect(self.on_checker_changed) def on_checker_changed(self): self.checker_changed.emit(self.checker.isChecked()) class ParamWidget(QWidget): paramwidget_edited = pyqtSignal(str, str) Loading Loading @@ -206,7 +226,8 @@ class InpaintConfigPanel(ModuleConfigParseWidget): self.inpainter_changed = self.module_changed self.inpainter_combobox = self.module_combobox self.setInpainter = self.setModule self.needInpaintChecker = ParamCheckerBox(self.tr('Let the program decide whether it is necessary to use the selected inpaint method.')) self.vlayout.addWidget(self.needInpaintChecker) class TextDetectConfigPanel(ModuleConfigParseWidget): def __init__(self, module_name: str, *args, **kwargs) -> None: Loading