Repository navigation
add FastVLM #4864
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
Open
yicycyc
wants to merge
9
commits into
PaddlePaddle:develop
Choose a base branch
from
yicycyc:feat/fastvlm
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add FastVLM #4864
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fe73e18
feat(fastvlm): add model support
yicycyc ea505d4
fix(fastvlm): address checkpoint and TP review issues
yicycyc 39a6221
fix(fastvlm): load official processor config
yicycyc bf2338f
fix(fastvlm): use native Paddle layer classes
yicycyc b7f8ea8
Merge remote-tracking branch 'upstream/develop' into merge/fastvlm
yicycyc d2bf13f
[Model] Add FastVLM multimodal template plugin
yicycyc 1ce4c0b
test(fastvlm): import implementation modules explicitly
yicycyc 18243f4
Merge remote-tracking branch 'upstream/develop' into merge/fastvlm
yicycyc c636d0d
Merge develop and reconcile fastvlm model registrations
yicycyc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Copyright (c) 2026 PaddlePaddle Authors. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
|
|
||
| import sys | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| from ...utils.lazy_import import _LazyModule | ||
|
|
||
| import_structure = { | ||
| "configuration": ["FastVLMConfig"], | ||
| "image_processor": ["FastVLMImageProcessor"], | ||
| "processor": ["FastVLMProcessor"], | ||
| "modeling": ["FastVLMModel", "FastVLMForCausalLM", "FastVLMForConditionalGeneration"], | ||
| "modeling_vision": ["FastVLMVisionModel"], | ||
| } | ||
|
|
||
| if TYPE_CHECKING: | ||
| from .configuration import FastVLMConfig | ||
| from .image_processor import FastVLMImageProcessor | ||
| from .modeling import ( | ||
| FastVLMForCausalLM, | ||
| FastVLMForConditionalGeneration, | ||
| FastVLMModel, | ||
| ) | ||
| from .modeling_vision import FastVLMVisionModel | ||
| from .processor import FastVLMProcessor | ||
| else: | ||
| sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], import_structure, module_spec=__spec__) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Copyright (c) 2026 PaddlePaddle Authors. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """FastVLM configuration.""" | ||
|
|
||
| from ..qwen2.configuration import Qwen2Config | ||
|
|
||
|
|
||
| class FastVLMConfig(Qwen2Config): | ||
| """Configuration for Apple FastVLM checkpoints based on LLaVA-Qwen2.""" | ||
|
|
||
| model_type = "llava_qwen2" | ||
|
|
||
| def __init__( | ||
| self, | ||
| mm_vision_tower="mobileclip_l_1024", | ||
| mm_hidden_size=3072, | ||
| mm_projector_type="mlp2x_gelu", | ||
| mm_patch_merge_type="flat", | ||
| image_aspect_ratio="pad", | ||
| image_token_index=-200, | ||
| unfreeze_mm_vision_tower=True, | ||
| tokenizer_model_max_length=8192, | ||
| tokenizer_padding_side="right", | ||
| vision_config=None, | ||
| **kwargs, | ||
| ): | ||
| super().__init__(**kwargs) | ||
| self.mm_vision_tower = mm_vision_tower | ||
| self.mm_hidden_size = mm_hidden_size | ||
| self.mm_projector_type = mm_projector_type | ||
| self.mm_patch_merge_type = mm_patch_merge_type | ||
| self.image_aspect_ratio = image_aspect_ratio | ||
| self.image_token_index = image_token_index | ||
| self.unfreeze_mm_vision_tower = unfreeze_mm_vision_tower | ||
| self.tokenizer_model_max_length = tokenizer_model_max_length | ||
| self.tokenizer_padding_side = tokenizer_padding_side | ||
| self.vision_config = vision_config | ||
|
|
||
|
|
||
| __all__ = ["FastVLMConfig"] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Copyright (c) 2026 PaddlePaddle Authors. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
|
||
| """Image preprocessing for FastVLM.""" | ||
|
|
||
| from transformers import CLIPImageProcessor | ||
|
|
||
| from ..image_processing_utils import PaddleImageProcessingMixin | ||
|
|
||
|
|
||
| class FastVLMImageProcessor(PaddleImageProcessingMixin, CLIPImageProcessor): | ||
| def __init__(self, image_size=1024, **kwargs): | ||
| kwargs.setdefault("do_resize", True) | ||
| kwargs.setdefault("size", {"shortest_edge": image_size}) | ||
| kwargs.setdefault("do_center_crop", True) | ||
| kwargs.setdefault("crop_size", {"height": image_size, "width": image_size}) | ||
| kwargs.setdefault("do_rescale", True) | ||
| kwargs.setdefault("rescale_factor", 1 / 255) | ||
| kwargs.setdefault("do_normalize", True) | ||
| kwargs.setdefault("image_mean", [0.0, 0.0, 0.0]) | ||
| kwargs.setdefault("image_std", [1.0, 1.0, 1.0]) | ||
| super().__init__(**kwargs) | ||
|
|
||
|
|
||
| __all__ = ["FastVLMImageProcessor"] |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.