gimlet-api 0.0.1__py3-none-any.whl → 0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gimlet_api-0.0.2.dist-info/METADATA +16 -0
- gimlet_api-0.0.2.dist-info/RECORD +41 -0
- {gimlet_api-0.0.1.dist-info → gimlet_api-0.0.2.dist-info}/WHEEL +1 -2
- gml/__init__.py +17 -0
- gml/_utils.py +41 -0
- gml/client.py +297 -0
- gml/compile.py +43 -8
- gml/model.py +149 -0
- gml/preprocessing.py +77 -0
- gml/proto/gogoproto/gogo_pb2.py +101 -0
- gml/proto/mediapipe/framework/calculator_contract_test_pb2.py +32 -0
- gml/proto/mediapipe/framework/calculator_options_pb2.py +28 -0
- gml/proto/mediapipe/framework/calculator_pb2.py +56 -0
- gml/proto/mediapipe/framework/calculator_profile_pb2.py +47 -0
- gml/proto/mediapipe/framework/mediapipe_options_pb2.py +26 -0
- gml/proto/mediapipe/framework/packet_factory_pb2.py +30 -0
- gml/proto/mediapipe/framework/packet_generator_pb2.py +32 -0
- gml/proto/mediapipe/framework/packet_test_pb2.py +32 -0
- gml/proto/mediapipe/framework/status_handler_pb2.py +27 -0
- gml/proto/mediapipe/framework/stream_handler_pb2.py +29 -0
- gml/proto/mediapipe/framework/test_calculators_pb2.py +32 -0
- gml/proto/mediapipe/framework/thread_pool_executor_pb2.py +30 -0
- gml/proto/opentelemetry/proto/common/v1/common_pb2.py +34 -0
- gml/proto/opentelemetry/proto/metrics/v1/metrics_pb2.py +62 -0
- gml/proto/opentelemetry/proto/resource/v1/resource_pb2.py +27 -0
- gml/proto/src/api/corepb/v1/controlplane_pb2.py +56 -0
- gml/proto/src/api/corepb/v1/cp_edge_pb2.py +117 -0
- gml/proto/src/api/corepb/v1/mediastream_pb2.py +64 -0
- gml/proto/src/api/corepb/v1/model_exec_pb2.py +174 -0
- gml/proto/src/common/typespb/jwt_pb2.py +61 -0
- gml/proto/src/common/typespb/status_pb2.py +29 -0
- gml/proto/src/common/typespb/uuid_pb2.py +26 -0
- gml/proto/src/controlplane/directory/directorypb/v1/directory_pb2.py +115 -0
- gml/proto/src/controlplane/directory/directorypb/v1/directory_pb2_grpc.py +452 -0
- gml/proto/src/controlplane/filetransfer/ftpb/v1/ftpb_pb2.py +70 -0
- gml/proto/src/controlplane/filetransfer/ftpb/v1/ftpb_pb2_grpc.py +231 -0
- gml/proto/src/controlplane/logicalpipeline/lppb/v1/lppb_pb2.py +59 -0
- gml/proto/src/controlplane/logicalpipeline/lppb/v1/lppb_pb2_grpc.py +132 -0
- gml/proto/src/controlplane/model/mpb/v1/mpb_pb2.py +47 -0
- gml/proto/src/controlplane/model/mpb/v1/mpb_pb2_grpc.py +99 -0
- gml/tensor.py +193 -0
- gimlet_api-0.0.1.dist-info/METADATA +0 -6
- gimlet_api-0.0.1.dist-info/RECORD +0 -6
- gimlet_api-0.0.1.dist-info/top_level.txt +0 -1
gml/tensor.py
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
# Copyright © 2023- Gimlet Labs, Inc.
|
2
|
+
# All Rights Reserved.
|
3
|
+
#
|
4
|
+
# NOTICE: All information contained herein is, and remains
|
5
|
+
# the property of Gimlet Labs, Inc. and its suppliers,
|
6
|
+
# if any. The intellectual and technical concepts contained
|
7
|
+
# herein are proprietary to Gimlet Labs, Inc. and its suppliers and
|
8
|
+
# may be covered by U.S. and Foreign Patents, patents in process,
|
9
|
+
# and are protected by trade secret or copyright law. Dissemination
|
10
|
+
# of this information or reproduction of this material is strictly
|
11
|
+
# forbidden unless prior written permission is obtained from
|
12
|
+
# Gimlet Labs, Inc.
|
13
|
+
#
|
14
|
+
# SPDX-License-Identifier: Proprietary
|
15
|
+
|
16
|
+
import abc
|
17
|
+
from typing import List, Literal, Optional, Tuple
|
18
|
+
|
19
|
+
import gml.proto.src.api.corepb.v1.model_exec_pb2 as modelexecpb
|
20
|
+
|
21
|
+
|
22
|
+
def box_format_str_to_proto(box_format: str):
|
23
|
+
match box_format.lower():
|
24
|
+
case "cxcywh":
|
25
|
+
return modelexecpb.BoundingBoxInfo.BOUNDING_BOX_FORMAT_CXCYWH
|
26
|
+
case "xyxy":
|
27
|
+
return modelexecpb.BoundingBoxInfo.BOUNDING_BOX_FORMAT_XYXY
|
28
|
+
case "yxyx":
|
29
|
+
return modelexecpb.BoundingBoxInfo.BOUNDING_BOX_FORMAT_YXYX
|
30
|
+
case _:
|
31
|
+
raise ValueError("Invalid bounding box format: {}".format(box_format))
|
32
|
+
|
33
|
+
|
34
|
+
class BoundingBoxFormat:
|
35
|
+
def __init__(self, box_format: str = "cxcywh", is_normalized: bool = True):
|
36
|
+
self.box_format = box_format_str_to_proto(box_format)
|
37
|
+
self.is_normalized = is_normalized
|
38
|
+
|
39
|
+
def to_proto(self) -> modelexecpb.BoundingBoxInfo:
|
40
|
+
return modelexecpb.BoundingBoxInfo(
|
41
|
+
box_format=self.box_format,
|
42
|
+
box_normalized=self.is_normalized,
|
43
|
+
)
|
44
|
+
|
45
|
+
|
46
|
+
class DimensionSemantics(abc.ABC):
|
47
|
+
@abc.abstractmethod
|
48
|
+
def to_proto(self) -> modelexecpb.DimensionSemantics:
|
49
|
+
pass
|
50
|
+
|
51
|
+
|
52
|
+
class BatchDimension(DimensionSemantics):
|
53
|
+
def to_proto(self) -> modelexecpb.DimensionSemantics:
|
54
|
+
return modelexecpb.DimensionSemantics(
|
55
|
+
kind=modelexecpb.DimensionSemantics.DIMENSION_SEMANTICS_KIND_BATCH,
|
56
|
+
)
|
57
|
+
|
58
|
+
|
59
|
+
class IgnoreDimension(DimensionSemantics):
|
60
|
+
def to_proto(self) -> modelexecpb.DimensionSemantics:
|
61
|
+
return modelexecpb.DimensionSemantics(
|
62
|
+
kind=modelexecpb.DimensionSemantics.DIMENSION_SEMANTICS_KIND_IGNORE,
|
63
|
+
)
|
64
|
+
|
65
|
+
|
66
|
+
def chan_format_str_to_proto(chan_format: str):
|
67
|
+
match chan_format.lower():
|
68
|
+
case "rgb":
|
69
|
+
return (
|
70
|
+
modelexecpb.DimensionSemantics.ImageChannelParams.IMAGE_CHANNEL_FORMAT_RGB
|
71
|
+
)
|
72
|
+
case "bgr":
|
73
|
+
return (
|
74
|
+
modelexecpb.DimensionSemantics.ImageChannelParams.IMAGE_CHANNEL_FORMAT_BGR
|
75
|
+
)
|
76
|
+
case _:
|
77
|
+
raise ValueError("Invalid channel_format format: {}".format(chan_format))
|
78
|
+
|
79
|
+
|
80
|
+
class ImageChannelDimension(DimensionSemantics):
|
81
|
+
def __init__(self, channel_format="rgb"):
|
82
|
+
self.channel_format = chan_format_str_to_proto(channel_format)
|
83
|
+
|
84
|
+
def to_proto(self) -> modelexecpb.DimensionSemantics:
|
85
|
+
return modelexecpb.DimensionSemantics(
|
86
|
+
kind=modelexecpb.DimensionSemantics.DIMENSION_SEMANTICS_KIND_IMAGE_CHANNEL,
|
87
|
+
image_channel_params=modelexecpb.DimensionSemantics.ImageChannelParams(
|
88
|
+
format=self.channel_format,
|
89
|
+
),
|
90
|
+
)
|
91
|
+
|
92
|
+
|
93
|
+
class ImageHeightDimension(DimensionSemantics):
|
94
|
+
def to_proto(self) -> modelexecpb.DimensionSemantics:
|
95
|
+
return modelexecpb.DimensionSemantics(
|
96
|
+
kind=modelexecpb.DimensionSemantics.DIMENSION_SEMANTICS_KIND_IMAGE_HEIGHT,
|
97
|
+
)
|
98
|
+
|
99
|
+
|
100
|
+
class ImageWidthDimension(DimensionSemantics):
|
101
|
+
def to_proto(self) -> modelexecpb.DimensionSemantics:
|
102
|
+
return modelexecpb.DimensionSemantics(
|
103
|
+
kind=modelexecpb.DimensionSemantics.DIMENSION_SEMANTICS_KIND_IMAGE_WIDTH,
|
104
|
+
)
|
105
|
+
|
106
|
+
|
107
|
+
class DetectionNumCandidatesDimension(DimensionSemantics):
|
108
|
+
def __init__(self, is_nms: bool = False):
|
109
|
+
self.is_nms = is_nms
|
110
|
+
|
111
|
+
def to_proto(self) -> modelexecpb.DimensionSemantics:
|
112
|
+
return modelexecpb.DimensionSemantics(
|
113
|
+
kind=modelexecpb.DimensionSemantics.DIMENSION_SEMANTICS_KIND_DETECTION_CANDIDATES,
|
114
|
+
detection_candidates_params=modelexecpb.DimensionSemantics.DetectionCandidatesParams(
|
115
|
+
is_nms_boxes=self.is_nms
|
116
|
+
),
|
117
|
+
)
|
118
|
+
|
119
|
+
|
120
|
+
class DetectionOutputDimension(DimensionSemantics):
|
121
|
+
def __init__(
|
122
|
+
self,
|
123
|
+
coordinates_start_index: int,
|
124
|
+
box_format: BoundingBoxFormat,
|
125
|
+
box_confidence_index: int,
|
126
|
+
class_index: Optional[int] = None,
|
127
|
+
scores_range: Optional[Tuple[int, int]] = None,
|
128
|
+
):
|
129
|
+
self.coordinates_range = (coordinates_start_index, 4)
|
130
|
+
self.box_format = box_format
|
131
|
+
self.box_confidence_index = box_confidence_index
|
132
|
+
self.class_index = class_index
|
133
|
+
self.scores_range = scores_range
|
134
|
+
|
135
|
+
def to_proto(self) -> modelexecpb.DimensionSemantics:
|
136
|
+
scores_range = None
|
137
|
+
if self.scores_range is not None:
|
138
|
+
scores_range = (
|
139
|
+
modelexecpb.DimensionSemantics.DetectionOutputParams.IndexRange(
|
140
|
+
start=self.scores_range[0],
|
141
|
+
size=self.scores_range[1],
|
142
|
+
)
|
143
|
+
)
|
144
|
+
return modelexecpb.DimensionSemantics(
|
145
|
+
kind=modelexecpb.DimensionSemantics.DIMENSION_SEMANTICS_KIND_DETECTION_OUTPUT,
|
146
|
+
detection_output_params=modelexecpb.DimensionSemantics.DetectionOutputParams(
|
147
|
+
box_coordinate_range=modelexecpb.DimensionSemantics.DetectionOutputParams.IndexRange(
|
148
|
+
start=self.coordinates_range[0],
|
149
|
+
size=self.coordinates_range[1],
|
150
|
+
),
|
151
|
+
box_format=self.box_format.to_proto(),
|
152
|
+
box_confidence_index=self.box_confidence_index,
|
153
|
+
class_index=self.class_index,
|
154
|
+
scores_range=scores_range,
|
155
|
+
),
|
156
|
+
)
|
157
|
+
|
158
|
+
|
159
|
+
def _segmentation_mask_kind_to_proto(kind: str):
|
160
|
+
match kind.lower():
|
161
|
+
case "bool_masks":
|
162
|
+
return (
|
163
|
+
modelexecpb.DimensionSemantics.SegmentationMaskParams.SEGMENTATION_MASK_KIND_BOOL
|
164
|
+
)
|
165
|
+
case "int_label_masks":
|
166
|
+
return (
|
167
|
+
modelexecpb.DimensionSemantics.SegmentationMaskParams.SEGMENTATION_MASK_KIND_CLASS_LABEL
|
168
|
+
)
|
169
|
+
case _:
|
170
|
+
raise ValueError("Invalid segmentation mask kind: {}".format(kind))
|
171
|
+
|
172
|
+
|
173
|
+
class SegmentationMaskChannel(DimensionSemantics):
|
174
|
+
def __init__(self, kind: Literal["bool_masks", "int_label_masks"]):
|
175
|
+
self.kind = _segmentation_mask_kind_to_proto(kind)
|
176
|
+
|
177
|
+
def to_proto(self) -> modelexecpb.DimensionSemantics:
|
178
|
+
return modelexecpb.DimensionSemantics(
|
179
|
+
kind=modelexecpb.DimensionSemantics.DIMENSION_SEMANTICS_KIND_SEGMENTATION_MASK_CHANNEL,
|
180
|
+
segmentation_mask_params=modelexecpb.DimensionSemantics.SegmentationMaskParams(
|
181
|
+
kind=self.kind,
|
182
|
+
),
|
183
|
+
)
|
184
|
+
|
185
|
+
|
186
|
+
class TensorSemantics:
|
187
|
+
def __init__(self, dimensions: List[DimensionSemantics]):
|
188
|
+
self.dimensions = dimensions
|
189
|
+
|
190
|
+
def to_proto(self) -> modelexecpb.TensorSemantics:
|
191
|
+
return modelexecpb.TensorSemantics(
|
192
|
+
dimensions=[dim.to_proto() for dim in self.dimensions],
|
193
|
+
)
|
@@ -1,6 +0,0 @@
|
|
1
|
-
gml/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
gml/compile.py,sha256=VzNVLojb8D8lISLYxazR3-YkJ6HzscP0juP7yWAltfg,869
|
3
|
-
gimlet_api-0.0.1.dist-info/METADATA,sha256=F7JACoU323q1pnbZD-KQfdJTpd_yKFBS8sXhSHhx-M4,106
|
4
|
-
gimlet_api-0.0.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
5
|
-
gimlet_api-0.0.1.dist-info/top_level.txt,sha256=wSbIUt3C0p7m2JMxpjK6M83pB9pqGe274eF3qgIxzS8,4
|
6
|
-
gimlet_api-0.0.1.dist-info/RECORD,,
|
@@ -1 +0,0 @@
|
|
1
|
-
gml
|