Enhance HVideoTool with background processing and device detection: implemented a background job system for detection and restoration tasks, updated the UI to display CUDA/CPU status, and improved device diagnostics. Documentation in README and CLAUDE.md reflects these changes.
This commit is contained in:
@@ -54,15 +54,20 @@ class YoloDetector(Detector):
|
||||
"(и PyTorch с CUDA отдельно — см. README)."
|
||||
) from exc
|
||||
|
||||
# Resolve the device: explicit override, else CUDA when available.
|
||||
# Resolve the device: CUDA only when actually available, else CPU. A CPU-only
|
||||
# torch build raises "Torch not compiled with CUDA enabled" if asked for cuda,
|
||||
# so we never request it without a working GPU (even on an explicit override).
|
||||
try:
|
||||
import torch
|
||||
|
||||
cuda_ok = torch.cuda.is_available()
|
||||
except Exception: # noqa: BLE001
|
||||
cuda_ok = False
|
||||
device = self.cfg.yolo_device
|
||||
if device is None:
|
||||
try:
|
||||
import torch
|
||||
|
||||
device = "cuda" if torch.cuda.is_available() else "cpu"
|
||||
except Exception: # noqa: BLE001
|
||||
device = "cpu"
|
||||
device = "cuda" if cuda_ok else "cpu"
|
||||
elif "cuda" in str(device) and not cuda_ok:
|
||||
device = "cpu"
|
||||
self._device = device
|
||||
self._model = YOLO(model_path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user