gimlet-api 0.0.0.dev0__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.
Files changed (41) hide show
  1. gimlet_api-0.0.0.dev0.dist-info/METADATA +16 -0
  2. gimlet_api-0.0.0.dev0.dist-info/RECORD +41 -0
  3. gimlet_api-0.0.0.dev0.dist-info/WHEEL +4 -0
  4. gml/__init__.py +17 -0
  5. gml/_utils.py +41 -0
  6. gml/client.py +297 -0
  7. gml/compile.py +61 -0
  8. gml/model.py +149 -0
  9. gml/preprocessing.py +77 -0
  10. gml/proto/gogoproto/gogo_pb2.py +101 -0
  11. gml/proto/mediapipe/framework/calculator_contract_test_pb2.py +32 -0
  12. gml/proto/mediapipe/framework/calculator_options_pb2.py +28 -0
  13. gml/proto/mediapipe/framework/calculator_pb2.py +56 -0
  14. gml/proto/mediapipe/framework/calculator_profile_pb2.py +47 -0
  15. gml/proto/mediapipe/framework/mediapipe_options_pb2.py +26 -0
  16. gml/proto/mediapipe/framework/packet_factory_pb2.py +30 -0
  17. gml/proto/mediapipe/framework/packet_generator_pb2.py +32 -0
  18. gml/proto/mediapipe/framework/packet_test_pb2.py +32 -0
  19. gml/proto/mediapipe/framework/status_handler_pb2.py +27 -0
  20. gml/proto/mediapipe/framework/stream_handler_pb2.py +29 -0
  21. gml/proto/mediapipe/framework/test_calculators_pb2.py +32 -0
  22. gml/proto/mediapipe/framework/thread_pool_executor_pb2.py +30 -0
  23. gml/proto/opentelemetry/proto/common/v1/common_pb2.py +34 -0
  24. gml/proto/opentelemetry/proto/metrics/v1/metrics_pb2.py +62 -0
  25. gml/proto/opentelemetry/proto/resource/v1/resource_pb2.py +27 -0
  26. gml/proto/src/api/corepb/v1/controlplane_pb2.py +56 -0
  27. gml/proto/src/api/corepb/v1/cp_edge_pb2.py +117 -0
  28. gml/proto/src/api/corepb/v1/mediastream_pb2.py +64 -0
  29. gml/proto/src/api/corepb/v1/model_exec_pb2.py +174 -0
  30. gml/proto/src/common/typespb/jwt_pb2.py +61 -0
  31. gml/proto/src/common/typespb/status_pb2.py +29 -0
  32. gml/proto/src/common/typespb/uuid_pb2.py +26 -0
  33. gml/proto/src/controlplane/directory/directorypb/v1/directory_pb2.py +115 -0
  34. gml/proto/src/controlplane/directory/directorypb/v1/directory_pb2_grpc.py +452 -0
  35. gml/proto/src/controlplane/filetransfer/ftpb/v1/ftpb_pb2.py +70 -0
  36. gml/proto/src/controlplane/filetransfer/ftpb/v1/ftpb_pb2_grpc.py +231 -0
  37. gml/proto/src/controlplane/logicalpipeline/lppb/v1/lppb_pb2.py +59 -0
  38. gml/proto/src/controlplane/logicalpipeline/lppb/v1/lppb_pb2_grpc.py +132 -0
  39. gml/proto/src/controlplane/model/mpb/v1/mpb_pb2.py +47 -0
  40. gml/proto/src/controlplane/model/mpb/v1/mpb_pb2_grpc.py +99 -0
  41. gml/tensor.py +166 -0
gml/tensor.py ADDED
@@ -0,0 +1,166 @@
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, 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
+ class TensorSemantics:
160
+ def __init__(self, dimensions: List[DimensionSemantics]):
161
+ self.dimensions = dimensions
162
+
163
+ def to_proto(self) -> modelexecpb.TensorSemantics:
164
+ return modelexecpb.TensorSemantics(
165
+ dimensions=[dim.to_proto() for dim in self.dimensions],
166
+ )