Skip to content

Conversation

@Isotr0py
Copy link
Collaborator

@Isotr0py Isotr0py commented May 13, 2025

What does this PR do?

Fixes #38098 (issue)

  • Just notice there is no feature extractor test for Phi-4-MM, let me add one for it, so mark this as draft currently.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

Signed-off-by: Isotr0py <2037008807@qq.com>
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Isotr0py added 2 commits May 13, 2025 23:00
Signed-off-by: Isotr0py <2037008807@qq.com>
@Isotr0py Isotr0py marked this pull request as ready for review May 13, 2025 15:01
@github-actions github-actions bot requested review from Rocketknight1 and ydshieh May 13, 2025 15:02
Comment on lines +162 to +171
speech_inputs = [floats_list((1, x))[0] for x in range(800, 1400, 200)]
np_speech_inputs = [np.asarray(speech_input) for speech_input in speech_inputs]
pt_speech_inputs = [torch.tensor(speech_input) for speech_input in speech_inputs]

# Test feature size
input_features = feature_extractor(np_speech_inputs, return_tensors="np").audio_input_features
max_audio_len = (1200 - feature_extractor.win_length) // feature_extractor.hop_length + 1
self.assertTrue(input_features.ndim == 3)
self.assertTrue(input_features.shape[-1] == feature_extractor.feature_size)
self.assertTrue(input_features.shape[-2] == max_audio_len)
Copy link
Collaborator Author

@Isotr0py Isotr0py May 13, 2025

Choose a reason for hiding this comment

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

Have confirmed this test can cover the original bug without fix, so I didn't add extra regression test:

>               masked_frames = frames[to_mask_batch_idxs, offset_idx:max_idx].masked_fill_(mask, 0)
E               RuntimeError: The size of tensor a (3) must match the size of tensor b (4) at non-singleton dimension 1

src/transformers/models/phi4_multimodal/feature_extraction_phi4_multimodal.py:312: RuntimeError
================================================================== short test summary info ==================================================================
FAILED tests/models/phi4_multimodal/test_feature_extractor_phi4_multimodal.py::Phi4MultimodalFeatureExtractionTest::test_call - RuntimeError: The size of tensor a (3) must match the size of tensor b (4) at non-singleton dimension 1

Signed-off-by: Isotr0py <2037008807@qq.com>
@Rocketknight1
Copy link
Member

cc @zucchini-nlp @eustlb

@ydshieh ydshieh removed their request for review May 16, 2025 15:51
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

Thanks, let's be explicit as python can hold surprises!

Isotr0py and others added 2 commits May 26, 2025 20:28
…4_multimodal.py

Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
@Isotr0py Isotr0py enabled auto-merge (squash) May 26, 2025 12:29
@Isotr0py Isotr0py merged commit bff3267 into huggingface:main May 26, 2025
11 checks passed
@Isotr0py Isotr0py deleted the fix-phi4mm-audio branch May 26, 2025 13:41
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.

[Bug] Phi-4-multimodal audio processor failed to process multiple audios with close length

4 participants