Skip to content

Commit

Permalink
Remove unnecessary fields from the /api/lambda/functions response (c…
Browse files Browse the repository at this point in the history
…vat-ai#8004)

Remove several fields that haven't been used for one reason or another:

* `labels` and `attributes` have been replaced by `labels_v2`. Keeping
them around nearly triples the response length.

* `framework` hasn't been used by the UI since cvat-ai#5635, and IMO was never
useful to begin with. There are no decisions that the UI can take based
on this field, so it's essentially just a freeform text field, and we
already have a freeform text field - `description`. (Which... the UI
doesn't display either. But it could!)

Remove the `framework` field from the function descriptions as well,
since it has no other purpose.

* `state` has, as far I could determine, never been used by the UI. I
could see a field like this potentially being useful (e.g. the UI could
still display a function, but prevent it from being used if it's
unavailable), but since none of that is implemented right now, I see no
reason to have this field in the API.
  • Loading branch information
SpecLad authored Jun 12, 2024
1 parent 14b65ac commit de95605
Show file tree
Hide file tree
Showing 30 changed files with 1 addition and 51 deletions.
1 change: 0 additions & 1 deletion cvat-core/src/core-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export interface SerializedModel {
name?: string;
labels_v2?: MLModelLabel[];
version?: number;
framework?: string;
description?: string;
kind?: ModelKind;
type?: string;
Expand Down
4 changes: 0 additions & 4 deletions cvat-core/src/ml-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ export default class MLModel {
return this.serialized.version;
}

public get framework(): string {
return this.serialized.framework;
}

public get description(): string {
return this.serialized.description;
}
Expand Down
6 changes: 1 addition & 5 deletions cvat/apps/lambda_manager/tests/test_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@
id_function_state_building = "test-model-has-state-building"
id_function_state_error = "test-model-has-state-error"

expected_keys_in_response_all_functions = ["id", "kind", "labels", "description", "framework", "name"]
expected_keys_in_response_all_functions = ["id", "kind", "labels_v2", "description", "name"]
expected_keys_in_response_function_interactor = expected_keys_in_response_all_functions + ["min_pos_points", "startswith_box"]
expected_keys_in_response_function_tracker = expected_keys_in_response_all_functions + ["state"]
expected_keys_in_response_requests = ["id", "function", "status", "progress", "enqueued", "started", "ended", "exc_info"]

path = os.path.join(os.path.dirname(__file__), 'assets', 'tasks.json')
Expand Down Expand Up @@ -247,9 +246,6 @@ def _check_expected_keys_in_response_function(self, data):
if kind == "interactor":
for key in expected_keys_in_response_function_interactor:
self.assertIn(key, data)
elif kind == "tracker":
for key in expected_keys_in_response_function_tracker:
self.assertIn(key, data)
else:
for key in expected_keys_in_response_all_functions:
self.assertIn(key, data)
Expand Down
15 changes: 0 additions & 15 deletions cvat/apps/lambda_manager/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,10 @@ def parse_attributes(attrs_spec):
raise ValidationError(
"`{}` lambda function has non-unique attributes for label {}".format(self.id, label),
code=status.HTTP_404_NOT_FOUND)
# state of the function
self.state = data['status']['state']
# description of the function
self.description = data['spec']['description']
# http port to access the serverless function
self.port = data["status"].get("httpPort")
# framework which is used for the function (e.g. tensorflow, openvino)
self.framework = meta_anno.get('framework')
# display name for the function
self.name = meta_anno.get('name', self.id)
self.min_pos_points = int(meta_anno.get('min_pos_points', 1))
Expand All @@ -207,10 +203,8 @@ def to_dict(self):
response = {
'id': self.id,
'kind': str(self.kind),
'labels': [label['name'] for label in self.labels],
'labels_v2': self.labels,
'description': self.description,
'framework': self.framework,
'name': self.name,
'version': self.version
}
Expand All @@ -224,15 +218,6 @@ def to_dict(self):
'animated_gif': self.animated_gif
})

if self.kind is LambdaType.TRACKER:
response.update({
'state': self.state
})
if self.kind is LambdaType.DETECTOR:
response.update({
'attributes': self.func_attributes
})

return response

def invoke(
Expand Down
1 change: 0 additions & 1 deletion serverless/onnx/WongKinYiu/yolov7/nuclio/function-gpu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
annotations:
name: YOLO v7
type: detector
framework: onnx
spec: |
[
{ "id": 0, "name": "person", "type": "rectangle" },
Expand Down
1 change: 0 additions & 1 deletion serverless/onnx/WongKinYiu/yolov7/nuclio/function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
annotations:
name: YOLO v7
type: detector
framework: onnx
spec: |
[
{ "id": 0, "name": "person", "type": "rectangle" },
Expand Down
1 change: 0 additions & 1 deletion serverless/openvino/dextr/nuclio/function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ metadata:
version: 2
type: interactor
spec:
framework: openvino
min_pos_points: 4
animated_gif: https://raw.githubusercontent.com/opencv/cvat/0fbb19ae3846a017853d52e187f0ce149adced7d/site/content/en/images/dextr_example.gif
help_message: The interactor allows to get a mask of an object using its extreme points (more or equal than 4). You can add a point left-clicking the image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
annotations:
name: Attributed face detection
type: detector
framework: openvino
spec: |
[
{ "id": 0, "name": "face", "type": "rectangle", "attributes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
annotations:
name: Person reidentification
type: reid
framework: openvino
spec:

spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
annotations:
name: Semantic segmentation for ADAS
type: detector
framework: openvino
spec: |
[
{ "id": 0, "name": "road", "type": "mask" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
annotations:
name: Text detection v4
type: detector
framework: openvino
spec: |
[
{ "id": 1, "name": "text", "type": "mask" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
annotations:
name: Faster RCNN
type: detector
framework: openvino
spec: |
[
{ "id": 1, "name": "person", "type": "rectangle" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ metadata:
annotations:
name: Mask RCNN
type: detector
framework: openvino
spec: |
[
{ "id": 1, "name": "person", "type": "mask" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
annotations:
name: YOLO v3
type: detector
framework: openvino
spec: |
[
{ "id": 0, "name": "person", "type": "rectangle" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
name: TransT
type: tracker
spec:
framework: pytorch

spec:
description: Fast Online Object Tracking and Segmentation
Expand Down
1 change: 0 additions & 1 deletion serverless/pytorch/dschoerk/transt/nuclio/function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
name: TransT
type: tracker
spec:
framework: pytorch

spec:
description: Fast Online Object Tracking and Segmentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
annotations:
name: RetinaNet R101
type: detector
framework: pytorch
spec: |
[
{ "id": 1, "name": "person", "type": "rectangle" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
annotations:
name: RetinaNet R101
type: detector
framework: pytorch
spec: |
[
{ "id": 1, "name": "person", "type": "rectangle" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ metadata:
version: 2
type: interactor
spec:
framework: pytorch
min_pos_points: 1
min_neg_points: 0
animated_gif: https://raw.githubusercontent.com/cvat-ai/cvat/develop/site/content/en/images/hrnet_example.gif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ metadata:
version: 2
type: interactor
spec:
framework: pytorch
min_pos_points: 1
min_neg_points: 0
animated_gif: https://raw.githubusercontent.com/cvat-ai/cvat/develop/site/content/en/images/hrnet_example.gif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
name: SiamMask
type: tracker
spec:
framework: pytorch

spec:
description: Fast Online Object Tracking and Segmentation
Expand Down
1 change: 0 additions & 1 deletion serverless/pytorch/foolwood/siammask/nuclio/function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
name: SiamMask
type: tracker
spec:
framework: pytorch

spec:
description: Fast Online Object Tracking and Segmentation
Expand Down
1 change: 0 additions & 1 deletion serverless/pytorch/mmpose/hrnet32/nuclio/function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
annotations:
name: Human pose estimation
type: detector
framework: pytorch
spec: |
[
{
Expand Down
1 change: 0 additions & 1 deletion serverless/pytorch/saic-vul/fbrs/nuclio/function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ metadata:
version: 2
type: interactor
spec:
framework: pytorch
min_pos_points: 1
min_neg_points: 0
animated_gif: https://raw.githubusercontent.com/cvat-ai/cvat/0fbb19ae3846a017853d52e187f0ce149adced7d/site/content/en/images/fbrs_example.gif
Expand Down
1 change: 0 additions & 1 deletion serverless/pytorch/saic-vul/hrnet/nuclio/function-gpu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ metadata:
version: 2
type: interactor
spec:
framework: pytorch
min_pos_points: 1
min_neg_points: 0
animated_gif: https://raw.githubusercontent.com/cvat-ai/cvat/develop/site/content/en/images/hrnet_example.gif
Expand Down
1 change: 0 additions & 1 deletion serverless/pytorch/saic-vul/hrnet/nuclio/function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ metadata:
version: 2
type: interactor
spec:
framework: pytorch
min_pos_points: 1
min_neg_points: 0
animated_gif: https://raw.githubusercontent.com/cvat-ai/cvat/develop/site/content/en/images/hrnet_example.gif
Expand Down
1 change: 0 additions & 1 deletion serverless/pytorch/shiyinzhang/iog/nuclio/function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ metadata:
version: 2
type: interactor
spec:
framework: pytorch
min_pos_points: 1
min_neg_points: 0
startswith_box: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
annotations:
name: Faster RCNN via Tensorflow
type: detector
framework: tensorflow
spec: |
[
{ "id": 1, "name": "person", "type": "rectangle" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
annotations:
name: Faster RCNN via Tensorflow
type: detector
framework: tensorflow
spec: |
[
{ "id": 1, "name": "person", "type": "rectangle" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ metadata:
annotations:
name: RetinaNet R101
type: detector
framework: pytorch
spec: |
[
{ "id": 1, "name": "person" },
Expand Down

0 comments on commit de95605

Please sign in to comment.