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
20e54e49
Unverified
Commit
20e54e49
authored
Apr 14, 2023
by
amyeroberts
Committed by
GitHub
Apr 14, 2023
Browse files
Indexing fix - CLIP checkpoint conversion (#22776)
* Indexing fix - CLIP checkpoint conversion * Fix up
parent
895ae3b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
src/transformers/models/clip/convert_clip_original_pytorch_to_hf.py
...ormers/models/clip/convert_clip_original_pytorch_to_hf.py
+3
-3
No files found.
src/transformers/models/clip/convert_clip_original_pytorch_to_hf.py
View file @
20e54e49
...
...
@@ -127,9 +127,9 @@ def convert_clip_checkpoint(checkpoint_path, pytorch_dump_folder_path, config_pa
input_ids
=
torch
.
arange
(
0
,
77
).
unsqueeze
(
0
)
pixel_values
=
torch
.
randn
(
1
,
3
,
224
,
224
)
hf_
logits_per_image
,
hf_logits_per_text
=
hf_model
(
input_ids
=
input_ids
,
pixel_values
=
pixel_values
,
return_dict
=
Tru
e
)[
1
:
3
]
hf_
outputs
=
hf_model
(
input_ids
=
input_ids
,
pixel_values
=
pixel_values
,
return_dict
=
True
)
hf_logits_per_image
=
hf_outputs
.
logits_per_imag
e
hf_logits_per_text
=
hf_outputs
.
logits_per_text
pt_logits_per_image
,
pt_logits_per_text
=
pt_model
(
pixel_values
,
input_ids
)
assert
torch
.
allclose
(
hf_logits_per_image
,
pt_logits_per_image
,
atol
=
1e-3
)
...
...
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