-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Add Florence2 support #31506
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
Closed
Closed
Add Florence2 support #31506
Changes from 23 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
b7e3311
add florence2 config
D4ve-R 3adc633
add florence2 processing
D4ve-R b4cb3d6
fix florence2 processing, add image_utils.ChannelDimension
D4ve-R 73041ba
fix florence2 processing, add missing tokenizers
D4ve-R 1ce7813
add florence2 modeling
D4ve-R c2221a2
add florence2 __init__.py
D4ve-R 6d1606e
make fixup
D4ve-R eaa2e7b
fix florence2 modeling, rm einops.rearrange dep
D4ve-R 492d30f
fix florence2 config, make fixup
D4ve-R 5b2737b
fix florence2 processing, make fixup
D4ve-R 7cef9d9
fix florence2 processing, make repo-consistency
D4ve-R 8875899
fix processing, add PILImageResampling
D4ve-R 86d0862
fix import of optional dependencies
D4ve-R 3765e73
add florence2 to models.__init__
D4ve-R 3f915bd
add florence2 to transformers.__init__
D4ve-R bdb3706
make fix-copies
D4ve-R 2d81135
fix formatting & typo
D4ve-R e9f86d0
fix __init__s & dummies
D4ve-R 172a1dd
add tests florence2 processing
D4ve-R 087ef0e
add tests florence2 modeling
D4ve-R fb234ef
fix tests florence2 processign vocabfile
D4ve-R 0a615ba
fix rm import Florence2PostProcessor
D4ve-R 26e1c23
fix rm unnecessary imports
D4ve-R f11c993
fix processing PILImageResampling
D4ve-R 311da9c
fix make repo-consistency error
D4ve-R b429814
update tests
D4ve-R 3d67beb
rename folders
D4ve-R 8b88ca7
fix folder renaming
D4ve-R 299670b
fix florence2 modeling, copy DropPath from beit
D4ve-R 689ad98
update Florence2DropPath
D4ve-R 6b7feb6
update Florence2Sequential
D4ve-R 3addc02
update modeling_florence2, add model-prefix
D4ve-R 0f624ac
update modeling_florence2, add DaViT prefixes
D4ve-R 880811f
fix base_model_prefix
D4ve-R 4069145
fix missing variables
D4ve-R 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,6 +86,7 @@ | |
| fastspeech2_conformer, | ||
| flaubert, | ||
| flava, | ||
| florence, | ||
| fnet, | ||
| focalnet, | ||
| fsmt, | ||
|
|
||
|
D4ve-R marked this conversation as resolved.
|
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,84 @@ | ||
| # Copyright 2024 The HuggingFace Team. 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. | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| from ...utils import ( | ||
| OptionalDependencyNotAvailable, | ||
| _LazyModule, | ||
| is_torch_available, | ||
| is_vision_available, | ||
| ) | ||
|
|
||
|
|
||
| _import_structure = { | ||
| "configuration_florence2": [ | ||
| "Florence2Config", | ||
| "Florence2VisionConfig", | ||
| ], | ||
| } | ||
|
|
||
| try: | ||
| if not is_vision_available(): | ||
| raise OptionalDependencyNotAvailable() | ||
| except OptionalDependencyNotAvailable: | ||
| pass | ||
| else: | ||
| _import_structure["processing_florence2"] = ["Florence2Processor"] | ||
|
|
||
|
|
||
| try: | ||
| if not is_torch_available(): | ||
| raise OptionalDependencyNotAvailable() | ||
| except OptionalDependencyNotAvailable: | ||
| pass | ||
| else: | ||
| _import_structure["modeling_florence2"] = [ | ||
| "Florence2ForConditionalGeneration", | ||
| "Florence2PreTrainedModel", | ||
| "Florence2VisionModel", | ||
| "Florence2VisionModelWithProjection", | ||
| ] | ||
|
|
||
|
|
||
| if TYPE_CHECKING: | ||
| from .configuration_florence2 import ( | ||
| Florence2Config, | ||
| Florence2VisionConfig, | ||
| ) | ||
|
|
||
| try: | ||
| if not is_vision_available(): | ||
| raise OptionalDependencyNotAvailable() | ||
| except OptionalDependencyNotAvailable: | ||
| pass | ||
| else: | ||
| from .processing_florence2 import Florence2Processor | ||
|
|
||
| try: | ||
| if not is_torch_available(): | ||
| raise OptionalDependencyNotAvailable() | ||
| except OptionalDependencyNotAvailable: | ||
| pass | ||
| else: | ||
| from .modeling_florence2 import ( | ||
| Florence2ForConditionalGeneration, | ||
| Florence2PreTrainedModel, | ||
| Florence2VisionModel, | ||
| Florence2VisionModelWithProjection, | ||
| ) | ||
|
|
||
| else: | ||
| import sys | ||
|
|
||
| sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure) |
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.