Skip to content

Commit b852ef7

Browse files
suiyoubithomasdhc
andauthored
Skip internvideo2 Test if not installed (#1089)
* Skip internvideo2 test if not installed. Signed-off-by: Ao Tang <aot@nvidia.com> * skip at file level Signed-off-by: Ao Tang <aot@nvidia.com> * Add the installation script Signed-off-by: Ao Tang <aot@nvidia.com> * Add copyright header to installation script and update .gitignore to include InternVideo2 dependency Signed-off-by: Ao Tang <aot@nvidia.com> --------- Signed-off-by: Ao Tang <aot@nvidia.com> Co-authored-by: Dong Hyuk Chang <thomaschang26@tutanota.com>
1 parent 4e4eccb commit b852ef7

File tree

5 files changed

+74
-13
lines changed

5 files changed

+74
-13
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,6 @@ data/
152152

153153
# Text Editor / IDE Files
154154
.vscode
155+
156+
# InternVideo2 dependency (cloned by installation script)
157+
InternVideo/
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# =============================================================================
17+
# InternVideo2 Installation Script
18+
# =============================================================================
19+
# This script installs the InternVideo2 dependency for the Curator project.
20+
# It clones the official InternVideo repository, applies necessary patches,
21+
# and integrates it into the project's dependency management system using uv.
22+
23+
# Verify that the script is being run from the correct directory
24+
# This ensures that relative paths in the script work correctly
25+
if [ "$(basename "$PWD")" != "Curator" ]; then
26+
echo "Please run this script from the Curator/ directory."
27+
exit 1
28+
fi
29+
30+
# Clone the official InternVideo repository from OpenGVLab
31+
# This is the source repository for the InternVideo2 model implementation
32+
git clone https://github.com/OpenGVLab/InternVideo.git;
33+
cd InternVideo; git checkout 09d872e5093296c6f36b8b3a91fc511b76433bf7;
34+
35+
# Apply a custom patch to the InternVideo2 codebase
36+
# This patch contains modifications needed for integration with NeMo Curator
37+
patch -p1 < ../external/intern_video2_multimodal.patch; cd ../

tests/models/test_internvideo2.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@
1818
from unittest.mock import MagicMock, Mock, patch
1919

2020
import numpy as np
21+
import pytest
2122
import torch
2223

23-
from nemo_curator.stages.video.embedding.internvideo2 import (
24-
InternVideo2EmbeddingStage,
25-
InternVideo2FrameCreationStage,
26-
)
24+
try:
25+
from nemo_curator.stages.video.embedding.internvideo2 import (
26+
InternVideo2EmbeddingStage,
27+
InternVideo2FrameCreationStage,
28+
)
29+
except ImportError:
30+
pytest.skip("InternVideo2 package not available", allow_module_level=True)
31+
2732
from nemo_curator.tasks.video import Clip, Video, VideoTask
2833

2934
# Create a random generator for consistent testing

tests/models/test_internvideo2_mm.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@
2121
import torch
2222
from easydict import EasyDict
2323

24-
from nemo_curator.models.internvideo2_mm import (
25-
BERT_MODEL_ID,
26-
INTERNVIDEO2_MODEL_FILE,
27-
INTERNVIDEO2_MODEL_ID,
28-
InternVideo2MultiModality,
29-
_InternVideo2Stage2Wrapper,
30-
_setup_internvideo2,
31-
)
24+
try:
25+
from nemo_curator.models.internvideo2_mm import (
26+
BERT_MODEL_ID,
27+
INTERNVIDEO2_MODEL_FILE,
28+
INTERNVIDEO2_MODEL_ID,
29+
InternVideo2MultiModality,
30+
_InternVideo2Stage2Wrapper,
31+
_setup_internvideo2,
32+
)
33+
except ImportError:
34+
pytest.skip("InternVideo2 package not available", allow_module_level=True)
3235

3336
# Create a random generator for consistent testing
3437
rng = np.random.default_rng(42)

tutorials/video/getting-started/video_split_clip_example.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,17 @@
2727
CosmosEmbed1EmbeddingStage,
2828
CosmosEmbed1FrameCreationStage,
2929
)
30-
from nemo_curator.stages.video.embedding.internvideo2 import InternVideo2EmbeddingStage, InternVideo2FrameCreationStage
30+
31+
try:
32+
from nemo_curator.stages.video.embedding.internvideo2 import (
33+
InternVideo2EmbeddingStage,
34+
InternVideo2FrameCreationStage,
35+
)
36+
except ImportError:
37+
print("InternVideo2 is not installed")
38+
InternVideo2EmbeddingStage = None
39+
InternVideo2FrameCreationStage = None
40+
3141
from nemo_curator.stages.video.filtering.clip_aesthetic_filter import ClipAestheticFilterStage
3242
from nemo_curator.stages.video.filtering.motion_filter import MotionFilterStage, MotionVectorDecodeStage
3343
from nemo_curator.stages.video.io.clip_writer import ClipWriterStage
@@ -159,6 +169,9 @@ def create_video_splitting_pipeline(args: argparse.Namespace) -> Pipeline: # no
159169
)
160170
)
161171
elif args.embedding_algorithm.startswith("internvideo2"):
172+
if InternVideo2FrameCreationStage is None:
173+
msg = "InternVideo2 is not installed, please consider installing it or using cosmos-embed1 instead."
174+
raise ValueError(msg)
162175
pipeline.add_stage(
163176
InternVideo2FrameCreationStage(
164177
model_dir=args.model_dir,

0 commit comments

Comments
 (0)