From 6645d338c6726bfb1909c11d047e10f972621d65 Mon Sep 17 00:00:00 2001 From: ryoKaz Date: Thu, 27 Apr 2023 19:40:43 +0900 Subject: [PATCH 1/2] add create request results api --- fastlabel/__init__.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 8f2e4cc..a086229 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -3633,3 +3633,19 @@ def execute_endpoint( "file": utils.base64_encode(file_path), } return self.api.post_request(endpoint, payload=payload) + + def create_model_monitoring_request_results( + self, + name: str, + results: list = [], + ) -> str: + """ + Create model monitoring request results. + + name is an unique identifier of model monitoring setting in your workspace (Required). + """ + endpoint = "model-monitorings/create" + + payload = {"name": name, "results": results} + + return self.api.post_request(endpoint, payload=payload) From 78c36f3dbb26b9619d6c2776b995be9617819a32 Mon Sep 17 00:00:00 2001 From: ryoKaz Date: Mon, 8 May 2023 16:05:50 +0900 Subject: [PATCH 2/2] add readme --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ fastlabel/__init__.py | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 193ce11..a36d863 100644 --- a/README.md +++ b/README.md @@ -2680,6 +2680,46 @@ if __name__ == '__main__': cv2.imwrite(RESULT_IMAGE_FILE_PATH, img) ``` +## Model Monitoring +### Create Request Results +You can integrate the results of model endpoint calls, +which are targeted for aggregation in model monitoring, from an external source. + + +```python +from datetime import datetime +import pytz +import fastlabel +client = fastlabel.Client() + +jst = pytz.timezone("Asia/Tokyo") +dt_jst = datetime(2023, 5, 8, 12, 10, 53, tzinfo=jst) + +client.create_model_monitoring_request_results( + name="model-monitoring-name", # The name of your model monitoring name + results=[ + { + "status": "success", # success or failed + "result": [ + { + "annotationIndex": 0, # The index of the inference class returned by your model + "value": "person", # The value of the inference class returned by your model + "points": [ + 12.98, + 23.84, + 140.83, + 165.82, + ], # [x_min, y_min, x_max,y_max] + "confidenceScore": 0.92, # 0 ~ 1 + } + ], + "resultSchema": "object_detection_base", # Currently, only 'object_detection_base' can be selected. + "requestAt": dt_jst.isoformat(), # The time when your endpoint accepted the request + } + ], +) +``` + ## API Docs Check [this](https://api.fastlabel.ai/docs/) for further information. diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index a086229..58b8edd 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -3641,8 +3641,8 @@ def create_model_monitoring_request_results( ) -> str: """ Create model monitoring request results. - name is an unique identifier of model monitoring setting in your workspace (Required). + results is a list of request result to be set (Required). """ endpoint = "model-monitorings/create"