Fixing issue with video loading for Gemma 4 with relative paths#9201
Merged
Jintao-Huang merged 1 commit intoApr 25, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds logic to resolve video and audio file paths using ROOT_IMAGE_DIR to ensure absolute paths are available for model-specific templates. The reviewer suggested refactoring the code to eliminate duplication between the video and audio path resolution loops.
Collaborator
|
thanks! |
Jintao-Huang
approved these changes
Apr 25, 2026
Collaborator
|
There is also the case where the value is base64-encoded. Could you fix this by referencing the handling here: ms-swift/swift/template/vision_utils.py Line 104 in 514ce7c |
Collaborator
|
Never mind, I'll open a PR to fix it. |
Merged
Contributor
Author
Sorry just saw it now, thanks again ! |
Jintao-Huang
pushed a commit
that referenced
this pull request
Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR type
PR information
When using datasets with relative media paths and
--root_image_dir, video and audio file paths are not resolved to absolute paths before being passed to model-specific templates. Image paths are correctly resolved via_load_image, but video and audio paths are passed as raw strings.This causes a
FileNotFoundErrorfor models like Gemma 4 whose templates delegate media loading to the HuggingFace processor, since the processor receives the unresolved relative path.This fix adds path resolution for
inputs.videosandinputs.audiosinTemplate._preprocess_media(swift/template/base.py), matching the existing behavior for images. A relative path is resolved againstroot_image_dironly when:root_image_diris setExperiment results
Verified that Gemma 4 video fine-tuning with relative video paths in the dataset and
--root_image_dircorrectly loads videos after this fix, where previously it raisedFileNotFoundError.