From 2b1b26333bd3749772c4399e0452e56bcbcc67f7 Mon Sep 17 00:00:00 2001 From: "fatih c. akyon" <34196005+fcakyon@users.noreply.github.com> Date: Fri, 5 Jul 2024 20:25:42 +0300 Subject: [PATCH] Fix Action Recognition Example with `torch>=2.0` (#14232) --- .../YOLOv8-Action-Recognition/action_recognition.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/YOLOv8-Action-Recognition/action_recognition.py b/examples/YOLOv8-Action-Recognition/action_recognition.py index bd91f08e23..612d23a2e3 100644 --- a/examples/YOLOv8-Action-Recognition/action_recognition.py +++ b/examples/YOLOv8-Action-Recognition/action_recognition.py @@ -171,13 +171,13 @@ class HuggingFaceVideoClassifier: """ if input_size is None: input_size = [224, 224] - from torchvision.transforms import v2 + from torchvision import transforms - transform = v2.Compose( + transform = transforms.Compose( [ - v2.ToDtype(torch.float32, scale=True), - v2.Resize(input_size, antialias=True), - v2.Normalize( + transforms.Lambda(lambda x: x.float() / 255.0), + transforms.Resize(input_size), + transforms.Normalize( mean=self.processor.image_processor.image_mean, std=self.processor.image_processor.image_std ), ]