Repository navigation
Fix! #50430
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
Fix! #50430
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ | |
| is_torch_available, | ||
| is_vision_available, | ||
| ) | ||
| from transformers.audio_utils import load_audio | ||
| from transformers.testing_utils import ( | ||
| Expectations, | ||
| cleanup, | ||
|
|
@@ -41,7 +42,6 @@ | |
| slow, | ||
| torch_device, | ||
| ) | ||
| from transformers.utils import is_torchcodec_available | ||
|
|
||
| from ...generation.test_utils import GenerationTesterMixin | ||
| from ...test_configuration_common import ConfigTester | ||
|
|
@@ -57,10 +57,6 @@ | |
| from PIL import Image | ||
|
|
||
|
|
||
| if is_torchcodec_available(): | ||
| import torchcodec | ||
|
|
||
|
|
||
| class Phi4MultimodalModelTester: | ||
| def __init__( | ||
| self, | ||
|
|
@@ -291,9 +287,8 @@ def setUp(self): | |
| self.assistant_token = "<|assistant|>" | ||
| self.end_token = "<|end|>" | ||
| self.image = Image.open(requests.get(self.image_url, stream=True).raw) | ||
| audio_bytes = requests.get(self.audio_url, stream=True).raw.data | ||
| samples = torchcodec.decoders.AudioDecoder(audio_bytes).get_all_samples() | ||
| self.audio, self.sampling_rate = samples.data, samples.sample_rate | ||
| self.sampling_rate = 16000 | ||
| self.audio = load_audio(self.audio_url, sampling_rate=self.sampling_rate) | ||
|
Comment on lines
-294
to
+296
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Instead i fix it here to load using out utils |
||
|
|
||
| cleanup(torch_device, gc_collect=True) | ||
|
|
||
|
|
@@ -306,7 +301,7 @@ def test_text_only_generation(self): | |
| ) | ||
|
|
||
| prompt = f"{self.user_token}What is the answer for 1+1? Explain it.{self.end_token}{self.assistant_token}" | ||
| inputs = self.processor(prompt, images=None, return_tensors="pt").to(torch_device) | ||
| inputs = self.processor(text=prompt, images=None, return_tensors="pt").to(torch_device) | ||
|
|
||
| output = model.generate( | ||
| **inputs, | ||
|
|
@@ -326,7 +321,7 @@ def test_vision_text_generation(self): | |
| ) | ||
|
|
||
| prompt = f"{self.user_token}<|image|>What is shown in this image?{self.end_token}{self.assistant_token}" | ||
| inputs = self.processor(prompt, images=self.image, return_tensors="pt").to(torch_device) | ||
| inputs = self.processor(text=prompt, images=self.image, return_tensors="pt").to(torch_device) | ||
|
|
||
| output = model.generate( | ||
| **inputs, | ||
|
|
@@ -360,7 +355,7 @@ def test_multi_image_vision_text_generation(self): | |
| placeholder += "<|image|>" | ||
|
|
||
| prompt = f"{self.user_token}{placeholder}Summarize the deck of slides.{self.end_token}{self.assistant_token}" | ||
| inputs = self.processor(prompt, images, return_tensors="pt").to(torch_device) | ||
| inputs = self.processor(text=prompt, images=images, return_tensors="pt").to(torch_device) | ||
|
|
||
| output = model.generate( | ||
| **inputs, | ||
|
|
@@ -380,9 +375,9 @@ def test_audio_text_generation(self): | |
| ) | ||
|
|
||
| prompt = f"{self.user_token}<|audio|>What is happening in this audio?{self.end_token}{self.assistant_token}" | ||
| inputs = self.processor(prompt, audio=self.audio, sampling_rate=self.sampling_rate, return_tensors="pt").to( | ||
| torch_device | ||
| ) | ||
| inputs = self.processor( | ||
| text=prompt, audio=self.audio, sampling_rate=self.sampling_rate, return_tensors="pt" | ||
| ).to(torch_device) | ||
|
|
||
| output = model.generate( | ||
| **inputs, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uses
image_placeholder_tokeninstead ofimage_tokenThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm maybe we could introduce an alias instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they also have an
image_tokenbut used for different purposes 😭There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crap lol