Unable to process image in pipeline for document question-answering
Author: pythonvijay
Pull request: no

Hi,

I am trying to read an image into google colab and then process it through pipeline() for document Q&A but it seems that my image  is not read by pipeline or maybe not in a supported format;

Here is my code 

```
from docquery import document, pipeline
from transformers import pipeline
from PIL import Image
pipe = pipeline("document-question-answering",model="impira/layoutlm-document-qa")

from google.colab import files
import cv2
import matplotlib.pyplot as plt

uploaded = files.upload()
```
```
img = cv2.imread ('testimg.png')
plt.imshow (img)
```
```
question = "What is IndexError?"
#image = Image.open(img)

pipe(image=img, question=question)
```

error message below - please advise what am I doing wrong here!

```
AttributeError                            Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/PIL/Image.py](https://localhost:8080/#) in open(fp, mode, formats)
   3230     try:
-> 3231         fp.seek(0)
   3232     except (AttributeError, io.UnsupportedOperation):

AttributeError: 'numpy.ndarray' object has no attribute 'seek'
```

Comments:
Not an expert but seems to me that open cv imread() is returning a numpy array (it is if you check the c++ code) and your pipeline expects a file.  Have you tried instead to send `Image.open('testing.png')` or just `open('testing.png')` to pipe?  something like:

```
with open('testimg.png', 'r') as fin:
  pipe(image=fin, question=question)
```



If I pass open () as below in pipe, I get the error as below the code:

```
with open('testimg.png', 'r') as fin:
  pipe(image=fin, question=question)
```
error:

```
----> 5   pipe(image=fin, question=question)

9 frames
[/usr/local/lib/python3.10/dist-packages/transformers/image_utils.py](https://localhost:8080/#) in load_image(image, timeout)
    315         image = image
    316     else:
--> 317         raise ValueError(
    318             "Incorrect format used for image. Should be an url linking to an image, a base64 string, a local path, or a PIL image."
    319         )

ValueError: Incorrect format used for image. Should be an url linking to an image, a base64 string, a local path, or a PIL image.
```
If I use Image.open() as here, I get the error as below this code:
```
with Image.open('testimg.png', 'r') as fin:
  pipe(image=fin, question=question)
```
```
----> 5   pipe(image=fin, question=question)

4 frames
[/usr/local/lib/python3.10/dist-packages/transformers/utils/generic.py](https://localhost:8080/#) in pop(self, *args, **kwargs)
    374 
    375     def pop(self, *args, **kwargs):
--> 376         raise Exception(f"You cannot use ``pop`` on a {self.__class__.__name__} instance.")
    377 
    378     def update(self, *args, **kwargs):

Exception: You cannot use ``pop`` on a ModelOutput instance.
```

have you tried `pipe(image='testimg.png', question=question)`?  That's what `ValueError: Incorrect format used for image. Should be an url linking to an image, a base64 string, a local path, or a PIL image.` seems to be asking for

Could share the output of `transformers-cli env` ? You should try one the latest release of transformers! 

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.