-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract text generation puts from forward inputs
- Loading branch information
1 parent
3211d16
commit 176c1e6
Showing
2 changed files
with
41 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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 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,17 @@ | ||
def extract_text_generation_inputs(inputs): | ||
if "pixel_values" in inputs: | ||
# image input | ||
text_generation_inputs = {"inputs": inputs["pixel_values"]} | ||
elif "input_values" in inputs: | ||
# speech input | ||
text_generation_inputs = {"inputs": inputs["input_values"]} | ||
elif "input_features" in inputs: | ||
# waveform input | ||
text_generation_inputs = {"inputs": inputs["input_features"]} | ||
elif "input_ids" in inputs: | ||
# text input | ||
text_generation_inputs = {"inputs": inputs["input_ids"]} | ||
else: | ||
raise ValueError("Could not find any valid text generation inputs.") | ||
|
||
return text_generation_inputs |