HumanSignal / HumanSignal/label-studio

YOLO export cannot handle multi-layer images

Open
#4,783 1 comment 0 reactions 1 assignee Claimed by @makseq View on GitHub
community:integration community:reviewed export images problem
Dominant language
TypeScript
Stars
28.3k
Forks
3.7k
Avg merge
14h
Merged PRs (30d)
15

Description

**Describe the bug**
Tasks containing multi-layer images (i.e., a list of images in their data->image value) which are described in https://github.com/HumanSignal/label-studio-frontend/issues/667#issuecomment-1145455797 cannot be exported to YOLO (or COCO, or Pascal VOC) format.

**To Reproduce**
Steps to reproduce the behavior:
1. Create a project with a simple label interface:
```xml




```
3. Import a multi-layer image from `data.json`:
```json
{
"data": {
"image": [
"/data/local-files/?d=layer_0/image.png",
"/data/local-files/?d=layer_1/image.png"
]
}
}
```
3. Label something on this image
4. Click on the "Export" button in the project overview and choose YOLO (same for COCO, Pascal VOC).
The frontend outputs a runtime error:
```
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/django/utils/decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "/label-studio/label_studio/data_export/api.py", line 183, in get
export_stream, content_type, filename = DataExport.generate_export_file(
File "/label-studio/label_studio/data_export/models.py", line 161, in generate_export_file
converter.convert(input_json, tmp_dir, output_format, is_dir=False)
File "/usr/local/lib/python3.10/dist-packages/label_studio_converter/converter.py", line 215, in convert
self.convert_to_yolo(
File "/usr/local/lib/python3.10/dist-packages/label_studio_converter/converter.py", line 794, in convert_to_yolo
if not os.path.exists(image_path):
File "/usr/lib/python3.10/genericpath.py", line 19, in exists
os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not list
```

**Expected behavior**
For multi-layer images, use the filename of the first list element for the YOLO formatted label (i.e., `image.txt`). If it downloads, then try to download all layers/images for this task.

**Screenshots**
n/a

**Environment (please complete the following information):**
- OS: Ubuntu 22.04
- Label Studio Version: 1.7.3

**Additional context**
n/a

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.