ydshieh
commited on
Commit
·
49030fb
1
Parent(s):
dbe1403
update 3
Browse files
run_image_captioning_flax_reduced.py
CHANGED
@@ -504,6 +504,10 @@ def main():
|
|
504 |
"Decoder Config: Either a pretrained config or a model location for decoder is required."
|
505 |
)
|
506 |
|
|
|
|
|
|
|
|
|
507 |
config = VisionEncoderDecoderConfig.from_encoder_decoder_configs(encoder_config, decoder_config)
|
508 |
model = FlaxVisionEncoderDecoderModel.from_encoder_decoder_pretrained(
|
509 |
encoder_pretrained_model_name_or_path=model_args.encoder_model_name_or_path,
|
@@ -544,7 +548,7 @@ def main():
|
|
544 |
"You are instantiating a new tokenizer from scratch. This is not supported by this script."
|
545 |
"You can do it from another script, save it, and load it from here, using --tokenizer_name."
|
546 |
)
|
547 |
-
tokenizer.pad_token = tokenizer.convert_ids_to_tokens(config.pad_token_id)
|
548 |
|
549 |
# Preprocessing the datasets.
|
550 |
# We need to tokenize inputs and targets.
|
|
|
504 |
"Decoder Config: Either a pretrained config or a model location for decoder is required."
|
505 |
)
|
506 |
|
507 |
+
# GPT2 only has eos token but not pad token
|
508 |
+
if decoder_config.pad_token_id is None:
|
509 |
+
decoder_config.pad_token_id = decoder_config.eos_token_id
|
510 |
+
|
511 |
config = VisionEncoderDecoderConfig.from_encoder_decoder_configs(encoder_config, decoder_config)
|
512 |
model = FlaxVisionEncoderDecoderModel.from_encoder_decoder_pretrained(
|
513 |
encoder_pretrained_model_name_or_path=model_args.encoder_model_name_or_path,
|
|
|
548 |
"You are instantiating a new tokenizer from scratch. This is not supported by this script."
|
549 |
"You can do it from another script, save it, and load it from here, using --tokenizer_name."
|
550 |
)
|
551 |
+
tokenizer.pad_token = tokenizer.convert_ids_to_tokens(config.decoder.pad_token_id)
|
552 |
|
553 |
# Preprocessing the datasets.
|
554 |
# We need to tokenize inputs and targets.
|