# Why use \`val\_transforms()\` function in image classification example instead of \`feature\_extractor\`?

**URL:** <https://discuss.huggingface.co/t/why-use-val-transforms-function-in-image-classification-example-instead-of-feature-extractor/19976>\
**Category:** Intermediate\
**Created:** [July 4, 2022, 2:27pm UTC](https://discuss.huggingface.co/t/why-use-val-transforms-function-in-image-classification-example-instead-of-feature-extractor/19976 "2022-07-04T14:27:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fxmarty](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/fxmarty/32/23782_2.png) [@fxmarty](https://discuss.huggingface.co/u/fxmarty)\
**Post date:** [July 4, 2022, 2:27pm UTC](https://discuss.huggingface.co/t/why-use-val-transforms-function-in-image-classification-example-instead-of-feature-extractor/19976/1 "2022-07-04T14:27:11Z")

</div>

Hello,

In the image classification example, custom transforms are applied on the evaluation dataset: [transformers/run\_image\_classification.py at 6cb19540c9a5288195445e8355646c06605a64fc · huggingface/transformers · GitHub](https://github.com/huggingface/transformers/blob/6cb19540c9a5288195445e8355646c06605a64fc/examples/pytorch/image-classification/run_image_classification.py#L299-L306)

Why not just use the `feature_extractor` on the eval dataset?

Instead of [transformers/run\_image\_classification.py at 6cb19540c9a5288195445e8355646c06605a64fc · huggingface/transformers · GitHub](https://github.com/huggingface/transformers/blob/6cb19540c9a5288195445e8355646c06605a64fc/examples/pytorch/image-classification/run_image_classification.py#L315-L318) we would have

```auto
    def val_transforms(example_batch):
        """Apply _val_transforms across a batch."""
        example_batch["pixel_values"] = [feature_extractor(pil_img.convert("RGB")) for pil_img in example_batch["image"]]
        return example_batch

```

Both do not yield the same output. Therefore, if using the model with `feature_extractor` as the processing step and not custom transforms, we may have unwanted results.

Cheers!
