Zero-shot image classification with single-label results in 'float is not iterable' error
Author: josephrocca
Pull request: no

### System Info

- `transformers` version: 4.29.2
- Platform: Linux-5.15.107+-x86_64-with-glibc2.31
- Python version: 3.10.11
- Huggingface_hub version: 0.15.1
- Safetensors version: not installed
- PyTorch version (GPU?): 2.0.1+cu118 (False)
- Tensorflow version (GPU?): 2.12.0 (False)
- Flax version (CPU?/GPU?/TPU?): 0.6.9 (cpu)
- Jax version: 0.4.10
- JaxLib version: 0.4.10
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help?

@Narsil

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

**Colab notebook**: https://colab.research.google.com/gist/josephrocca/fdf9537e06fd15d2b5a81727fd70d56b/zero-shot-classification-with-single-label.ipynb

```py
!pip install transformers
!wget https://i.imgur.com/RKsLoNB.png

from transformers import pipeline
image_classifier = pipeline("zero-shot-image-classification", model="openai/clip-vit-large-patch14-336")
text_classifier = pipeline(model="facebook/bart-large-mnli")

# multi-label text - works ✅
text_classifier("houston, we have a problem with the thruster", candidate_labels=["astronaut", "forest cabin", "rabbit and lion"])

# single-label text - works ✅
text_classifier("houston, we have a problem with the thruster", candidate_labels=["astronaut"])

# multi-label image - works ✅
image_classifier("RKsLoNB.png", candidate_labels = ["astronaut", "forest cabin", "rabbit and lion"])

# single-label image - doesn't work ❌
image_classifier("RKsLoNB.png", candidate_labels = ["astronaut"])
```

### Expected behavior

Like in the text case, I'd expect it to not give an error, and importantly, I'd expect it to give a value between 0 and 1, rather than giving a value of exactly 1 (again, like in the text classification case). In other words, if you provide only 1 label, the scores change from being *relative to other label scores* to being a simple **similarity score** between the text and the image - i.e. a binary classification (with the underlying score exposed so you can choose your own threshold).

Comments:
It might make sense to have some sort of explicit option for opting into the "similarity score" mode - that may be less surprising e.g. for people that are using the pipeline for a variable number of labels, and expect the scores to mean the same thing regardless of how many labels are passed in.

But if that approach is taken, then it seems like it would require a breaking change, since zero-shot text classification doesn't return a score of 1 if you pass a single label.

Yes, The single label odd behavior, is legacy, I don't think it's something we want to support in the same way for a new pipeline.

That being said, having a parameter to deactivate normalization, and at the very least *not crashing* is desirable.


Created a PR to just fix the failure (will just return 1.0 all the time)