Skip to content

Commit

Permalink
fix(video) remove file:// prefix for torchvision < 0.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kq-chen committed Sep 24, 2024
1 parent 3a8e0ed commit c6e6201
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions qwen-vl-utils/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies = [
"requests",
"pillow",
"av",
"packaging",
]
readme = "README.md"
requires-python = ">= 3.8"
Expand Down
2 changes: 2 additions & 0 deletions qwen-vl-utils/requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ nvidia-nvjitlink-cu12==12.6.68
# via nvidia-cusparse-cu12
nvidia-nvtx-cu12==12.1.105
# via torch
packaging==24.1
# via qwen-vl-utils
pillow==10.2.0
# via qwen-vl-utils
# via torchvision
Expand Down
2 changes: 2 additions & 0 deletions qwen-vl-utils/requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ idna==3.4
# via requests
numpy==1.24.4
# via decord
packaging==24.1
# via qwen-vl-utils
pillow==10.2.0
# via qwen-vl-utils
requests==2.28.1
Expand Down
8 changes: 8 additions & 0 deletions qwen-vl-utils/src/qwen_vl_utils/vision_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
import os
import sys
import time
import warnings
from functools import lru_cache
from io import BytesIO

import requests
import torch
import torchvision
from packaging import version
from PIL import Image
from torchvision import io, transforms
from torchvision.transforms import InterpolationMode
Expand Down Expand Up @@ -174,6 +177,11 @@ def _read_video_torchvision(
torch.Tensor: the video tensor with shape (T, C, H, W).
"""
video_path = ele["video"]
if version(torchvision.__version__) < version.parse("0.19.0"):
if "http://" in video_path or "https://" in video_path:
warnings.warn("torchvision < 0.19.0 does not support http/https video path, please upgrade to 0.19.0.")
if "file://" in video_path:
video_path = video_path[7:]
st = time.time()
video, audio, info = io.read_video(
video_path,
Expand Down

0 comments on commit c6e6201

Please sign in to comment.