Skip to content

Commit 71555fe

Browse files
authored
Merge pull request #150 from fastlabel/feature/model-monitoring
add create request results api
2 parents 9243e28 + 78c36f3 commit 71555fe

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2680,6 +2680,46 @@ if __name__ == '__main__':
26802680
cv2.imwrite(RESULT_IMAGE_FILE_PATH, img)
26812681
```
26822682

2683+
## Model Monitoring
2684+
### Create Request Results
2685+
You can integrate the results of model endpoint calls,
2686+
which are targeted for aggregation in model monitoring, from an external source.
2687+
2688+
2689+
```python
2690+
from datetime import datetime
2691+
import pytz
2692+
import fastlabel
2693+
client = fastlabel.Client()
2694+
2695+
jst = pytz.timezone("Asia/Tokyo")
2696+
dt_jst = datetime(2023, 5, 8, 12, 10, 53, tzinfo=jst)
2697+
2698+
client.create_model_monitoring_request_results(
2699+
name="model-monitoring-name", # The name of your model monitoring name
2700+
results=[
2701+
{
2702+
"status": "success", # success or failed
2703+
"result": [
2704+
{
2705+
"annotationIndex": 0, # The index of the inference class returned by your model
2706+
"value": "person", # The value of the inference class returned by your model
2707+
"points": [
2708+
12.98,
2709+
23.84,
2710+
140.83,
2711+
165.82,
2712+
], # [x_min, y_min, x_max,y_max]
2713+
"confidenceScore": 0.92, # 0 ~ 1
2714+
}
2715+
],
2716+
"resultSchema": "object_detection_base", # Currently, only 'object_detection_base' can be selected.
2717+
"requestAt": dt_jst.isoformat(), # The time when your endpoint accepted the request
2718+
}
2719+
],
2720+
)
2721+
```
2722+
26832723
## API Docs
26842724

26852725
Check [this](https://api.fastlabel.ai/docs/) for further information.

fastlabel/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3633,3 +3633,19 @@ def execute_endpoint(
36333633
"file": utils.base64_encode(file_path),
36343634
}
36353635
return self.api.post_request(endpoint, payload=payload)
3636+
3637+
def create_model_monitoring_request_results(
3638+
self,
3639+
name: str,
3640+
results: list = [],
3641+
) -> str:
3642+
"""
3643+
Create model monitoring request results.
3644+
name is an unique identifier of model monitoring setting in your workspace (Required).
3645+
results is a list of request result to be set (Required).
3646+
"""
3647+
endpoint = "model-monitorings/create"
3648+
3649+
payload = {"name": name, "results": results}
3650+
3651+
return self.api.post_request(endpoint, payload=payload)

0 commit comments

Comments
 (0)