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

Fix video batching to videollava #32139

Merged
merged 8 commits into from
Jul 23, 2024
Merged

Fix video batching to videollava #32139

merged 8 commits into from
Jul 23, 2024

Conversation

merveenoyan
Copy link
Contributor

cc @zucchini-nlp works with no problems

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

Copy link
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

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

Thanks ❤️

Can we activate tests, it is being skipped now for PIL inputs?

@merveenoyan
Copy link
Contributor Author

@zucchini-nlp one thing confused me, you are passing numpy tests but don't pass numpify=True when creating dummy inputs (also they pass the assertion of being numpy arrays) I couldn't make any change to the numpy test to make it for PIL

@zucchini-nlp
Copy link
Member

Yes, I made bad decision when constructing tests tailoring only for torch and numpy. This one has better dummy video preparation, can copy from it maybe

def prepare_video_inputs(self, equal_resolution=False, numpify=False, torchify=False):
images = prepare_image_inputs(
batch_size=self.batch_size,
num_channels=self.num_channels,
min_resolution=self.min_resolution,
max_resolution=self.max_resolution,
equal_resolution=equal_resolution,
numpify=numpify,
torchify=torchify,
)
# let's simply copy the frames to fake a long video-clip
if numpify or torchify:
videos = []
for image in images:
if numpify:
video = image[None, ...].repeat(8, 0)
else:
video = image[None, ...].repeat(8, 1, 1, 1)
videos.append(video)
else:
videos = []
for pil_image in images:
videos.append([pil_image] * 8)
return videos

@merveenoyan merveenoyan requested a review from zucchini-nlp July 23, 2024 09:27
Copy link
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

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

Great, thanks!

@zucchini-nlp zucchini-nlp requested a review from amyeroberts July 23, 2024 09:49
Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

FWIW - I think the current "numpify" and "torchify" logic is pretty bad and repeated everywhere. We should look into making this clearer and consolidate in the future!

@merveenoyan merveenoyan merged commit 9ced33c into main Jul 23, 2024
22 checks passed
@merveenoyan merveenoyan deleted the fix-videollava-batching branch July 23, 2024 10:23
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.

4 participants