cvat-ai / cvat

Annotate better with CVAT, the industry-leading data engine for machine learning. Used and trusted by teams at any scale, for data of any scale.
https://cvat.ai
MIT License
12.33k stars 2.97k forks source link

"Cannot read properties of undefined (reading 'length')" when returning serverless predictions #8365

Closed jphdotam closed 1 month ago

jphdotam commented 1 month ago

Actions before raising this issue

Steps to Reproduce

I have been working from https://github.com/cvat-ai/cvat/tree/develop/serverless/openvino/omz/intel/semantic-segmentation-adas-0001/nuclio and copying it as closely as possible.

I have a serverless function which at the end has:

context.Response(body=json.dumps(results), headers={},
                            content_type='application/json', status_code=200)

Where results is defined as:

            results = [
                {"confidence": None,
                 "label": "blood",
                 "points": contour_blood.ravel().tolist(),
                 "mask": cvat_mask_blood,
                 "type": "mask"},
                {"confidence": None,
                 "label": "myocardium",
                 "points": contour_myo.ravel().tolist(),
                 "mask": cvat_mask_myo,
                 "type": "mask"}
            ]

But in CVAT when I use it as an interactor to get masks or points, I get Interaction error occurred - Cannot read properties of undefined (reading 'length')

Note I have tried returning

In the network tab in the developer tools a request to http://100.76.3.138:8080/api/lambda/functions/lgep2d?org= and it has the following in response:

[
    {
        "confidence": null,
        "label": "blood",
        "points": [
            183,
            217,
            182,
            218,
            ...,
            218,
            204,
            218,
            203,
            217
        ],
        "mask": [
            0,
            0,
            0,
            0,
            ...,
            0,
            0,
            0,
            0,
            0,
            152,
            217,
            226,
            284
        ],
        "type": "mask"
    },
    {
        "confidence": null,
        "label": "myocardium",
        "points": [
            190,
            203,
            189,
            204,
            188,
            204,
            187,
            205,
            184,
            ...,
            205,
            207,
            204,
            203,
            204,
            202,
            203
        ],
        "mask": [
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            1,
            1,
            0,
            ...,
            0,
            0,
            0,
            0,
            147,
            203,
            242,
            298
        ],
        "type": "mask"
    }
]

Expected Behavior

Masks and/or points to appear in my labelled image.

Possible Solution

No response

Context

No response

Environment

Server version: 2.17.0

Core version: 15.1.1

Canvas version: 2.20.8

UI version: 1.64.5

commit a69e1228ac8ab120ca9f1274348e83ddcb89d4be (HEAD -> develop, origin/develop, origin/HEAD)
Author: Andrey Zhavoronkov <andrey@cvat.ai>
Date:   Fri Aug 16 14:06:44 2024 +0300

    Update dependencies (#8308)

    Updated:
      backend python packages
      golang image
      frontend nginx base image

Client: Docker Engine - Community
 Version:           27.1.2
 API version:       1.46
 Go version:        go1.21.13
 Git commit:        d01f264
 Built:             Mon Aug 12 11:50:12 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.1.2
  API version:      1.46 (minimum version 1.24)
  Go version:       go1.21.13
  Git commit:       f9522e5
  Built:            Mon Aug 12 11:50:12 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.20
  GitCommit:        8fc6bcff51318944179630522a095cc9dbf9f353
 runc:
  Version:          1.1.13
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
bsekachev commented 1 month ago

I would recommend to look at existing interactors (except for SAM as SAM output additionally handled in the browser by inferring onnx decoder) to see correct output.

jphdotam commented 1 month ago

I would recommend to look at existing interactors (except for SAM as SAM output additionally handled in the browser by inferring onnx decoder) to see correct output.

Sorry yes, I was confusing detectors with interactors!