Repository: huggingface/transformers
Pull request: [gemma3] Fix do_convert_rgb in image processors.

* Adds the do_convert_rgb=True statement in image_processing_gemma3_fast.py as suggested in code review for https://github.com/huggingface/transformers/pull/39375
This PR in conjunction with https://github.com/huggingface/transformers/pull/39376 and https://github.com/huggingface/transformers/pull/39375 is needed to make lm-eval run on gemma3.  
See https://github.com/huggingface/transformers/pull/39376 for more details on the command used.

* Fix typo in comments of do_pan_and_scan input variable.

Fixes # https://github.com/huggingface/transformers/issues/23447

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x ] 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
- vision models: @amyeroberts, @qubvel
- speech models: @eustlb
- graph models: @clefourrier

Library:

- flax: @gante and @Rocketknight1
- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- pipelines: @Rocketknight1
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @zach-huggingface, @SunMarc and @qgallouedec
- chat templates: @Rocketknight1

Integrations:

- deepspeed: HF Trainer/Accelerate: @SunMarc @zach-huggingface
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc @MekkCyber

Documentation: @stevhliu

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: @Rocketknight1
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->


Changed files:
filename: src/transformers/models/gemma3/image_processing_gemma3.py
patch: @@ -102,7 +102,7 @@ def __init__(
         do_normalize: bool = True,
         image_mean: Optional[Union[float, list[float]]] = None,
         image_std: Optional[Union[float, list[float]]] = None,
-        do_convert_rgb: Optional[bool] = None,
+        do_convert_rgb: Optional[bool] = True,
         do_pan_and_scan: Optional[bool] = None,
         pan_and_scan_min_crop_size: Optional[int] = None,
         pan_and_scan_max_num_crops: Optional[int] = None,
@@ -302,7 +302,7 @@ def preprocess(
                 - `"none"` or `ChannelDimension.NONE`: image in (height, width) format.
             do_convert_rgb (`bool`, *optional*, defaults to `self.do_convert_rgb`):
                 Whether to convert the image to RGB.
-            do_pan_and_scan (`bool`, *optional*, defaults to `self.do_convert_rgb`):
+            do_pan_and_scan (`bool`, *optional*, defaults to `self.do_pan_and_scan`):
                 Whether to apply `pan_and_scan` to images.
             pan_and_scan_min_crop_size (`int`, *optional*, defaults to `self.pan_and_scan_min_crop_size`):
                 Minimum size of each crop in pan and scan.

filename: src/transformers/models/gemma3/image_processing_gemma3_fast.py
patch: @@ -78,6 +78,7 @@ class Gemma3ImageProcessorFast(BaseImageProcessorFast):
     image_std = IMAGENET_STANDARD_STD
     size = {"height": 224, "width": 224}
     default_to_square = True
+    do_convert_rgb = True
     do_resize = True
     do_rescale = True
     do_normalize = True

filename: src/transformers/models/gemma3/processing_gemma3.py
patch: @@ -41,6 +41,7 @@ class Gemma3ProcessorKwargs(ProcessingKwargs, total=False):
             "return_mm_token_type_ids": True,
         },
         "images_kwargs": {
+            "do_convert_rgb": True,
             "do_pan_and_scan": False,
             "pan_and_scan_min_crop_size": 256,
             "pan_and_scan_max_num_crops": 4,