Enhance HVideoTool's detection and restoration features: added support for tracking the model used in detections, improved temporal coherence by allowing the use of already-restored frames in the restoration process, and updated the UI to reflect these changes with new indicators and configuration options. Documentation in CLAUDE.md has been updated accordingly.

This commit is contained in:
Leonid Pershin
2026-06-07 08:40:57 +03:00
parent 7a225efa85
commit cabb4e3d3d
11 changed files with 168 additions and 27 deletions
+3
View File
@@ -24,6 +24,7 @@ class Detection:
bbox: tuple[int, int, int, int] # x, y, w, h
polygon: list[tuple[int, int]] = field(default_factory=list) # contour points
label: str = "" # model category (models/yolo/<label>); drives colour/grouping
model: str = "" # weights file that produced it (the .pt stem)
@property
def display(self) -> str:
@@ -37,6 +38,7 @@ class Detection:
"bbox": list(self.bbox),
"polygon": [list(p) for p in self.polygon],
"label": self.label,
"model": self.model,
}
@classmethod
@@ -47,4 +49,5 @@ class Detection:
bbox=tuple(data["bbox"]), # type: ignore[arg-type]
polygon=[tuple(p) for p in data.get("polygon", [])],
label=data.get("label", ""),
model=data.get("model", ""),
)
+7 -2
View File
@@ -35,10 +35,14 @@ def _name_to_type(name: str) -> CensorType:
class YoloDetector(Detector):
def __init__(
self, model_path: str, config: DetectionConfig | None = None, label: str = ""
self, model_path: str, config: DetectionConfig | None = None,
label: str = "", model_name: str = "",
) -> None:
self.cfg = config or DetectionConfig()
self._label = label # category (models/yolo/<label>) tagged onto every detection
# weights filename (stem) tagged onto every detection, so the UI can show
# which specific model predicted it (a category folder may hold several).
self._model_name = model_name or os.path.splitext(os.path.basename(model_path))[0]
if not os.path.isfile(model_path):
raise FileNotFoundError(
f"Файл весов не найден: {model_path}\n"
@@ -108,6 +112,7 @@ class YoloDetector(Detector):
poly = [(int(px), int(py)) for px, py in polygons[i]]
ctype = _name_to_type(names.get(int(classes[i]), ""))
out.append(Detection(
type=ctype, score=float(confs[i]), bbox=bbox, polygon=poly, label=self._label
type=ctype, score=float(confs[i]), bbox=bbox, polygon=poly,
label=self._label, model=self._model_name,
))
return out