From f084fbc14d9cfd41e3f8b2ed30080662bcdcabd5 Mon Sep 17 00:00:00 2001 From: fcakyon Date: Tue, 30 Jul 2024 15:06:02 +0300 Subject: [PATCH] Update HuggingFaceVideoClassifier to support torchvision>=0.16.0 --- ultralytics/solutions/action_recognition.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ultralytics/solutions/action_recognition.py b/ultralytics/solutions/action_recognition.py index b0623ca540..ab80fc70a4 100644 --- a/ultralytics/solutions/action_recognition.py +++ b/ultralytics/solutions/action_recognition.py @@ -343,6 +343,8 @@ class TorchVisionVideoClassifier: class HuggingFaceVideoClassifier: """Zero-shot video classifier using Hugging Face models for various devices.""" + supports_transforms_v2 = check_requirements("torchvision>=0.16.0", install=False) + def __init__( self, labels: List[str], @@ -385,9 +387,7 @@ class HuggingFaceVideoClassifier: if input_size is None: input_size = [224, 224] - supports_transforms_v2 = check_requirements("torchvision>=0.16.0", install=False) - - if supports_transforms_v2: + if self.upports_transforms_v2: from torchvision.transforms import v2 transform = v2.Compose(