From 083126a46c2b2c2534f50d4c2d2fa945ec091235 Mon Sep 17 00:00:00 2001 From: ovalle15 Date: Wed, 28 Feb 2024 11:30:51 -0500 Subject: [PATCH 1/7] fix issues with ndjson composite mask --- examples/annotation_import/image.ipynb | 32 ++++---------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/examples/annotation_import/image.ipynb b/examples/annotation_import/image.ipynb index 0e5e81461..08fcb9311 100644 --- a/examples/annotation_import/image.ipynb +++ b/examples/annotation_import/image.ipynb @@ -108,7 +108,7 @@ { "metadata": {}, "source": [ - "API_KEY = \"\"\n", + "API_KEY =\"\"\n", "client = lb.Client(API_KEY)" ], "cell_type": "code", @@ -569,33 +569,9 @@ " )\n", "\n", "\n", - "# NDJSON using instanceURI, or bytes array - use one of the two options\n", + "# NDJSON using bytes array - use one of the two options\n", "cp_mask_ndjson = []\n", "\n", - "for color in colors:\n", - " if color in rgb_colors_for_mask_with_text_subclass_tool:\n", - " cp_mask_ndjson.append({\n", - " \"name\": \"mask_with_text_subclass\",\n", - " \"mask\": {\"instanceURI\": cp_mask_url,\n", - " \"colorRGB\": color },\n", - " \"classifications\":[{\n", - " \"name\": \"sub_free_text\",\n", - " \"answer\": \"free text answer\"\n", - " }]\n", - " }\n", - " )\n", - " else:\n", - " cp_mask_ndjson.append({\n", - " \"name\": \"mask\",\n", - " \"classifications\": [],\n", - " \"mask\": {\n", - " \"instanceURI\": cp_mask_url,\n", - " \"colorRGB\": color\n", - " }\n", - " }\n", - " )\n", - "\n", - "\n", "#Using bytes array.\n", "response = requests.get(cp_mask_url)\n", "im_bytes = base64.b64encode(response.content).decode('utf-8')\n", @@ -603,7 +579,7 @@ " if color in rgb_colors_for_mask_with_text_subclass_tool:\n", " cp_mask_ndjson.append({\n", " \"name\": \"mask_with_text_subclass\",\n", - " \"mask\": {\"instanceURI\": im_bytes,\n", + " \"mask\": {\"imBytes\": im_bytes, # You can also use instanceURI and pass the raw URL\n", " \"colorRGB\": color },\n", " \"classifications\":[{\n", " \"name\": \"sub_free_text\",\n", @@ -616,7 +592,7 @@ " \"name\": \"mask\",\n", " \"classifications\": [],\n", " \"mask\": {\n", - " \"instanceURI\": im_bytes,\n", + " \"imBytes\": im_bytes,\n", " \"colorRGB\": color\n", " }\n", " }\n", From 01999a302555fbf0a7b34bfece626b81c944737c Mon Sep 17 00:00:00 2001 From: ovalle15 Date: Wed, 28 Feb 2024 11:58:57 -0500 Subject: [PATCH 2/7] removed instance uri comment --- examples/annotation_import/image.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/annotation_import/image.ipynb b/examples/annotation_import/image.ipynb index 08fcb9311..f7137702a 100644 --- a/examples/annotation_import/image.ipynb +++ b/examples/annotation_import/image.ipynb @@ -579,7 +579,7 @@ " if color in rgb_colors_for_mask_with_text_subclass_tool:\n", " cp_mask_ndjson.append({\n", " \"name\": \"mask_with_text_subclass\",\n", - " \"mask\": {\"imBytes\": im_bytes, # You can also use instanceURI and pass the raw URL\n", + " \"mask\": {\"imBytes\": im_bytes,\n", " \"colorRGB\": color },\n", " \"classifications\":[{\n", " \"name\": \"sub_free_text\",\n", From 3e3e1748e8ef17b52f3382cf8793c1bc27825cbd Mon Sep 17 00:00:00 2001 From: ovalle15 Date: Wed, 28 Feb 2024 11:59:37 -0500 Subject: [PATCH 3/7] removed instance the other comment --- examples/annotation_import/image.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/annotation_import/image.ipynb b/examples/annotation_import/image.ipynb index f7137702a..f7204c201 100644 --- a/examples/annotation_import/image.ipynb +++ b/examples/annotation_import/image.ipynb @@ -569,7 +569,7 @@ " )\n", "\n", "\n", - "# NDJSON using bytes array - use one of the two options\n", + "# NDJSON using bytes array\n", "cp_mask_ndjson = []\n", "\n", "#Using bytes array.\n", From bfc1f068a85e09086ca1700986f1d4b79d7d7322 Mon Sep 17 00:00:00 2001 From: ovalle15 Date: Wed, 28 Feb 2024 13:36:56 -0500 Subject: [PATCH 4/7] Removed confidence from masks in prediction import, added annotation types to custom metrics demo --- .../custom_metrics_demo.ipynb | 387 +++++++++++++++++- .../prediction_upload/image_predictions.ipynb | 3 - 2 files changed, 376 insertions(+), 14 deletions(-) diff --git a/examples/model_diagnostics/custom_metrics_demo.ipynb b/examples/model_diagnostics/custom_metrics_demo.ipynb index 42b8575d1..ec2742817 100644 --- a/examples/model_diagnostics/custom_metrics_demo.ipynb +++ b/examples/model_diagnostics/custom_metrics_demo.ipynb @@ -55,7 +55,17 @@ "!pip install -q 'labelbox[data]'" ], "cell_type": "code", - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.0\u001b[0m\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n" + ] + } + ], "execution_count": null }, { @@ -105,6 +115,20 @@ { "metadata": {}, "source": [ + "radio_prediction = lb_types.ClassificationAnnotation(\n", + " name=\"radio_question\",\n", + " value=lb_types.Radio(\n", + " answer = lb_types.ClassificationAnswer(\n", + " name = \"second_radio_answer\", confidence=0.5,\n", + " custom_metrics=[{ 'name': 'iou', 'value': 0.1 },\n", + " { 'name': 'f1', 'value': 0.33 },\n", + " { 'name': 'precision', 'value': 0.55 },\n", + " { 'name': 'recall', 'value': 0.33 },\n", + " { 'name': 'tagsCount', 'value': 43 },\n", + " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }],\n", + " )\n", + " )\n", + ")\n", "\n", "# NDJSON\n", "radio_prediction_ndjson = {\n", @@ -135,10 +159,42 @@ { "metadata": {}, "source": [ + "checklist_prediction = lb_types.ClassificationAnnotation(\n", + " name=\"checklist_question\",\n", + " value=lb_types.Checklist(\n", + " answer = [\n", + " lb_types.ClassificationAnswer(\n", + " name = \"first_checklist_answer\",\n", + " confidence=0.5,\n", + " custom_metrics=[\n", + " { 'name': 'iou', 'value': 0.5 },\n", + " { 'name': 'f1', 'value': 0.33 },\n", + " { 'name': 'precision', 'value': 0.55 },\n", + " { 'name': 'recall', 'value': 0.33 },\n", + " { 'name': 'tagsCount', 'value': 43 },\n", + " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }\n", + " ]\n", + " ),\n", + " lb_types.ClassificationAnswer(\n", + " name = \"second_checklist_answer\",\n", + " confidence=0.5,\n", + " custom_metrics= [\n", + " { 'name': 'iou', 'value': 0.5 },\n", + " { 'name': 'f1', 'value': 0.33 },\n", + " { 'name': 'precision', 'value': 0.55 },\n", + " { 'name': 'recall', 'value': 0.33 },\n", + " { 'name': 'tagsCount', 'value': 43 },\n", + " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }\n", + " ]\n", + " )\n", + " ]\n", + " )\n", + " )\n", "checklist_prediction_ndjson = {\n", " 'name': 'checklist_question',\n", " 'answer': [\n", - " {'name': 'first_checklist_answer' , 'confidence': 0.5, 'customMetrics': [\n", + " {'name': 'first_checklist_answer' , 'confidence': 0.5,\n", + " 'customMetrics': [\n", " { 'name': 'iou', 'value': 0.5 },\n", " { 'name': 'f1', 'value': 0.33 },\n", " { 'name': 'precision', 'value': 0.55 },\n", @@ -146,7 +202,8 @@ " { 'name': 'tagsCount', 'value': 43 },\n", " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }\n", " ]},\n", - " {'name': 'second_checklist_answer', 'confidence': 0.5, 'customMetrics': [\n", + " {'name': 'second_checklist_answer', 'confidence': 0.5,\n", + " 'customMetrics': [\n", " { 'name': 'iou', 'value': 0.5 },\n", " { 'name': 'f1', 'value': 0.33 },\n", " { 'name': 'precision', 'value': 0.55 },\n", @@ -171,6 +228,43 @@ { "metadata": {}, "source": [ + "nested_radio_prediction = lb_types.ClassificationAnnotation(\n", + " name=\"nested_radio_question\",\n", + " value=lb_types.Radio(\n", + " answer=lb_types.ClassificationAnswer(\n", + " name=\"first_radio_answer\",\n", + " confidence=0.5,\n", + " custom_metrics=[\n", + " { 'name': 'iou', 'value': 0.5 },\n", + " { 'name': 'f1', 'value': 0.33 },\n", + " { 'name': 'precision', 'value': 0.55 },\n", + " { 'name': 'recall', 'value': 0.33 },\n", + " { 'name': 'tagsCount', 'value': 43 },\n", + " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }\n", + " ],\n", + " classifications=[\n", + " lb_types.ClassificationAnnotation(\n", + " name=\"sub_radio_question\",\n", + " value=lb_types.Radio(\n", + " answer=lb_types.ClassificationAnswer(\n", + " name=\"first_sub_radio_answer\",\n", + " confidence=0.5,\n", + " custom_metrics=[\n", + " { 'name': 'iou', 'value': 0.5 },\n", + " { 'name': 'f1', 'value': 0.33 },\n", + " { 'name': 'precision', 'value': 0.55 },\n", + " { 'name': 'recall', 'value': 0.33 },\n", + " { 'name': 'tagsCount', 'value': 43 },\n", + " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }\n", + " ]\n", + " )\n", + " )\n", + " )\n", + " ]\n", + " )\n", + " )\n", + ")\n", + "\n", "nested_radio_prediction_ndjson = {\n", " \"name\": \"nested_radio_question\",\n", " \"confidence\": 0.5 ,\n", @@ -201,6 +295,42 @@ " ]\n", "}\n", "\n", + "nested_checklist_prediction = lb_types.ClassificationAnnotation(\n", + " name=\"nested_checklist_question\",\n", + " value=lb_types.Checklist(\n", + " answer=[lb_types.ClassificationAnswer(\n", + " name=\"first_checklist_answer\",\n", + " confidence=0.5,\n", + " custom_metrics = [\n", + " { 'name': 'iou', 'value': 0.5 },\n", + " { 'name': 'f1', 'value': 0.33 },\n", + " { 'name': 'precision', 'value': 0.55 },\n", + " { 'name': 'recall', 'value': 0.33 },\n", + " { 'name': 'tagsCount', 'value': 43 },\n", + " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }\n", + " ],\n", + " classifications=[\n", + " lb_types.ClassificationAnnotation(\n", + " name=\"sub_checklist_question\",\n", + " value=lb_types.Checklist(\n", + " answer=[lb_types.ClassificationAnswer(\n", + " name=\"first_sub_checklist_answer\",\n", + " confidence=0.5,\n", + " custom_metrics= [\n", + " { 'name': 'iou', 'value': 0.5 },\n", + " { 'name': 'f1', 'value': 0.33 },\n", + " { 'name': 'precision', 'value': 0.55 },\n", + " { 'name': 'recall', 'value': 0.33 },\n", + " { 'name': 'tagsCount', 'value': 43 },\n", + " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }\n", + " ]\n", + " )]\n", + " ))\n", + " ]\n", + " )]\n", + " )\n", + ")\n", + "\n", "nested_checklist_prediction_ndjson = {\n", " \"name\": \"nested_checklist_question\",\n", " \"confidence\": 0.5 ,\n", @@ -246,6 +376,23 @@ { "metadata": {}, "source": [ + "bbox_prediction = lb_types.ObjectAnnotation(\n", + " name = \"bounding_box\",\n", + " confidence=0.5,\n", + " custom_metrics= [\n", + " { 'name': 'iou', 'value': 0.5 },\n", + " { 'name': 'f1', 'value': 0.33 },\n", + " { 'name': 'precision', 'value': 0.55 },\n", + " { 'name': 'recall', 'value': 0.33 },\n", + " { 'name': 'tagsCount', 'value': 43 },\n", + " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }\n", + " ],\n", + " value=lb_types.Rectangle(\n", + " start=lb_types.Point(x=1690, y=977), # x = left, y = top\n", + " end=lb_types.Point(x=1915, y=1307), # x= left + width , y = top + height\n", + " )\n", + ")\n", + "\n", "\n", "bbox_prediction_ndjson = {\n", " \"name\": \"bounding_box\",\n", @@ -280,6 +427,40 @@ { "metadata": {}, "source": [ + "bbox_with_radio_subclass_prediction = lb_types.ObjectAnnotation(\n", + " name=\"bbox_with_radio_subclass\",\n", + " confidence=0.5,\n", + " custom_metrics = [\n", + " { 'name': 'iou', 'value': 0.5 },\n", + " { 'name': 'f1', 'value': 0.2 },\n", + " { 'name': 'precision', 'value': 0.1 },\n", + " { 'name': 'recall', 'value': 0.3 },\n", + " { 'name': 'tagsCount', 'value': 23 },\n", + " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }\n", + " ],\n", + " value=lb_types.Rectangle(\n", + " start=lb_types.Point(x=541, y=933), # x = left, y = top\n", + " end=lb_types.Point(x=871, y=1124), # x= left + width , y = top + height\n", + " ),\n", + " classifications=[\n", + " \tlb_types.ClassificationAnnotation(\n", + " \tname=\"sub_radio_question\",\n", + " \t\tvalue=lb_types.Radio(\n", + " answer=lb_types.ClassificationAnswer(\n", + " name=\"first_sub_radio_answer\",\n", + " confidence=0.5,\n", + " custom_metrics =[\n", + " { 'name': 'iou', 'value': 0.5 },\n", + " { 'name': 'f1', 'value': 0.2 },\n", + " { 'name': 'precision', 'value': 0.1 },\n", + " { 'name': 'recall', 'value': 0.3 },\n", + " { 'name': 'tagsCount', 'value': 23 },\n", + " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }\n", + " ]\n", + " ))\n", + " )\n", + " ]\n", + ")\n", "## NDJSON\n", "bbox_with_radio_subclass_prediction_ndjson = {\n", " \"name\": \"bbox_with_radio_subclass\",\n", @@ -295,7 +476,16 @@ " \"classifications\": [{\n", " \"name\": \"sub_radio_question\",\n", " \"answer\":\n", - " { \"name\":\"first_sub_radio_answer\", \"confidence\": 0.5}\n", + " { \"name\":\"first_sub_radio_answer\",\n", + " \"confidence\": 0.5,\n", + " 'customMetrics': [\n", + " { 'name': 'iou', 'value': 0.5 },\n", + " { 'name': 'f1', 'value': 0.2 },\n", + " { 'name': 'precision', 'value': 0.1 },\n", + " { 'name': 'recall', 'value': 0.3 },\n", + " { 'name': 'tagsCount', 'value': 23 },\n", + " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }\n", + " ]}\n", "\n", " }],\n", " \"bbox\": {\n", @@ -320,6 +510,26 @@ { "metadata": {}, "source": [ + "# Python Anotation\n", + "polygon_prediction = lb_types.ObjectAnnotation(\n", + " name = \"polygon\",\n", + " confidence = 0.5,\n", + " custom_metrics = [\n", + " { 'name': 'iou', 'value': 0.5 },\n", + " { 'name': 'f1', 'value': 0.33 },\n", + " { 'name': 'precision', 'value': 0.55 },\n", + " { 'name': 'recall', 'value': 0.33 },\n", + " { 'name': 'tagsCount', 'value': 43 },\n", + " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }\n", + " ],\n", + " value=lb_types.Polygon(\n", + " points=[lb_types.Point(x=1489.581,y=183.934), lb_types.Point(x=2278.306,y=256.885), lb_types.Point(x=2428.197,y=200.437), lb_types.Point(x=2560.0,y=335.419),\n", + " lb_types.Point(x=2557.386,y=503.165), lb_types.Point(x=2320.596,y=503.103), lb_types.Point(x=2156.083, y=628.943), lb_types.Point(x=2161.111,y=785.519),\n", + " lb_types.Point(x=2002.115, y=894.647), lb_types.Point(x=1838.456,y=877.874), lb_types.Point(x=1436.53,y=874.636), lb_types.Point(x=1411.403,y=758.579),\n", + " lb_types.Point(x=1353.853,y=751.74), lb_types.Point(x=1345.264, y=453.461), lb_types.Point(x=1426.011,y=421.129)]\n", + " ),\n", + ")\n", + "\n", "polygon_prediction_ndjson = {\n", " \"name\": \"polygon\",\n", " \"confidence\": 0.5,\n", @@ -365,6 +575,24 @@ { "metadata": {}, "source": [ + "# Python annotation\n", + "text_annotation = lb_types.ClassificationAnnotation(\n", + " name=\"free_text\",\n", + " value=lb_types.Text(\n", + " answer=\"sample text\",\n", + " confidence=0.5,\n", + " custom_metrics = [\n", + " { 'name': 'iou', 'value': 0.5 },\n", + " { 'name': 'f1', 'value': 0.33 },\n", + " { 'name': 'precision', 'value': 0.55 },\n", + " { 'name': 'recall', 'value': 0.33 },\n", + " { 'name': 'tagsCount', 'value': 43 },\n", + " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }\n", + " ]\n", + " )\n", + ")\n", + "\n", + "\n", "text_annotation_ndjson = {\n", " \"name\": \"free_text\",\n", " \"answer\": \"sample text\",\n", @@ -393,6 +621,21 @@ { "metadata": {}, "source": [ + "# Python Annotation\n", + "point_prediction = lb_types.ObjectAnnotation(\n", + " name = \"point\",\n", + " confidence=0.5,\n", + " custom_metrics= [\n", + " { 'name': 'iou', 'value': 0.5 },\n", + " { 'name': 'f1', 'value': 0.33 },\n", + " { 'name': 'precision', 'value': 0.55 },\n", + " { 'name': 'recall', 'value': 0.33 },\n", + " { 'name': 'tagsCount', 'value': 43 },\n", + " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }\n", + " ],\n", + " value = lb_types.Point(x=1166.606, y=1441.768),\n", + ")\n", + "\n", "point_prediction_ndjson = {\n", " \"name\": \"point\",\n", " \"confidence\": 0.5,\n", @@ -422,6 +665,27 @@ { "metadata": {}, "source": [ + "polyline_prediction = lb_types.ObjectAnnotation(\n", + " name = \"polyline\",\n", + " confidence=0.5,\n", + " custom_metrics=[\n", + " { 'name': 'iou', 'value': 0.5 },\n", + " { 'name': 'f1', 'value': 0.33 },\n", + " { 'name': 'precision', 'value': 0.55 },\n", + " { 'name': 'recall', 'value': 0.33 },\n", + " { 'name': 'tagsCount', 'value': 43 },\n", + " { 'name': 'metric_with_a_very_long_name', 'value': 0.334332 }\n", + " ],\n", + " value=lb_types.Line(\n", + " points=[lb_types.Point(x=2534.353, y=249.471), lb_types.Point(x=2429.492, y=182.092), lb_types.Point(x=2294.322, y=221.962), lb_types.Point(x=2224.491, y=180.463), lb_types.Point(x=2136.123, y=204.716),\n", + " lb_types.Point(x=1712.247, y=173.949), lb_types.Point(x=1703.838, y=84.438), lb_types.Point(x=1579.772, y=82.61), lb_types.Point(x=1583.442, y=167.552),\n", + " lb_types.Point(x=1478.869, y=164.903), lb_types.Point(x=1418.941, y=318.149), lb_types.Point(x=1243.128, y=400.815), lb_types.Point(x=1022.067, y=319.007),\n", + " lb_types.Point(x=892.367, y=379.216), lb_types.Point(x=670.273, y=364.408), lb_types.Point(x=613.114, y=288.16), lb_types.Point(x=377.559, y=238.251),\n", + " lb_types.Point(x=368.087, y=185.064), lb_types.Point(x=246.557, y=167.286), lb_types.Point(x=236.648, y=285.61), lb_types.Point(x=90.929, y=326.412)]\n", + " ),\n", + ")\n", + "\n", + "\n", "polyline_prediction_ndjson = {\n", " \"name\": \"polyline\",\n", " \"confidence\":0.5,\n", @@ -494,7 +758,31 @@ " dataset.delete()" ], "cell_type": "code", - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "There are errors present. Please look at `task.errors` for more details\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Failed data rows: [{'message': \"Duplicate global key: '2560px-Kitano_Street_Kobe01s5s4110.jpeg'\", 'failedDataRows': [{'rowData': 'https://storage.googleapis.com/labelbox-datasets/image_sample_data/2560px-Kitano_Street_Kobe01s5s4110.jpeg', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}]}]\n", + "Errors: [{'message': \"Duplicate global key: '2560px-Kitano_Street_Kobe01s5s4110.jpeg'\", 'failedDataRows': [{'rowData': 'https://storage.googleapis.com/labelbox-datasets/image_sample_data/2560px-Kitano_Street_Kobe01s5s4110.jpeg', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}]}]\n", + "Deleting empty dataset: \n" + ] + } + ], "execution_count": null }, { @@ -631,7 +919,18 @@ "model_run.upsert_data_rows(global_keys=[global_key])" ], "cell_type": "code", - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 230, + "metadata": {}, + "output_type": "execute_result" + } + ], "execution_count": null }, { @@ -645,6 +944,33 @@ ], "cell_type": "markdown" }, + { + "metadata": {}, + "source": [ + "# Create a Label for predictions\n", + "label_prediction = []\n", + "label_prediction.append(lb_types.Label(\n", + " data=lb_types.ImageData(global_key=global_key),\n", + " annotations = [\n", + " radio_prediction,\n", + " nested_radio_prediction,\n", + " checklist_prediction,\n", + " nested_checklist_prediction,\n", + " bbox_prediction,\n", + " bbox_with_radio_subclass_prediction,\n", + " polyline_prediction,\n", + " polygon_prediction,\n", + " point_prediction,\n", + " text_annotation\n", + "\n", + " ]\n", + " )\n", + ")" + ], + "cell_type": "code", + "outputs": [], + "execution_count": null + }, { "metadata": {}, "source": [ @@ -691,13 +1017,21 @@ "# Upload the prediction label to the Model Run\n", "upload_job_prediction = model_run.add_predictions(\n", " name=\"prediction_upload_job\"+str(uuid.uuid4()),\n", - " predictions=label_prediction_ndjson)\n", + " predictions=label_prediction)\n", "\n", "# Errors will appear for prediction uploads that failed.\n", "print(\"Errors:\", upload_job_prediction.errors)" ], "cell_type": "code", - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Errors: []\n" + ] + } + ], "execution_count": null }, { @@ -745,7 +1079,18 @@ ")" ], "cell_type": "code", - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 235, + "metadata": {}, + "output_type": "execute_result" + } + ], "execution_count": null }, { @@ -922,7 +1267,16 @@ "print(\"Status of uploads: \", upload_job_annotation.statuses)" ], "cell_type": "code", - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Errors: []\n", + "Status of uploads: [{'uuid': 'e0f46046-8b22-4300-85e9-bdf776ea5fa9', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '03cc8876-7ad7-48e8-836f-ed4df411c272', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '9d6a04fb-180a-4d0d-832d-87e18619cd99', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '449b328f-497a-4528-bbef-e82561cbcbfd', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '2d6f51f0-1210-40e3-a670-12556c917677', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '2a8c5764-04df-46fe-a6a3-31dd261b6c4e', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '7a79d54e-d7bf-41fd-95f0-2f9e9c8e5850', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': 'f2de7bf8-f1c7-4832-9aef-cad3d9807af8', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '646c7199-9c31-43e5-9183-e6458ea3664c', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '12b9c5fe-e171-4191-985b-9b7fa43fb324', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}]\n" + ] + } + ], "execution_count": null }, { @@ -938,7 +1292,18 @@ "model_run.upsert_labels(project_id=project.uid)" ], "cell_type": "code", - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 239, + "metadata": {}, + "output_type": "execute_result" + } + ], "execution_count": null }, { diff --git a/examples/prediction_upload/image_predictions.ipynb b/examples/prediction_upload/image_predictions.ipynb index 593a0de10..7731d38a7 100644 --- a/examples/prediction_upload/image_predictions.ipynb +++ b/examples/prediction_upload/image_predictions.ipynb @@ -447,7 +447,6 @@ "mask_data = lb.types.MaskData(im_bytes=response.content) # You can also use \"url\" instead of img_bytes to pass the PNG mask url.\n", "mask_prediction = lb_types.ObjectAnnotation(\n", " name=\"mask\",\n", - " confidence=0.5,\n", " value=lb_types.Mask(\n", " mask=mask_data,\n", " color=(255, 255, 255))\n", @@ -456,7 +455,6 @@ "# NDJSON using instanceURI, bytes array is not fully supported.\n", "mask_prediction_ndjson = {\n", " \"name\": \"mask\",\n", - " \"confidence\": 0.5,\n", " \"classifications\": [],\n", " \"mask\": {\"instanceURI\": url,\n", " \"colorRGB\": (255, 255, 255)}\n", @@ -486,7 +484,6 @@ " name = \"mask_with_text_subclass\", # must match your ontology feature\"s name\n", " value=lb_types.Mask(\n", " mask=mask_data_2,\n", - " confidence=0.5,\n", " color=(255, 255, 255)),\n", " classifications=[\n", " lb_types.ClassificationAnnotation(\n", From 9739d610d93f9380bc26ffc269e842dbea8818cd Mon Sep 17 00:00:00 2001 From: ovalle15 Date: Wed, 28 Feb 2024 13:53:04 -0500 Subject: [PATCH 5/7] remove outputs --- .../custom_metrics_demo.ipynb | 98 ++----------------- 1 file changed, 7 insertions(+), 91 deletions(-) diff --git a/examples/model_diagnostics/custom_metrics_demo.ipynb b/examples/model_diagnostics/custom_metrics_demo.ipynb index ec2742817..437ba6d04 100644 --- a/examples/model_diagnostics/custom_metrics_demo.ipynb +++ b/examples/model_diagnostics/custom_metrics_demo.ipynb @@ -55,17 +55,7 @@ "!pip install -q 'labelbox[data]'" ], "cell_type": "code", - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.0\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n" - ] - } - ], + "outputs": [], "execution_count": null }, { @@ -758,31 +748,7 @@ " dataset.delete()" ], "cell_type": "code", - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "There are errors present. Please look at `task.errors` for more details\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Failed data rows: [{'message': \"Duplicate global key: '2560px-Kitano_Street_Kobe01s5s4110.jpeg'\", 'failedDataRows': [{'rowData': 'https://storage.googleapis.com/labelbox-datasets/image_sample_data/2560px-Kitano_Street_Kobe01s5s4110.jpeg', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}]}]\n", - "Errors: [{'message': \"Duplicate global key: '2560px-Kitano_Street_Kobe01s5s4110.jpeg'\", 'failedDataRows': [{'rowData': 'https://storage.googleapis.com/labelbox-datasets/image_sample_data/2560px-Kitano_Street_Kobe01s5s4110.jpeg', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}]}]\n", - "Deleting empty dataset: \n" - ] - } - ], + "outputs": [], "execution_count": null }, { @@ -919,18 +885,7 @@ "model_run.upsert_data_rows(global_keys=[global_key])" ], "cell_type": "code", - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 230, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "execution_count": null }, { @@ -1023,15 +978,7 @@ "print(\"Errors:\", upload_job_prediction.errors)" ], "cell_type": "code", - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Errors: []\n" - ] - } - ], + "outputs": [], "execution_count": null }, { @@ -1079,18 +1026,7 @@ ")" ], "cell_type": "code", - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 235, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "execution_count": null }, { @@ -1267,16 +1203,7 @@ "print(\"Status of uploads: \", upload_job_annotation.statuses)" ], "cell_type": "code", - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Errors: []\n", - "Status of uploads: [{'uuid': 'e0f46046-8b22-4300-85e9-bdf776ea5fa9', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '03cc8876-7ad7-48e8-836f-ed4df411c272', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '9d6a04fb-180a-4d0d-832d-87e18619cd99', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '449b328f-497a-4528-bbef-e82561cbcbfd', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '2d6f51f0-1210-40e3-a670-12556c917677', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '2a8c5764-04df-46fe-a6a3-31dd261b6c4e', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '7a79d54e-d7bf-41fd-95f0-2f9e9c8e5850', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': 'f2de7bf8-f1c7-4832-9aef-cad3d9807af8', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '646c7199-9c31-43e5-9183-e6458ea3664c', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}, {'uuid': '12b9c5fe-e171-4191-985b-9b7fa43fb324', 'dataRow': {'id': 'clf9spzxq029m071nehy60a6v', 'globalKey': '2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'status': 'SUCCESS'}]\n" - ] - } - ], + "outputs": [], "execution_count": null }, { @@ -1292,18 +1219,7 @@ "model_run.upsert_labels(project_id=project.uid)" ], "cell_type": "code", - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 239, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "execution_count": null }, { From 13d92ba2800e1d0612a3e120828e3d82102d7a10 Mon Sep 17 00:00:00 2001 From: ovalle15 Date: Wed, 28 Feb 2024 16:48:07 -0500 Subject: [PATCH 6/7] updated folder structure and path --- .../model_diagnostics/custom_metrics_basics.ipynb | 4 ++-- .../model_diagnostics/custom_metrics_demo.ipynb | 4 ++-- .../model_diagnostics/model_diagnostics_demo.ipynb | 4 ++-- .../model_diagnostics/model_diagnostics_guide.ipynb | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) rename examples/{ => model_experiments}/model_diagnostics/custom_metrics_basics.ipynb (98%) rename examples/{ => model_experiments}/model_diagnostics/custom_metrics_demo.ipynb (99%) rename examples/{ => model_experiments}/model_diagnostics/model_diagnostics_demo.ipynb (98%) rename examples/{ => model_experiments}/model_diagnostics/model_diagnostics_guide.ipynb (97%) diff --git a/examples/model_diagnostics/custom_metrics_basics.ipynb b/examples/model_experiments/model_diagnostics/custom_metrics_basics.ipynb similarity index 98% rename from examples/model_diagnostics/custom_metrics_basics.ipynb rename to examples/model_experiments/model_diagnostics/custom_metrics_basics.ipynb index 6c5c54ffb..8cacfb8b1 100644 --- a/examples/model_diagnostics/custom_metrics_basics.ipynb +++ b/examples/model_experiments/model_diagnostics/custom_metrics_basics.ipynb @@ -16,12 +16,12 @@ "metadata": {}, "source": [ "\n", - "\n", "\n", "\n", "\n", - "\n", "" ], diff --git a/examples/model_diagnostics/custom_metrics_demo.ipynb b/examples/model_experiments/model_diagnostics/custom_metrics_demo.ipynb similarity index 99% rename from examples/model_diagnostics/custom_metrics_demo.ipynb rename to examples/model_experiments/model_diagnostics/custom_metrics_demo.ipynb index 437ba6d04..d18119c2c 100644 --- a/examples/model_diagnostics/custom_metrics_demo.ipynb +++ b/examples/model_experiments/model_diagnostics/custom_metrics_demo.ipynb @@ -17,12 +17,12 @@ "source": [ "\n", "\n", - "\n", "\n", "\n", "\n", - "\n", "" ], diff --git a/examples/model_diagnostics/model_diagnostics_demo.ipynb b/examples/model_experiments/model_diagnostics/model_diagnostics_demo.ipynb similarity index 98% rename from examples/model_diagnostics/model_diagnostics_demo.ipynb rename to examples/model_experiments/model_diagnostics/model_diagnostics_demo.ipynb index 5c728f979..914ac9801 100644 --- a/examples/model_diagnostics/model_diagnostics_demo.ipynb +++ b/examples/model_experiments/model_diagnostics/model_diagnostics_demo.ipynb @@ -16,12 +16,12 @@ "metadata": {}, "source": [ "\n", - "\n", "\n", "\n", "\n", - "\n", "" ], diff --git a/examples/model_diagnostics/model_diagnostics_guide.ipynb b/examples/model_experiments/model_diagnostics/model_diagnostics_guide.ipynb similarity index 97% rename from examples/model_diagnostics/model_diagnostics_guide.ipynb rename to examples/model_experiments/model_diagnostics/model_diagnostics_guide.ipynb index 9c355fcb1..4dae1cb8c 100644 --- a/examples/model_diagnostics/model_diagnostics_guide.ipynb +++ b/examples/model_experiments/model_diagnostics/model_diagnostics_guide.ipynb @@ -16,12 +16,12 @@ "metadata": {}, "source": [ "\n", - "\n", "\n", "\n", "\n", - "\n", "" ], @@ -352,4 +352,4 @@ "execution_count": null } ] -} +} \ No newline at end of file From 14210181751a0ce743c58b7beb003d5b198fa607 Mon Sep 17 00:00:00 2001 From: ovalle15 Date: Wed, 28 Feb 2024 16:48:31 -0500 Subject: [PATCH 7/7] updated folder structure and path --- .../model_diagnostics/custom_metrics_basics.ipynb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/examples/model_experiments/model_diagnostics/custom_metrics_basics.ipynb b/examples/model_experiments/model_diagnostics/custom_metrics_basics.ipynb index 8cacfb8b1..ea7312f6a 100644 --- a/examples/model_experiments/model_diagnostics/custom_metrics_basics.ipynb +++ b/examples/model_experiments/model_diagnostics/custom_metrics_basics.ipynb @@ -27,16 +27,6 @@ ], "cell_type": "markdown" }, - { - "metadata": {}, - "source": [ - " \n", - "\n", - " \n", - "" - ], - "cell_type": "markdown" - }, { "metadata": {}, "source": [