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
ec344b56
Unverified
Commit
ec344b56
authored
Apr 15, 2024
by
amyeroberts
Committed by
GitHub
Apr 15, 2024
Browse files
Separate out kwargs in processor (#30193)
* Separate out kwargs in processor * Fix up
parent
fc8eda36
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
src/transformers/models/clip/processing_clip.py
src/transformers/models/clip/processing_clip.py
+8
-2
No files found.
src/transformers/models/clip/processing_clip.py
View file @
ec344b56
...
...
@@ -92,15 +92,21 @@ class CLIPProcessor(ProcessorMixin):
`None`).
- **pixel_values** -- Pixel values to be fed to a model. Returned when `images` is not `None`.
"""
tokenizer_kwargs
,
image_processor_kwargs
=
{},
{}
if
kwargs
:
tokenizer_kwargs
=
{
k
:
v
for
k
,
v
in
kwargs
.
items
()
if
k
not
in
self
.
image_processor
.
_valid_processor_keys
}
image_processor_kwargs
=
{
k
:
v
for
k
,
v
in
kwargs
.
items
()
if
k
in
self
.
image_processor
.
_valid_processor_keys
}
if
text
is
None
and
images
is
None
:
raise
ValueError
(
"You have to specify either text or images. Both cannot be none."
)
if
text
is
not
None
:
encoding
=
self
.
tokenizer
(
text
,
return_tensors
=
return_tensors
,
**
kwargs
)
encoding
=
self
.
tokenizer
(
text
,
return_tensors
=
return_tensors
,
**
tokenizer_
kwargs
)
if
images
is
not
None
:
image_features
=
self
.
image_processor
(
images
,
return_tensors
=
return_tensors
,
**
kwargs
)
image_features
=
self
.
image_processor
(
images
,
return_tensors
=
return_tensors
,
**
image_processor_
kwargs
)
if
text
is
not
None
and
images
is
not
None
:
encoding
[
"pixel_values"
]
=
image_features
.
pixel_values
...
...
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