`Pathlike` objects are treated as `AutoModel` objects in `pipeline` initialization
### System Info

- `transformers` version: 4.22.2
- Platform: macOS-13.0-arm64-arm-64bit
- Python version: 3.9.13
- Huggingface_hub version: 0.10.0
- PyTorch version (GPU?): 1.12.1 (False)
- Tensorflow version (GPU?): 2.10.0 (True)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no

### Who can help?

@Narsil 

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

Steps to reproduce the behaviour:
1. Run the following code snippet
```python
from transformers import pipeline
from pathlib import Path

# store pipeline locally
gen = pipeline("image-classification", "google/vit-base-patch16-224")
gen.save_pretrained(Path("./models") / "google/vit-base-patch16-224")

# load pipeline locally
new_gen = pipeline(
    "image-classification", Path("./models") / "google/vit-base-patch16-224"
)
```

Loading pipeline fails with following error:
<img width="1010" alt="image" src="https://user-images.githubusercontent.com/20420308/199565245-190f8291-d691-48f4-bd43-3a4500bc225d.png">

This works file if I pass string path:
```
new_gen = pipeline(
    "image-classification", str(Path("./models") / "google/vit-base-patch16-224")
)
```

### Expected behavior

The pipeline model argument should check for Pathlike objects and not treat them the same as AutoModel instances.
Excellent suggestion! 

I opened a PR https://github.com/huggingface/transformers/pull/20030