Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid input data for ImageToTextOutput: Expected a single instance, but got a list. #2273

Open
whiskyboy opened this issue May 7, 2024 · 2 comments · May be fixed by #2285
Open

Invalid input data for ImageToTextOutput: Expected a single instance, but got a list. #2273

whiskyboy opened this issue May 7, 2024 · 2 comments · May be fixed by #2285
Labels
bug Something isn't working

Comments

@whiskyboy
Copy link

Describe the bug

When inferencing with image_to_text() method, it reports a value error:
ValueError: Invalid input data for <class 'huggingface_hub.inference._generated.types.image_to_text.ImageToTextOutput'>. Expected a single instance, but got a list.

It looks like the post response need to be parsed as a list:

raw_response = client.post(data=image_data, task="image-to-text")
ImageToTextOutput.parse_obj_as_list(raw_response)[0].generated_text

I verified the above code could work as expected.

Reproduction

No response

Logs

No response

System info

- huggingface_hub version: 0.23.0
- Platform: Linux-6.5.0-1019-azure-x86_64-with-glibc2.35
- Python version: 3.11.9
- Running in iPython ?: Yes
- iPython shell: ZMQInteractiveShell
- Running in notebook ?: Yes
- Running in Google Colab ?: No
- Token path ?: /home/weitian/.cache/huggingface/token
- Has saved token ?: False
- Configured git credential helpers: 
- FastAI: N/A
- Tensorflow: N/A
- Torch: N/A
- Jinja2: N/A
- Graphviz: N/A
- keras: N/A
- Pydot: N/A
- Pillow: 10.3.0
- hf_transfer: N/A
- gradio: N/A
- tensorboard: N/A
- numpy: 1.26.4
- pydantic: 2.7.1
- aiohttp: N/A
- ENDPOINT: https://huggingface.co
- HF_HUB_CACHE: /home/weitian/.cache/huggingface/hub
- HF_ASSETS_CACHE: /home/weitian/.cache/huggingface/assets
- HF_TOKEN_PATH: /home/weitian/.cache/huggingface/token
- HF_HUB_OFFLINE: False
- HF_HUB_DISABLE_TELEMETRY: False
- HF_HUB_DISABLE_PROGRESS_BARS: None
- HF_HUB_DISABLE_SYMLINKS_WARNING: False
- HF_HUB_DISABLE_EXPERIMENTAL_WARNING: False
- HF_HUB_DISABLE_IMPLICIT_TOKEN: False
- HF_HUB_ENABLE_HF_TRANSFER: False
- HF_HUB_ETAG_TIMEOUT: 10
- HF_HUB_DOWNLOAD_TIMEOUT: 10
@whiskyboy whiskyboy added the bug Something isn't working label May 7, 2024
@tejas36026
Copy link

same here . for some code i am running i am also getting this error lets say for example running this code


import gradio as gr

gr.load("models/naver-clova-ix/donut-base").launch(share=True)   

i get this error

ValueError: Invalid input data for <class 'huggingface_hub.inference._generated.types.image_to_text.ImageToTextOutput'>. Expected a single instance, but got a list.

@Wauplin Wauplin linked a pull request May 21, 2024 that will close this issue
@Wauplin
Copy link
Contributor

Wauplin commented May 21, 2024

Thanks for reporting @whiskyboy @tejas36026 and sorry for the inconvenience!
I have opened a PR to fix this: #2285

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants