Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add video support to NeVA LLM conversation data [VideoNeVA] #8220

Closed

Conversation

PannuMuthu
Copy link
Contributor

@PannuMuthu PannuMuthu commented Jan 23, 2024

What does this PR do ?

Refactors preprocess_multimodal to support video tokens in LLM conversation data

Collection: Multimodal - NeVA

Changelog

  • Adds videoneva_dataset.py and conversation.py to /nemo/collections/multimodal/data/
  • videoneva_dataset.py implements TarOrFolderVisualLoader (modified from neva_dataset.py), tokenize, and preprocess_multimodal
    • TarOrFolderVisualLoader is a modification of TarOrFolderImageLoader (from neva_dataset.py) which extends support to video files with the open_video function
    • tokenize is identical to neva_dataset.py implementation
    • preprocess_multimodal extends preprocess_multimodal from neva_dataset.py to include support for video tokens
  • videoneva/conversation.py is a modification of neva/conversation.py to include additional video-related constants

Usage

  • You can potentially add a usage example below

Jenkins CI

To run Jenkins, a NeMo User with write access must comment jenkins on the PR.

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

Pratyush Muthukumar and others added 6 commits January 25, 2024 09:42
Signed-off-by: Pratyush Muthukumar <pmuthukumar@nvidia.com>
for more information, see https://pre-commit.ci

Signed-off-by: Pratyush Muthukumar <pmuthukumar@nvidia.com>
Signed-off-by: Pratyush Muthukumar <pmuthukumar@nvidia.com>
Signed-off-by: Pratyush Muthukumar <pmuthukumar@nvidia.com>
for more information, see https://pre-commit.ci

Signed-off-by: Pratyush Muthukumar <pmuthukumar@nvidia.com>
Signed-off-by: Pratyush Muthukumar <pmuthukumar@nvidia.com>
@PannuMuthu PannuMuthu marked this pull request as ready for review January 25, 2024 17:42
@PannuMuthu PannuMuthu changed the title Add video support to preprocess_multimodal Add video support to NeVA LLM Conversation Data [VideoNeVA] Jan 25, 2024
@PannuMuthu PannuMuthu changed the title Add video support to NeVA LLM Conversation Data [VideoNeVA] Add video support to NeVA LLM conversation data [VideoNeVA] Jan 25, 2024
@PannuMuthu
Copy link
Contributor Author

@yaoyu-33

@@ -0,0 +1,221 @@
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

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

rename to video_neva_dataset

Copy link
Collaborator

Choose a reason for hiding this comment

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

similar, too many copy paste from image neva, re-use some of the components?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Removed tokenize because it is identical to neva_dataset.py implementation. preprocess_multimodal must be reimplemented in video_neva_dataset.py because of video token integration.

I have split TarOrFolderVisualLoader which processes images and videos together into TarOrFolderImageLoader and TarOrFolderVideoLoader, where TarOrFolderImageLoader is imported from neva_dataset.py and TarOrFolderVideoLoader is implemented in video_neva_dataset.py.

@@ -193,6 +193,7 @@ model:
data_path:
lazy_preprocess: True
is_multimodal: True
num_frames: 8
Copy link
Collaborator

Choose a reason for hiding this comment

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

set default to null and add a comment plz, similar above

@@ -0,0 +1,411 @@
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not reuse neva conversation.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, will reuse nemo.collections.multimodal.data.neva.conversation

Signed-off-by: Pratyush Muthukumar <pmuthukumar@nvidia.com>
Pratyush Muthukumar and others added 2 commits January 29, 2024 14:37
Signed-off-by: Pratyush Muthukumar <pmuthukumar@nvidia.com>
return None


def preprocess_multimodal(sources: dict, multimodal_cfg: dict, cur_token_len: int, use_plain: bool = False) -> Dict:
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't see where this class getting used yet. Is this a partial pr?

@PannuMuthu PannuMuthu marked this pull request as draft February 2, 2024 22:29
Copy link
Contributor

This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Feb 17, 2024
Copy link
Contributor

This PR was closed because it has been inactive for 7 days since being marked as stale.

@github-actions github-actions bot closed this Feb 25, 2024
@yaoyu-33 yaoyu-33 reopened this Apr 5, 2024
from torch.utils.data import Dataset, default_collate
from transformers import CLIPImageProcessor

import nemo.collections.multimodal.data.neva.conversation as conversation_lib

Check notice

Code scanning / CodeQL

Module is imported with 'import' and 'import from' Note

Module 'nemo.collections.multimodal.data.neva.conversation' is imported with both 'import' and 'import from'.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import copy

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'copy' is not used.
# See the License for the specific language governing permissions and
# limitations under the License.
import copy
import json

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'json' is not used.
# limitations under the License.
import copy
import json
import logging

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'logging' is not used.
import json
import logging
import os
import re

Check notice

Code scanning / CodeQL

Unused import Note

Import of 're' is not used.
from omegaconf import DictConfig
from PIL import Image
from torch.utils.data import Dataset, default_collate
from transformers import CLIPImageProcessor

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'CLIPImageProcessor' is not used.
from transformers import CLIPImageProcessor

import nemo.collections.multimodal.data.neva.conversation as conversation_lib
from nemo.collections.multimodal.data.clip.augmentations.augmentations import image_transform

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'image_transform' is not used.
Comment on lines +36 to +48
from nemo.collections.multimodal.data.neva.conversation import (
DEFAULT_BOS_TOKEN,
DEFAULT_EOS_TOKEN,
DEFAULT_IM_END_TOKEN,
DEFAULT_IM_START_TOKEN,
DEFAULT_IMAGE_PATCH_TOKEN,
DEFAULT_IMAGE_TOKEN,
DEFAULT_LABELS_TOKEN,
DEFAULT_PAD_TOKEN,
DEFAULT_SEPARATOR_TOKEN,
DEFAULT_SYSTEM_TOKEN,
DEFAULT_UNK_TOKEN,
)

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'DEFAULT_BOS_TOKEN' is not used.
Import of 'DEFAULT_EOS_TOKEN' is not used.
Import of 'DEFAULT_PAD_TOKEN' is not used.
Import of 'DEFAULT_SEPARATOR_TOKEN' is not used.
Import of 'DEFAULT_SYSTEM_TOKEN' is not used.
Import of 'DEFAULT_UNK_TOKEN' is not used.
Import of 'DEFAULT_LABELS_TOKEN' is not used.
DEFAULT_SYSTEM_TOKEN,
DEFAULT_UNK_TOKEN,
)
from nemo.collections.multimodal.data.neva.neva_dataset import TarOrFolderImageLoader

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'TarOrFolderImageLoader' is not used.
DEFAULT_UNK_TOKEN,
)
from nemo.collections.multimodal.data.neva.neva_dataset import TarOrFolderImageLoader
from nemo.collections.nlp.modules.common.megatron.utils import get_ltor_masks_and_position_ids

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'get_ltor_masks_and_position_ids' is not used.
@github-actions github-actions bot removed the stale label Jul 27, 2024
Copy link
Contributor

This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Aug 11, 2024
Copy link
Contributor

This PR was closed because it has been inactive for 7 days since being marked as stale.

@github-actions github-actions bot closed this Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants