ImportError: Blip2ForConditionalGeneration
Author: garg-aayush
Pull request: no

### System Info


I am trying to run Image captioning using `BLIP2` using the steps mentioned in [Link](https://huggingface.co/blog/blip-2#using-blip-2-with-hugging-face-transformers). However, there seems to be import error for `BLIP2ForConditionalGeneration`

`transformers version: 4.27.0.dev0`

Issue
```bash
Traceback (most recent call last):
  File "/home/aayush/ControlNet/blip2_captions_test.py", line 4, in <module>
    from transformers import AutoProcessor, BLIP2ForConditionalGeneration
ImportError: cannot import name 'Blip2ForConditionalGeneration' from 'transformers' (/home/aayush/miniconda3/envs/diffusers/lib/python3.10/site-packages/transformers/__init__.py)
```



### Who can help?

_No response_

### 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

1. pip install transformers
2. Run the following snippet

```
from PIL import Image
from transformers import AutoProcessor, Blip2ForConditionalGeneration
device = "cuda" if torch.cuda.is_available() else "cpu"
processor = AutoProcessor.from_pretrained("Salesforce/blip2-opt-2.7b")
model = Blip2ForConditionalGeneration.from_pretrained("Salesforce/blip2-opt-2.7b", torch_dtype=torch.float16)
```

### Expected behavior

It should have started downloading the blip-2 models locally

Comments:
Hi, thanks for using BLIP-2!

It's Blip2ForConditionalGeneration, not BLIP2ForConditionalGeneration ;)

@NielsRogge 

Same issue changing to `Blip2ForConditionalGeneration`
```bash
  File "/home/aayush/ControlNet/blip2_captions_test.py", line 4, in <module>
    from transformers import AutoProcessor, Blip2ForConditionalGeneration
ImportError: cannot import name 'Blip2ForConditionalGeneration' from 'transformers' (/home/aayush/miniconda3/envs/diffusers/lib/python3.10/site-packages/transformers/__init__.py))
```

@NielsRogge 

I installed `transformers` from source now
```bash
git clone https://github.com/huggingface/transformers.git
cd transformers
pip install -e .
```
instead of `pip install git+https://github.com/huggingface/transformers` or `pip install transformers`.

It works now!




Ok, I thought you were already using that since you mentioned transformers version: 4.27.0.dev0.

Feel free to close this issue if it's resolved :)

I installed from the source but still getting the same error. Any update here?


@minarainbow How did you installed from source?

This way (worked!)
```
git clone https://github.com/huggingface/transformers.git
cd transformers
pip install -e .
```
or (error)

```
pip install git+https://github.com/huggingface/transformers
``



Best is to do:

```
pip install git+https://github.com/huggingface/transformers.git@main
```

What's actually going on here? It's now almost November 2023 and not included? 

https://huggingface.co/docs/transformers/v4.28.1/model_doc/blip-2

and

https://huggingface.co/docs/transformers/v4.34.1/model_doc/blip-2

both cite `Blip2ForConditionalGeneration` but for me, these versions cannot import it. 

I install from source

> `pip install git+https://github.com/huggingface/transformers.git@main`

And still can't import `Blip2ForConditionalGeneration`

```
Traceback (most recent call last):
  File "c:\testing\blip2.py", line 1, in <module>
    from transformers import AutoProcessor, Blip2ForConditionalGeneration
ImportError: cannot import name 'Blip2ForConditionalGeneration' from 'transformers' (C:\Users\jorda\AppData\Roaming\Python\Python310\site-packages\transformers\__init__.py) 
```

There is documentation citing code that doesn't exist in those versions, and you cannot follow the documentation. 

Hey, I cannot reproduce your issue, the following works for me: 
```python 
>>> from transformers import Blip2ForConditionalGeneration
```
make sure transformers is correctly installed and that you are using the correct environment 
```python 
>>> import transformers 
>>> print(transformers.__version__)
```

> Hey, I cannot reproduce your issue, the following works for me:
> 
> ```python
> >>> from transformers import Blip2ForConditionalGeneration
> ```
> 
> make sure transformers is correctly installed and that you are using the correct environment
> 
> ```python
> >>> import transformers 
> >>> print(transformers.__version__)
> ```

I think issue was how pip handling upgrades, cause installing from source worked (cloning the main repo)