Skip to content

Commit 489eac6

Browse files
suiyoubithomasdhc
andauthored
Add iv2 install guide and guard import (#1112)
* Add iv2 install guide and guard import Signed-off-by: Ao Tang <[email protected]> * Placeholder commit to run tests Signed-off-by: Dong Hyuk Chang <[email protected]> * Test removing gitignore changes Signed-off-by: Dong Hyuk Chang <[email protected]> * Add InternVideo to pythonpath Signed-off-by: Dong Hyuk Chang <[email protected]> * Try timeout on pytest Signed-off-by: Dong Hyuk Chang <[email protected]> * Reduce timeout for test Signed-off-by: Dong Hyuk Chang <[email protected]> * Further reduce pytest timeout Signed-off-by: Dong Hyuk Chang <[email protected]> * Remove Internvideo gitignore for cpu unit test Signed-off-by: Dong Hyuk Chang <[email protected]> --------- Signed-off-by: Ao Tang <[email protected]> Signed-off-by: Dong Hyuk Chang <[email protected]> Co-authored-by: Dong Hyuk Chang <[email protected]> Co-authored-by: Dong Hyuk Chang <[email protected]>
1 parent 7a0208c commit 489eac6

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

.github/workflows/cicd-main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ jobs:
158158
- name: Run tests ${{ matrix.folder }} (CPU)
159159
timeout-minutes: 20
160160
run: |
161-
cd InternVideo && patch -p1 < ../external/intern_video2_multimodal.patch && cd ..
161+
cd InternVideo && patch -p1 < ../external/intern_video2_multimodal.patch && cd .. && sed -i "/InternVideo/d" .gitignore
162162
uv sync --link-mode copy --locked --extra audio_cpu --extra text_cpu --extra video_cpu --group test
163163
uv add InternVideo/InternVideo2/multi_modality
164164
uv run coverage run --branch --source=nemo_curator -m pytest -v tests/${{ matrix.folder }} -m "not gpu"

.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 ../

tutorials/video/getting-started/video_split_clip_example.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,18 @@
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+
41+
3142
from nemo_curator.stages.video.filtering.clip_aesthetic_filter import ClipAestheticFilterStage
3243
from nemo_curator.stages.video.filtering.motion_filter import MotionFilterStage, MotionVectorDecodeStage
3344
from nemo_curator.stages.video.io.clip_writer import ClipWriterStage
@@ -159,6 +170,9 @@ def create_video_splitting_pipeline(args: argparse.Namespace) -> Pipeline: # no
159170
)
160171
)
161172
elif args.embedding_algorithm.startswith("internvideo2"):
173+
if InternVideo2FrameCreationStage is None:
174+
msg = "InternVideo2 is not installed, please consider installing it or using cosmos-embed1 instead."
175+
raise ValueError(msg)
162176
pipeline.add_stage(
163177
InternVideo2FrameCreationStage(
164178
model_dir=args.model_dir,

0 commit comments

Comments
 (0)