diff --git a/config-eval.yaml b/config-eval.yaml index 9dc286e..77586b4 100644 --- a/config-eval.yaml +++ b/config-eval.yaml @@ -5,4 +5,7 @@ validation_dataset_split: "train" has_metadata: False print_output: True output_file_dir: "../../gonito-outs" -test_name: "fine-tuned-test" \ No newline at end of file +test_name: "fine-tuned-test" +image_size: [1920, 2560] +use_enc_dec_config: False +max_dec_length: 768 \ No newline at end of file diff --git a/donut-eval.py b/donut-eval.py index 5a03d45..42490c2 100644 --- a/donut-eval.py +++ b/donut-eval.py @@ -15,15 +15,15 @@ from sconf import Config def main(config): - # image_size = [1920, 2560] - # config_vision = VisionEncoderDecoderConfig.from_pretrained(config.pretrained_model_path) - # config_vision.encoder.image_size = image_size # (height, width) - # config_vision.decoder.max_length = 768 + if config.use_enc_dec_config: + config_vision = VisionEncoderDecoderConfig.from_pretrained(config.pretrained_model_path) + config_vision.encoder.image_size = config.image_size # (height, width) + config_vision.decoder.max_length = config.max_dec_length processor = DonutProcessor.from_pretrained(config.pretrained_processor_path) model = VisionEncoderDecoderModel.from_pretrained(config.pretrained_model_path) - # processor.image_processor.size = image_size[::-1] # should be (width, height) + processor.image_processor.size = config.image_size[::-1] # should be (width, height) processor.image_processor.do_align_long_axis = False dataset = load_dataset(config.validation_dataset_path, split=config.validation_dataset_split)