Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/consistency.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG REF=main
RUN apt-get update && apt-get install -y time git g++ pkg-config make git-lfs
ENV UV_PYTHON=/usr/local/bin/python
RUN pip install uv && uv pip install --no-cache-dir -U pip setuptools GitPython
RUN uv pip install --no-cache-dir --upgrade 'torch<=2.10.0' 'torchaudio' 'torchvision' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir --upgrade 'torch<=2.11.0' 'torchaudio' 'torchvision' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir pypi-kenlm
RUN uv pip install --no-cache-dir "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[quality,testing,torch-speech,vision]"
RUN git lfs install
Expand Down
2 changes: 1 addition & 1 deletion docker/custom-tokenizers.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN make install -j 10

WORKDIR /

RUN uv pip install --no-cache --upgrade 'torch<=2.10.0' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache --upgrade 'torch<=2.11.0' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir --no-deps accelerate --extra-index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[ja,testing,sentencepiece,spacy,rjieba]" unidic unidic-lite
# spacy is not used so not tested. Causes to failures. TODO fix later
Expand Down
2 changes: 1 addition & 1 deletion docker/examples-torch.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ USER root
RUN apt-get update && apt-get install -y --no-install-recommends libsndfile1-dev espeak-ng time git g++ cmake pkg-config openssh-client git-lfs ffmpeg curl
ENV UV_PYTHON=/usr/local/bin/python
RUN pip --no-cache-dir install uv && uv pip install --no-cache-dir -U pip setuptools
RUN uv pip install --no-cache-dir 'torch<=2.10.0' 'torchaudio' 'torchvision' 'torchcodec<=0.10.0' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir 'torch<=2.11.0' 'torchaudio' 'torchvision' 'torchcodec<=0.11.0' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-deps timm accelerate --extra-index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir librosa "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[sklearn,sentencepiece,vision,testing]" seqeval albumentations jiwer

Expand Down
2 changes: 1 addition & 1 deletion docker/exotic-models.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ USER root
RUN apt-get update && apt-get install -y libsndfile1-dev espeak-ng time git libgl1 g++ tesseract-ocr git-lfs curl
ENV UV_PYTHON=/usr/local/bin/python
RUN pip --no-cache-dir install uv && uv pip install --no-cache-dir -U pip setuptools
RUN uv pip install --no-cache-dir 'torch<=2.10.0' 'torchaudio' 'torchvision' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir 'torch<=2.11.0' 'torchaudio' 'torchvision' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir --no-deps timm accelerate
RUN uv pip install -U --no-cache-dir pytesseract python-Levenshtein opencv-python nltk
# RUN uv pip install --no-cache-dir natten==0.15.1+torch210cpu -f https://shi-labs.com/natten/wheels
Expand Down
2 changes: 1 addition & 1 deletion docker/pipeline-torch.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ USER root
RUN apt-get update && apt-get install -y --no-install-recommends libsndfile1-dev espeak-ng time git pkg-config openssh-client git ffmpeg curl
ENV UV_PYTHON=/usr/local/bin/python
RUN pip --no-cache-dir install uv && uv pip install --no-cache-dir -U pip setuptools
RUN uv pip install --no-cache-dir 'torch<=2.10.0' 'torchaudio' 'torchvision' 'torchcodec<=0.10.0' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir 'torch<=2.11.0' 'torchaudio' 'torchvision' 'torchcodec<=0.11.0' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-deps timm accelerate --extra-index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir librosa "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[sklearn,sentencepiece,vision,testing]"

Expand Down
2 changes: 1 addition & 1 deletion docker/torch-light.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ USER root
RUN apt-get update && apt-get install -y --no-install-recommends libsndfile1-dev espeak-ng time git g++ cmake pkg-config openssh-client git-lfs ffmpeg curl
ENV UV_PYTHON=/usr/local/bin/python
RUN pip --no-cache-dir install uv && uv pip install --no-cache-dir -U pip setuptools
RUN uv pip install --no-cache-dir 'torch<=2.10.0' 'torchaudio' 'torchvision' 'torchcodec<=0.10.0' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir 'torch<=2.11.0' 'torchaudio' 'torchvision' 'torchcodec<=0.11.0' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-deps timm accelerate --extra-index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir librosa "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[sklearn,sentencepiece,vision,testing,tiktoken,num2words,video]"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class LlavaOnevisionProcessorTest(ProcessorTesterMixin, unittest.TestCase):
def setUpClass(cls):
# Ensure local assets are used instead of remote URLs to avoid network access in tests
from tests.test_processing_common import MODALITY_INPUT_DATA
from transformers import video_processing_utils, video_utils

repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", ".."))
local_image = os.path.join(repo_root, "coco_sample.png")
Expand Down Expand Up @@ -67,9 +66,6 @@ def setUpClass(cls):
MODALITY_INPUT_DATA["images"] = [local_image, local_image]
MODALITY_INPUT_DATA["videos"] = local_videos

# Force video decoding to use torchvision backend to avoid torchcodec dependency during tests
video_processing_utils.is_torchcodec_available = lambda: False # type: ignore
video_utils.is_torchcodec_available = lambda: False # type: ignore
Comment on lines -70 to -72

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes issues like below.

I have no context of why using this. But we are moving away from torchvision anyway as @zucchini-nlp told me, and we also have

        if not is_torchcodec_available():
            warnings.warn(
                "`torchcodec` is not installed and cannot be used to decode the video by default. "
                "Falling back to `torchvision`. Note that `torchvision` decoding is deprecated and will be removed in future versions. "
            )
            backend = "torchvision"

Anyway, the changes works.

error log

a = (<tests.models.llava_onevision.test_processing_llava_onevision.LlavaOnevisionProcessorTest testMethod=test_apply_chat_template_video_1>,)
kw = {}

    @wraps(func)
    def standalone_func(*a, **kw):
>       return func(*(a + p.args), **p.kwargs, **kw)

/usr/local/lib/python3.10/site-packages/parameterized/parameterized.py:620: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_processing_common.py:1679: in test_apply_chat_template_video
    self._test_apply_chat_template(
tests/test_processing_common.py:1616: in _test_apply_chat_template
    out_dict = processor.apply_chat_template(
/usr/local/lib/python3.10/site-packages/transformers/processing_utils.py:1898: in apply_chat_template
    out = self(
/usr/local/lib/python3.10/site-packages/transformers/models/llava_onevision/processing_llava_onevision.py:139: in __call__
    video_inputs = self.video_processor(videos, **output_kwargs["videos_kwargs"])
/usr/local/lib/python3.10/site-packages/transformers/video_processing_utils.py:178: in __call__
    return self.preprocess(videos, **kwargs)
/usr/local/lib/python3.10/site-packages/transformers/video_processing_utils.py:354: in preprocess
    videos, video_metadata = self._decode_and_sample_videos(
/usr/local/lib/python3.10/site-packages/transformers/video_processing_utils.py:294: in _decode_and_sample_videos
    videos, video_metadata = self.fetch_videos(videos, sample_indices_fn=sample_indices_fn)
/usr/local/lib/python3.10/site-packages/transformers/video_processing_utils.py:836: in fetch_videos
    return list(zip(*[self.fetch_videos(x, sample_indices_fn=sample_indices_fn) for x in video_url_or_urls]))
/usr/local/lib/python3.10/site-packages/transformers/video_processing_utils.py:836: in <listcomp>
    return list(zip(*[self.fetch_videos(x, sample_indices_fn=sample_indices_fn) for x in video_url_or_urls]))
/usr/local/lib/python3.10/site-packages/transformers/video_processing_utils.py:838: in fetch_videos
    return load_video(video_url_or_urls, backend=backend, sample_indices_fn=sample_indices_fn)
/usr/local/lib/python3.10/site-packages/transformers/video_utils.py:726: in load_video
    video, metadata = video_decoder(file_obj, sample_indices_fn, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

video_path = '/root/project/sample_demo_1.mp4'
sample_indices_fn = functools.partial(<bound method BaseVideoProcessor.sample_frames of LlavaOnevisionVideoProcessor {
  "do_convert_rgb": true,
  "do_normalize": true,
  "do_rescale": true,
  "do_resize": true,
  "do_sample_frames": false,
  "image_mean": [
    0.48145466,
    0.4578275,
    0.40821073
  ],
  "image_std": [
    0.26862954,
    0.26130258,
    0.27577711
  ],
  "resample": 3,
  "rescale_factor": 0.00392156862745098,
  "return_metadata": false,
  "size": {
    "height": 384,
    "width": 384
  },
  "video_processor_type": "LlavaOnevisionVideoProcessor"
}
>, return_tensors='pt', num_frames=2, do_convert_rgb=True, do_resize=True, size=SizeDict(height=384, width=384, longest_edge=None, shortest_edge=None, max_height=None, max_width=None), default_to_square=False, resample=3, do_rescale=True, rescale_factor=0.00392156862745098, do_normalize=True, image_mean=(0.48145466, 0.4578275, 0.40821073), image_std=(0.26862954, 0.26130258, 0.27577711), do_center_crop=None, do_pad=None, crop_size=None, data_format=None, fps=None, return_metadata=False)
kwargs = {}

    def read_video_torchvision(
        video_path: Union["URL", "Path"],
        sample_indices_fn: Callable,
        **kwargs,
    ):
        """
        Decode the video with torchvision decoder.
    
        Args:
            video_path (`str`):
                Path to the video file.
            sample_indices_fn (`Callable`, *optional*):
                A callable function that will return indices at which the video should be sampled. If the video has to be loaded using
                by a different sampling technique than provided by `num_frames` or `fps` arguments, one should provide their own `sample_indices_fn`.
                If not provided, simple uniform sampling with fps is performed.
                Example:
                def sample_indices_fn(metadata, **kwargs):
                    return np.linspace(0, metadata.total_num_frames - 1, num_frames, dtype=int)
    
        Returns:
            tuple[`torch.Tensor`, `VideoMetadata`]: A tuple containing:
                - Torch tensor of frames in RGB (shape: [num_frames, height, width, 3]).
                - `VideoMetadata` object.
        """
        warnings.warn(
            "Using `torchvision` for video decoding is deprecated and will be removed in future versions. "
            "Please use `torchcodec` instead."
        )
>       video, _, info = torchvision_io.read_video(
            video_path,
            start_pts=0.0,
            end_pts=None,
            pts_unit="sec",
            output_format="TCHW",
        )
E       AttributeError: module 'torchvision.io' has no attribute 'read_video'. Did you mean: 'read_file'?

/usr/local/lib/python3.10/site-packages/transformers/video_utils.py:538: AttributeError

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, I don't know when that was added, and indeed it shouldn't be there in the first place

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no worry, it was not you :-)

super().setUpClass()

@classmethod
Expand Down
Loading