Supporting `ImageProcessor` in place of `FeatureExtractor` for pipelines
# What does this PR do?

~As a bonus point, it enables `OneFormer` for `image-segmentation`.~ Moved to separate PR.
Requires https://github.com/huggingface/transformers/pull/21278

<!--
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 -->

Fixes # (issue)


## Before submitting
- [ ] 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#start-contributing-pull-requests),
      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 and @NielsRogge
- speech models: @sanchit-gandhi

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @sgugger

Integrations:

- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam

Documentation: @sgugger and @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: @sanchit-gandhi
- PyTorch: @sgugger
- TensorFlow: @Rocketknight1

 -->

I don't seem to have direct write access (git is asking for credentials). I opened a PR here: https://github.com/praeclarumjj3/transformers/pull/1.<|||||>Hi @Narsil, please let me know if you need my assistance with the pipeline. I would like to emphasize that we should have a `task_inputs` argument if possible and provide an option to change the task on the model page under the `Hosted Inference API` to demonstrate the task-dynamic nature of a **single** OneFormer model. Thanks!

<img width="1152" alt="Screenshot 2022-12-24 at 4 09 46 PM" src="https://user-images.githubusercontent.com/54928629/209432305-793e150b-2dbd-4566-958c-a53ba69c3d75.png">

<|||||>> Hi @Narsil, please let me know if you need my assistance with the pipeline. I would like to emphasize that we should have a `task_inputs` argument if possible and provide an option to change the task on the model page under the `Hosted Inference API` to demonstrate the task-dynamic nature of a **single** OneFormer model. 

In my modifications (I'll create a PR when this one is merged, the branch already exists) it will be possible to use `subtask` which already exists as a parameter today and will work with oneformer out of the box.

On the UI front, I'm not really convinced we should add the complexity of this. This requires either changing  segmentation for ALL segmentation models (which most models will only support one form, so it's a source of confusion) or add a new task (and that's a big modification, which imo is not worth it)
`panoptic` is just more general than `instance` and `semantic` so it is a sound default IMO. Since the widget is here to be simple, it really seems like a good way to showcase the model's performance. For advanced use cases, using the API with subtask will work, and specific spaces and colab can showcase them further. Just like `text-generation` 's widget doesn't display all the various generation params (which are indeed useful in a lot of cases when tinkering with such a model) I don't think we should display a choice of subtask for this one specific model on the UI.
<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.<|||||>cc @Narsil now that OneFormer has been merged, we can update the image segmentation pipeline :)<|||||>_The documentation is not available anymore as the PR was closed or merged._<|||||>Merging since I removed the problematic part.<|||||>HI @amyeroberts @Narsil @sgugger , I notice some dev tests in Optimum that start to fail due to this PR. Notably, this PR break code snippets (that are working on 4.26) as:

```python
from transformers import pipeline, AutoModelForImageClassification, AutoFeatureExtractor
model_id = "microsoft/resnet-18"

model = AutoModelForImageClassification.from_pretrained(model_id)
feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)

pipe = pipeline(task="image-classification", model=model, feature_extractor=feature_extractor)
```

with error `Exception: Impossible to guess which image processor to use. Please provide a PreTrainedImageProcessor class or a path/identifier to a pretrained image processor.`

It is only natural to want to pass `feature_extractor` and not `image_processor` from a user perspective, given that a lot of code snippets in README use them: https://huggingface.co/models?pipeline_tag=image-classification&sort=downloads

Is this breaking change intended? Given https://github.com/huggingface/transformers/pull/21401 @ydshieh  I guess it is?<|||||>`ImageProcessor`  are replacing `FeatureExtractor` for images (so `FeatureExtractor` will stay but just for the audio.

Now the breaking change you've seen is not intended. We should automatically set the image_processor when you send a `FeatureExtractor`. 

Going forward it's getting extinct, but we should be able to maintain long term backward compatibility.<|||||>Quick question, any reason you're using this code instead of just `pipeline(model="microsoft/resnet-18")` ? <|||||>This line is supposed to fix the backward compability: https://github.com/huggingface/transformers/blob/main/src/transformers/pipelines/base.py#L795

I created a PR to fix this snippet though.<|||||>Thank you @fxmarty @Narsil for rescuing the backward compatibility, and sorry, the CI didn't detect this edge case while I worked on #21401