Skip to content

Conversation

@Cathy0908
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Cathy0908, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the multimodal processing capabilities by introducing new mappers for advanced image analysis. It enables the generation of detailed image tags using Visual Language Models and facilitates human keypoint detection through MMPose models, leveraging mmdeploy for robust model integration. These additions aim to provide more comprehensive and automated metadata extraction from visual data.

Highlights

  • New Image Tagging with VLM: Introduced a new ImageTaggingVLMMapper that leverages Visual Language Models (VLMs) to generate descriptive tags for images. This mapper supports both API-based and vLLM-based models, enhancing the ability to extract rich metadata from visual content.
  • New MMPose Mapper for Keypoint Detection: Added a MMPoseMapper to perform human keypoint detection using MMPose models. This mapper integrates with mmdeploy for efficient model inference and can extract detailed pose information, including keypoints, bounding boxes, and scores, with optional visualization capabilities.
  • MMLab Model Integration: Integrated mmdeploy to support MMLab models, providing a generic wrapper (MMLabModel) and a preparation function (prepare_mmlab_model) to load and utilize these models within the framework.
  • Minor Logging Refinement: Updated several files to reformat a vLLM tensor parallel size logging message, making it more concise and on a single line.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for mmpose and VLM-based image tagging by adding two new mappers, MMPoseMapper and ImageTaggingVLMMapper, along with supporting utility functions and tests. My review focuses on improving correctness, performance, and test quality. Key findings include a bug in prompt construction for the VLM mapper, inefficient batch handling in the mmpose mapper, and several issues in the new tests such as hardcoded paths and reliance on external models, which should be mocked for better reliability and portability.

Comment on lines +31 to +140
def test(self):
ds_list = [{
'images': [self.img1_path]
}, {
'images': [self.img2_path]
}, {
'images': [self.img3_path]
}]
tgt_list = [{
'images': [self.img1_path],
Fields.meta: {
MetaKeys.image_tags: [[
'bed', 'pillow', 'mattress', 'bedroom', 'home', 'comfort', 'sleeping', 'house']]},
}, {
'images': [self.img2_path],
Fields.meta: {
MetaKeys.image_tags: [[
'bus', 'advertisement', 'street scene', 'city life', 'tour bus',
'travel service', 'urban environment', 'local transportation', 'daylight']]},
}, {
'images': [self.img3_path],
Fields.meta: {
MetaKeys.image_tags: [[
'urban', 'alley', 'rainy-day', 'building', 'person', 'umbrella', 'sidewalk',
'black-and-white', '/blackandwhite', 'shoe', 'clothing', 'architecture',
'trees', 'reflection', 'exploration']]},
}]
op = ImageTaggingVLMMapper(
api_or_hf_model="Qwen2.5-VL-7B-Instruct",
is_api_model=False,
model_params={"tensor_parallel_size": 1}
)
self._run_image_tagging_vlm_mapper(op, ds_list, tgt_list)

def test_no_images(self):
ds_list = [{
'images': []
}, {
'images': [self.img2_path]
}]
tgt_list = [{
'images': [],
Fields.meta: {
MetaKeys.image_tags: [[]]},
}, {
'images': [self.img2_path],
Fields.meta: {
MetaKeys.image_tags: [[
'bus', 'advertisement', 'street scene', 'city life', 'tour bus',
'travel service', 'urban environment', 'local transportation', 'daylight']]},
}]
op = ImageTaggingVLMMapper(
api_or_hf_model="Qwen2.5-VL-7B-Instruct",
is_api_model=False,
model_params={"tensor_parallel_size": 1}
)
self._run_image_tagging_vlm_mapper(op, ds_list, tgt_list)

def test_api_model(self):

ds_list = [{
'images': []
}, {
'images': [self.img2_path]
}]
tgt_list = [{
'images': [],
Fields.meta: {
MetaKeys.image_tags: [[]]},
}, {
'images': [self.img2_path],
Fields.meta: {
MetaKeys.image_tags: [[
'bus', 'advertisement', 'street scene', 'city life', 'tour bus',
'travel service', 'urban environment', 'local transportation', 'daylight']]},
}]

op = ImageTaggingVLMMapper(
api_or_hf_model='qwen2.5-vl-3b-instruct',
is_api_model=True,
)
self._run_image_tagging_vlm_mapper(op, ds_list, tgt_list)

def test_specify_tag_fieldl(self):
tag_field_name = 'my_tags'

ds_list = [{
'images': []
}, {
'images': [self.img2_path]
}]
tgt_list = [{
'images': [],
Fields.meta: {
tag_field_name: [[]]},
}, {
'images': [self.img2_path],
Fields.meta: {
tag_field_name: [[
'bus', 'advertisement', 'street scene', 'city life', 'tour bus',
'travel service', 'urban environment', 'local transportation', 'daylight']]},
}]

op = ImageTaggingVLMMapper(
api_or_hf_model="Qwen2.5-VL-7B-Instruct",
is_api_model=False,
tag_field_name=tag_field_name,
model_params={"tensor_parallel_size": 1}
)
self._run_image_tagging_vlm_mapper(op, ds_list, tgt_list)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

These tests are implemented as integration tests that rely on real model inference and external API calls. This makes them slow, non-deterministic, and dependent on specific hardware (GPU) and environment setup (API keys). Unit tests should be fast, deterministic, and isolated. Please refactor these tests to use mocking to simulate the model's output, which will make them more reliable and suitable for a CI/CD pipeline.

Comment on lines 26 to 62
def test_mmpose_mapper(self):
data_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'data')
img1 = os.path.join(data_path, 'img3.jpg')
img2 = os.path.join(data_path, 'img8.jpg')

base_dir = '/mnt/workspace/mmdeploy/'
deploy_cfg = base_dir + 'configs/mmpose/pose-detection_onnxruntime_static.py'
model_cfg = base_dir + 'td-hm_hrnet-w32_8xb64-210e_coco-256x192.py'
backend_model = [base_dir + 'mmdeploy_models/mmpose/ort/end2end.onnx']

ds_list = [{
'text': f'{SpecialTokens.image}a photo',
'images': [img2]
}, {
'text': f'{SpecialTokens.image}a photo, a women with an umbrella',
'images': [img1]
}]
dataset = Dataset.from_list(ds_list)

visualization_dir=os.path.join(self.tmp_dir, 'vis_outs')
op = MMPoseMapper(
deploy_cfg=deploy_cfg,
model_cfg=model_cfg,
model_files=backend_model,
visualization_dir=visualization_dir
)

dataset = dataset.map(op.process, with_rank=True)
dataset_list = dataset.to_list()

for out in dataset_list:
pose_info = out[Fields.meta][MetaKeys.pose_info][0]
self.assertEqual(np.array(pose_info['bbox_scores']), (1, ))
self.assertEqual(np.array(pose_info['bboxes']).shape, (1, 4))
self.assertEqual(np.array(pose_info['keypoint_names']).shape, (17, ))
self.assertEqual(np.array(pose_info['keypoint_scores'][0]).shape, (17, ))
self.assertEqual(np.array(pose_info['keypoints'][0]).shape, (17, 2))
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This test relies on a real mmpose model and specific model files, making it an integration test. This approach is slow, brittle, and has external dependencies. For a unit test, you should mock the model calls and verify that the mapper processes the mocked output correctly. This will lead to faster and more reliable tests.

@yxdyc yxdyc requested review from HYLcool and Qirui-jiao and removed request for Qirui-jiao October 24, 2025 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant