label-studio icon indicating copy to clipboard operation
label-studio copied to clipboard

Unable to upload new images in a created Visual Question Answering task

Open c-x-z opened this issue 1 year ago • 1 comments

Describe the bug Unable to upload a new image in a created VQA task, the following appears when uploading an image:

[0daf5e7a-bba8-4a2a-a6b2-a2d2ea423ab8] Validation error (Failed to parse input file upload/20/b95b6c59-00005.jpg: [ErrorDetail(string='Your label config has more than one data key and direct file upload supports only one data key. To import data with multiple data keys, use a JSON or CSV file.', code='invalid')])

屏幕截图 2024-09-05 155127

What do I have to do to fix it?

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Label Studio Version [e.g. 0.8.0]

Additional context Add any other context about the problem here.

c-x-z avatar Sep 05 '24 07:09 c-x-z

do we know how solve it or not yet?

gabrielqr avatar May 29 '25 16:05 gabrielqr

The error occurs because in Label Studio, when we upload an image directly (drag & drop or file upload), there can only be one data key in the labeling configuration.

👉 What this means is that in the label config (XML setup for the project), there can be more than one <Image value="..."> or <Data value="..."> element. Incorrect example (having more than one key):

<View>
<Image name="img1" value="$image"/>
<Image name="img2" value="$image2"/>
</View>

If you use direct upload, it doesn't work, because Label Studio is confused about which data field to use (image or image2).


Solution:

1. If you only want one image per task:

Make sure there is only one data key in the configuration, for example:

<View>
<Image name="image" value="$image"/>
<Choices name="label" toName="image">
<Choice value="Cat"/>
<Choice value="Dog"/>
</Choices>
</View>

Then upload the image directly to the project.


2. If you need multiple data keys (e.g., image + text, or two images at once):

You cannot use direct file upload. You must use JSON/CSV import. Example JSON format:

[
{
"image": "https://example.com/image1.jpg",
"image2": "https://example.com/image2.jpg"
}
]

Or CSV:

image,image2
https://example.com/image1.jpg,https://example.com/image2.jpg

⚡ So the bottom line:

  • Direct upload → only 1 <Image> or data key.
  • Multiple data keys → use JSON/CSV import.

gilberthtg avatar Sep 12 '25 04:09 gilberthtg