Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
a3264332
Unverified
Commit
a3264332
authored
Jul 31, 2024
by
Raushan Turganbay
Committed by
GitHub
Jul 31, 2024
Browse files
LLaVA-NeXT: fix anyres shapes (#32314)
fix
parent
6e2d04e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
+2
-2
src/transformers/models/llava_next/modeling_llava_next.py
src/transformers/models/llava_next/modeling_llava_next.py
+1
-1
src/transformers/models/llava_next_video/modeling_llava_next_video.py
...mers/models/llava_next_video/modeling_llava_next_video.py
+1
-1
No files found.
src/transformers/models/llava_next/modeling_llava_next.py
View file @
a3264332
...
@@ -660,7 +660,7 @@ class LlavaNextForConditionalGeneration(LlavaNextPreTrainedModel):
...
@@ -660,7 +660,7 @@ class LlavaNextForConditionalGeneration(LlavaNextPreTrainedModel):
height
=
width
=
self
.
config
.
vision_config
.
image_size
//
self
.
config
.
vision_config
.
patch_size
height
=
width
=
self
.
config
.
vision_config
.
image_size
//
self
.
config
.
vision_config
.
patch_size
if
height
*
width
!=
base_image_feature
.
shape
[
0
]:
if
height
*
width
!=
base_image_feature
.
shape
[
0
]:
raise
ValueError
(
"The number of patches is not consistent with the image size."
)
raise
ValueError
(
"The number of patches is not consistent with the image size."
)
num_patch_
width
,
num_patch_
height
=
get_anyres_image_grid_shape
(
num_patch_
height
,
num_patch_
width
=
get_anyres_image_grid_shape
(
image_sizes
[
image_idx
],
image_sizes
[
image_idx
],
self
.
config
.
image_grid_pinpoints
,
self
.
config
.
image_grid_pinpoints
,
self
.
config
.
vision_config
.
image_size
,
self
.
config
.
vision_config
.
image_size
,
...
...
src/transformers/models/llava_next_video/modeling_llava_next_video.py
View file @
a3264332
...
@@ -704,7 +704,7 @@ class LlavaNextVideoForConditionalGeneration(LlavaNextVideoPreTrainedModel):
...
@@ -704,7 +704,7 @@ class LlavaNextVideoForConditionalGeneration(LlavaNextVideoPreTrainedModel):
height
=
width
=
self
.
config
.
vision_config
.
image_size
//
self
.
config
.
vision_config
.
patch_size
height
=
width
=
self
.
config
.
vision_config
.
image_size
//
self
.
config
.
vision_config
.
patch_size
if
height
*
width
!=
base_image_feature
.
shape
[
0
]:
if
height
*
width
!=
base_image_feature
.
shape
[
0
]:
raise
ValueError
(
"The number of patches is not consistent with the image size."
)
raise
ValueError
(
"The number of patches is not consistent with the image size."
)
num_patch_
width
,
num_patch_
height
=
get_anyres_image_grid_shape
(
num_patch_
height
,
num_patch_
width
=
get_anyres_image_grid_shape
(
image_sizes
[
image_idx
],
image_sizes
[
image_idx
],
self
.
config
.
image_grid_pinpoints
,
self
.
config
.
image_grid_pinpoints
,
self
.
config
.
vision_config
.
image_size
,
self
.
config
.
vision_config
.
image_size
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment