fixed a bug
This commit is contained in:
@@ -15,17 +15,29 @@ except ImportError:
|
||||
sys.exit(1)
|
||||
|
||||
class VideoCleaner:
|
||||
def __init__(self, model_path='yolo26n.pt', brightness_threshold=25, age_days=30):
|
||||
print(f"Initializing YOLO model: {model_path}...")
|
||||
try:
|
||||
self.model = YOLO(model_path)
|
||||
except Exception as e:
|
||||
print(f"Failed to load YOLO model: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
def __init__(self, model_path='yolo26n.pt', brightness_threshold=25, age_days=30, workers=4):
|
||||
self.model_path = model_path
|
||||
self.brightness_threshold = brightness_threshold
|
||||
self.age_limit = timedelta(days=age_days)
|
||||
self.workers = workers
|
||||
self.supported_extensions = ('.mp4', '.avi', '.mov', '.mkv', '.flv', '.wmv')
|
||||
|
||||
# We'll initialize the model inside each process for thread/process safety
|
||||
self.model = None
|
||||
|
||||
def _get_model(self):
|
||||
"""Lazy initialization of the model for each process."""
|
||||
if self.model is None:
|
||||
# print(f"[{os.getpid()}] Initializing YOLO model: {self.model_path}...")
|
||||
try:
|
||||
self.model = YOLO(self.model_path)
|
||||
# Ensure it's on GPU if available
|
||||
if torch.cuda.is_available():
|
||||
self.model.to('cuda')
|
||||
except Exception as e:
|
||||
print(f"Failed to load YOLO model in process {os.getpid()}: {e}")
|
||||
sys.exit(1)
|
||||
return self.model
|
||||
|
||||
def is_frame_color_and_bright(self, frame):
|
||||
"""Checks if a single frame is in 'Day/Lights-on' mode."""
|
||||
|
||||
Reference in New Issue
Block a user