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
857d4e1c
Unverified
Commit
857d4e1c
authored
Jun 01, 2023
by
Adam Lewis
Committed by
GitHub
Jun 01, 2023
Browse files
rename DocumentQuestionAnsweringTool parameter input to match docstring (#23939)
rename encode input to match docstring
parent
91931882
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
src/transformers/tools/document_question_answering.py
src/transformers/tools/document_question_answering.py
+2
-2
No files found.
src/transformers/tools/document_question_answering.py
View file @
857d4e1c
...
@@ -46,13 +46,13 @@ class DocumentQuestionAnsweringTool(PipelineTool):
...
@@ -46,13 +46,13 @@ class DocumentQuestionAnsweringTool(PipelineTool):
super
().
__init__
(
*
args
,
**
kwargs
)
super
().
__init__
(
*
args
,
**
kwargs
)
def
encode
(
self
,
image
:
"Image"
,
question
:
str
):
def
encode
(
self
,
document
:
"Image"
,
question
:
str
):
task_prompt
=
"<s_docvqa><s_question>{user_input}</s_question><s_answer>"
task_prompt
=
"<s_docvqa><s_question>{user_input}</s_question><s_answer>"
prompt
=
task_prompt
.
replace
(
"{user_input}"
,
question
)
prompt
=
task_prompt
.
replace
(
"{user_input}"
,
question
)
decoder_input_ids
=
self
.
pre_processor
.
tokenizer
(
decoder_input_ids
=
self
.
pre_processor
.
tokenizer
(
prompt
,
add_special_tokens
=
False
,
return_tensors
=
"pt"
prompt
,
add_special_tokens
=
False
,
return_tensors
=
"pt"
).
input_ids
).
input_ids
pixel_values
=
self
.
pre_processor
(
image
,
return_tensors
=
"pt"
).
pixel_values
pixel_values
=
self
.
pre_processor
(
document
,
return_tensors
=
"pt"
).
pixel_values
return
{
"decoder_input_ids"
:
decoder_input_ids
,
"pixel_values"
:
pixel_values
}
return
{
"decoder_input_ids"
:
decoder_input_ids
,
"pixel_values"
:
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