Refactor HVideoTool to exclusively use YOLO for detection and DeepMosaics for restoration: removed classic CV and composite detectors, updated configuration and UI accordingly. Enhanced documentation in README and CLAUDE.md to reflect these changes, including new batch processing capabilities and device diagnostics.

This commit is contained in:
Leonid Pershin
2026-06-07 06:16:05 +03:00
parent cc518cc3e6
commit 9c471ca701
17 changed files with 798 additions and 676 deletions
+23 -12
View File
@@ -1,9 +1,11 @@
"""Configure the restoration ("расцензурить") engine.
inpaint — no setup. deepmosaics — the network code is vendored (built-in); the user
picks a clean model from a dropdown of the bundled ``models/deepmosaics`` weights
(or browses to another ``clean_*.pth``). ``mosaic_position.pth`` must sit beside the
chosen model. A CUDA GPU is strongly recommended (GPU id, -1 = CPU/slow).
Restoration is DeepMosaics-only — pick the per-frame ("картинка") or temporal ("видео")
engine. The network code is vendored (built-in); the user picks a clean model from a
dropdown of the bundled ``models/deepmosaics`` weights (or browses to another
``clean_*.pth``) — for the video engine only ``clean_*_video.pth`` is offered.
``mosaic_position.pth`` must sit beside the chosen model. A CUDA GPU is strongly
recommended (GPU id, -1 = CPU/slow).
"""
from __future__ import annotations
@@ -35,9 +37,9 @@ class RestoreDialog(QDialog):
self.setMinimumWidth(560)
self.engine = QComboBox()
self.engine.addItem("Инпейнт (быстро, замазывает — без модели)", "inpaint")
self.engine.addItem("DeepMosaics (реальное расцензуривание, нужна модель+GPU)", "deepmosaics")
self.engine.setCurrentIndex(1 if config.restorer == "deepmosaics" else 0)
self.engine.addItem("DeepMosaics — картинка (покадрово, нужна модель+GPU)", "deepmosaics")
self.engine.addItem("DeepMosaics — видео (соседние кадры, лучше для роликов)", "deepmosaics_video")
self.engine.setCurrentIndex(max(0, self.engine.findData(config.restorer)))
self.engine.currentIndexChanged.connect(self._sync)
# Model dropdown — bundled clean models, plus the configured one if external.
@@ -52,9 +54,11 @@ class RestoreDialog(QDialog):
form.addRow("Модель:", self._with_browse(self.model_combo, self._browse_model))
form.addRow("GPU id:", self.dm_gpu)
hint = QLabel(
"Модели берутся из models/deepmosaics. Нужны clean_youknow_resnet_9blocks.pth "
"и mosaic_position.pth (рядом). Видеомодель clean_*_video.pth покадрово не "
"работает и в списке не показывается. На CPU медленно — лучше GPU. См. README."
"Модели берутся из models/deepmosaics (рядом нужен mosaic_position.pth).\n"
"• Картинка: clean_youknow_resnet_9blocks.pth покадрово.\n"
"• Видео: clean_youknow_video.pth — использует соседние кадры (когерентнее на "
"роликах), требует прогона по диапазону («Расцензурить все»).\n"
"На CPU медленно — лучше GPU. См. README."
)
hint.setWordWrap(True)
form.addRow(hint)
@@ -67,7 +71,12 @@ class RestoreDialog(QDialog):
def _populate_models(self, current: str | None) -> None:
self.model_combo.clear()
for name, path in discover_models():
is_video = self.engine.currentData() == "deepmosaics_video"
if is_video: # temporal engine: only the video weights (clean_*_video.pth)
models = [(n, p) for n, p in discover_models(include_video=True) if "video" in n.lower()]
else:
models = discover_models() # per-frame engine: image clean models only
for name, path in models:
self.model_combo.addItem(name, path)
# Keep an externally-configured model selectable even if it's outside the folder.
if current and self.model_combo.findData(current) < 0:
@@ -88,7 +97,9 @@ class RestoreDialog(QDialog):
return w
def _sync(self) -> None:
is_dm = self.engine.currentData() == "deepmosaics"
is_dm = self.engine.currentData() in ("deepmosaics", "deepmosaics_video")
# The model list differs per engine (image vs video weights) — repopulate.
self._populate_models(self._cfg.dm_model)
self.model_combo.setEnabled(is_dm)
self.dm_gpu.setEnabled(is_dm)