|
75 | 75 | "metadata": {}, |
76 | 76 | "source": [ |
77 | 77 | "import labelbox.types as lb_types\n", |
| 78 | + "import labelbox as lb\n", |
| 79 | + "import uuid\n", |
78 | 80 | "import json" |
79 | 81 | ], |
80 | 82 | "cell_type": "code", |
|
121 | 123 | { |
122 | 124 | "metadata": {}, |
123 | 125 | "source": [ |
124 | | - "data_row_metric = ScalarMetric(metric_name=\"iou\", value=0.5)\n", |
| 126 | + "data_row_metric = ScalarMetric(metric_name=\"iou_custom\", value=0.5)\n", |
125 | 127 | "\n", |
126 | | - "feature_metric = ScalarMetric(metric_name=\"iou\", feature_name=\"cat\", value=0.5)\n", |
| 128 | + "feature_metric = ScalarMetric(metric_name=\"iou_custom\", feature_name=\"cat\", value=0.5)\n", |
127 | 129 | "\n", |
128 | | - "subclass_metric = ScalarMetric(metric_name=\"iou\",\n", |
| 130 | + "subclass_metric = ScalarMetric(metric_name=\"iou_custom\",\n", |
129 | 131 | " feature_name=\"cat\",\n", |
130 | 132 | " subclass_name=\"organge\",\n", |
131 | 133 | " value=0.5)" |
|
192 | 194 | " 0.9: [1, 0, 1, 0]\n", |
193 | 195 | " })\n", |
194 | 196 | "\n", |
195 | | - "scalar_metric_with_confidence = ScalarMetric(metric_name=\"iou\",\n", |
| 197 | + "scalar_metric_with_confidence = ScalarMetric(metric_name=\"iou_custom\",\n", |
196 | 198 | " value={\n", |
197 | 199 | " 0.1: 0.2,\n", |
198 | 200 | " 0.3: 0.25,\n", |
|
300 | 302 | "print(feature_confusion_matrix_metric(ground_truths, predictions))" |
301 | 303 | ], |
302 | 304 | "cell_type": "code", |
303 | | - "outputs": [ |
304 | | - { |
305 | | - "name": "stdout", |
306 | | - "output_type": "stream", |
307 | | - "text": [ |
308 | | - "[ScalarMetric(value=0.64, feature_name='cat', subclass_name=None, extra={}, metric_name='iou', aggregation=<ScalarMetricAggregation.ARITHMETIC_MEAN: 'ARITHMETIC_MEAN'>)]\n", |
309 | | - "[ScalarMetric(value=0.64, feature_name=None, subclass_name=None, extra={}, metric_name='iou', aggregation=<ScalarMetricAggregation.ARITHMETIC_MEAN: 'ARITHMETIC_MEAN'>)]\n", |
310 | | - "[ConfusionMatrixMetric(value=(1, 0, 0, 0), feature_name=None, subclass_name=None, extra={}, metric_name='50pct_iou', aggregation=<ConfusionMatrixAggregation.CONFUSION_MATRIX: 'CONFUSION_MATRIX'>)]\n", |
311 | | - "[ConfusionMatrixMetric(value=(1, 0, 0, 0), feature_name='cat', subclass_name=None, extra={}, metric_name='50pct_iou', aggregation=<ConfusionMatrixAggregation.CONFUSION_MATRIX: 'CONFUSION_MATRIX'>)]\n" |
312 | | - ] |
313 | | - } |
314 | | - ], |
| 305 | + "outputs": [], |
315 | 306 | "execution_count": null |
316 | 307 | }, |
317 | 308 | { |
|
322 | 313 | "print(feature_confusion_matrix_metric(ground_truths, predictions, iou=0.9))" |
323 | 314 | ], |
324 | 315 | "cell_type": "code", |
325 | | - "outputs": [ |
326 | | - { |
327 | | - "name": "stdout", |
328 | | - "output_type": "stream", |
329 | | - "text": [ |
330 | | - "[ConfusionMatrixMetric(value=(0, 1, 0, 1), feature_name='cat', subclass_name=None, extra={}, metric_name='90pct_iou', aggregation=<ConfusionMatrixAggregation.CONFUSION_MATRIX: 'CONFUSION_MATRIX'>)]\n" |
331 | | - ] |
332 | | - } |
333 | | - ], |
| 316 | + "outputs": [], |
334 | 317 | "execution_count": null |
335 | 318 | }, |
336 | 319 | { |
337 | 320 | "metadata": {}, |
338 | 321 | "source": [ |
| 322 | + "\n", |
339 | 323 | "# subclasses are included by default\n", |
340 | 324 | "predictions = [\n", |
341 | 325 | " lb_types.ObjectAnnotation(\n", |
|
375 | 359 | "print(\"Excluding Subclasses:\", iou_metrics[0].value)" |
376 | 360 | ], |
377 | 361 | "cell_type": "code", |
378 | | - "outputs": [ |
379 | | - { |
380 | | - "name": "stdout", |
381 | | - "output_type": "stream", |
382 | | - "text": [ |
383 | | - "Subclasses: (0, 1, 0, 1)\n", |
384 | | - "Excluding Subclasses: (1, 0, 0, 0)\n" |
385 | | - ] |
386 | | - } |
387 | | - ], |
| 362 | + "outputs": [], |
388 | 363 | "execution_count": null |
389 | 364 | }, |
390 | 365 | { |
|
404 | 379 | "metadata": {}, |
405 | 380 | "source": [ |
406 | 381 | "# Continuing with the last example:\n", |
| 382 | + "global_key = \"<global_key>\"\n", |
407 | 383 | "metrics = [*conf_matrix_metrics, *iou_metrics]\n", |
408 | 384 | "labels = [\n", |
409 | | - " lb_types.Label(data=lb_types.ImageData(uid=\"cktiom8osh4210ytmevuk7lfh\"), annotations=metrics)\n", |
| 385 | + " lb_types.Label(data=lb_types.ImageData(global_key=global_key), annotations=metrics)\n", |
410 | 386 | "]\n", |
411 | 387 | "# We can upload these metric with other annotations\n", |
412 | 388 | "#model_run.add_predictions(f'diagnostics-import-{uuid.uuid4()}', labels)" |
|
0 commit comments