Fix a bug in object_detection.md
Author: jajupmochi
Pull request: yes

Modify the `size` argument of the `AutoImageProcessor.from_pretrained`function.

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Original codes are as following:
```
image_processor = AutoImageProcessor.from_pretrained(
    MODEL_NAME,
    do_resize=True,
    size={"max_height": MAX_SIZE, "max_width": MAX_SIZE},
    do_pad=True,
    pad_size={"height": MAX_SIZE, "width": MAX_SIZE},
)
```
It causes the following error:
```
Traceback (most recent call last):
  File "lib/python3.12/site-packages/transformers/models/auto/image_processing_auto.py", line 406, in from_pretrained
    return image_processor_class.from_dict(config_dict, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/transformers/models/conditional_detr/image_processing_conditional_detr.py", line 883, in from_dict
    return super().from_dict(image_processor_dict, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/transformers/image_processing_utils.py", line 413, in from_dict
    image_processor = cls(**image_processor_dict)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/transformers/models/conditional_detr/image_processing_conditional_detr.py", line 831, in __init__
    size = get_size_dict(size, max_size=max_size, default_to_square=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/transformers/image_processing_utils.py", line 745, in get_size_dict
    raise ValueError(
ValueError: size must have one of the following set of keys: ({'width', 'height'}, {'shortest_edge'}, {'longest_edge', 'shortest_edge'}, {'longest_edge'}), got dict_keys(['max_height', 'max_width'])
```
I assume `size={"height": MAX_SIZE, "width": MAX_SIZE}` should be used.


## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker and @younesbelkada
- vision models: @amyeroberts
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @SunMarc

Integrations:

- deepspeed: HF Trainer/Accelerate: @muellerzr
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc and @younesbelkada

Documentation: @stevhliu and @MKhalusova

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->


Comments:
Hi @jajupmochi, can you please provide the `transformers` version you use? 'max_height', 'max_width' were recently added.


> Hi @jajupmochi, can you please provide the `transformers` version you use? 'max_height', 'max_width' were recently added.

Hi @qubvel it is 4.41.2. 

One more thing, the guide https://huggingface.co/docs/transformers/tasks/object_detection and its GitHub source are not exact matches: https://github.com/huggingface/transformers/blob/main/docs/source/en/tasks/object_detection.md.

I noticed that the resizing are omitted in the latter, which leads to a less accurate detection:
![tmpp1900awa](https://github.com/huggingface/transformers/assets/20688296/9c8392e2-108f-4f84-9a3a-ce5e1e658046)




> Hi @jajupmochi, can you please provide the `transformers` version you use? 'max_height', 'max_width' were recently added.

I have solved this bug by upgrading to version 4.42.0.dev0 by installing from the source:
```
python3 -m pip install git+https://github.com/huggingface/transformers
```
I am using this script instead: https://github.com/huggingface/transformers/blob/main/examples/pytorch/object-detection/run_object_detection.py

@jajupmochi thanks, we should probably add a check to the guide about the minimum version required, similar to those in the script you mentioned https://github.com/huggingface/transformers/blob/35b112d3442e4a9f3873191dcde7d1235b6c72eb/examples/pytorch/object-detection/run_object_detection.py#L51 

Would you like to make a PR?

> @jajupmochi thanks, we should probably add a check to the guide about the minimum version required, similar to those in the script you mentioned
> 
> https://github.com/huggingface/transformers/blob/35b112d3442e4a9f3873191dcde7d1235b6c72eb/examples/pytorch/object-detection/run_object_detection.py#L51
> 
> Would you like to make a PR?

Sure. https://github.com/huggingface/transformers/pull/31520#issue-2364650302