diff --git a/examples/annotation_import/tiled.ipynb b/examples/annotation_import/tiled.ipynb index 4ba73975a..7d63979be 100644 --- a/examples/annotation_import/tiled.ipynb +++ b/examples/annotation_import/tiled.ipynb @@ -87,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 72, + "execution_count": 49, "id": "voluntary-minister", "metadata": { "id": "voluntary-minister" @@ -99,7 +99,7 @@ }, { "cell_type": "code", - "execution_count": 73, + "execution_count": 50, "id": "committed-richards", "metadata": { "id": "committed-richards" @@ -113,16 +113,13 @@ "import cv2\n", "import ndjson\n", "\n", - "from labelbox import Client, LabelingFrontend, LabelImport, MALPredictionImport, OntologyBuilder, Tool , Classification, MediaType, Option\n", + "import labelbox as lb\n", + "import labelbox.data.annotation_types as lb_types\n", + "import labelbox.schema.queue_mode as lb_queue_mode\n", + "\n", "from labelbox.data.serialization.ndjson.converter import NDJsonConverter\n", "from labelbox.data.annotation_types.data.tiled_image import TiledBounds, TiledImageData, TileLayer, EPSG, EPSGTransformer\n", - "from labelbox.schema.queue_mode import QueueMode\n", - "from labelbox.data.annotation_types import (\n", - " Label, ImageData, ObjectAnnotation, \n", - " Rectangle, Point, Line, Polygon,\n", - " Radio, Checklist, Text,MaskData, Mask,\n", - " ClassificationAnnotation, ClassificationAnswer\n", - ")\n" + "\n" ] }, { @@ -138,7 +135,7 @@ }, { "cell_type": "code", - "execution_count": 74, + "execution_count": 51, "id": "affecting-myanmar", "metadata": { "id": "affecting-myanmar" @@ -146,7 +143,7 @@ "outputs": [], "source": [ "API_KEY = None\n", - "client = Client(API_KEY)" + "client = lb.Client(API_KEY)" ] }, { @@ -175,9 +172,9 @@ "####### Point #######\n", "\n", "# Python Annotation\n", - "point_annotation = ObjectAnnotation(\n", + "point_annotation = lb_types.ObjectAnnotation(\n", " name = \"point_geo\",\n", - " value = Point(x=-122.31741025134123, y=37.87355669249922),\n", + " value = lb_types.Point(x=-122.31741025134123, y=37.87355669249922),\n", ")\n", "\n", "# NDJSON\n", @@ -193,7 +190,7 @@ "id": "3mQh-yQ2TLmd" }, "id": "3mQh-yQ2TLmd", - "execution_count": 75, + "execution_count": 52, "outputs": [] }, { @@ -220,16 +217,15 @@ "line_points_ndjson = []\n", "\n", "for sub in coords: \n", - " line_points.append(Point(x=sub[0], y=sub[1]))\n", + " line_points.append(lb_types.Point(x=sub[0], y=sub[1]))\n", " line_points_ndjson.append({\"x\":sub[0], \"y\":sub[1]})\n", "\n", "# Python Annotation \n", - "polyline_annotation = ObjectAnnotation(\n", + "polyline_annotation = lb_types.ObjectAnnotation(\n", " name = \"polyline_geo\",\n", - " value = Line(points=line_points),\n", + " value = lb_types.Line(points=line_points),\n", ")\n", "\n", - "\n", "# NDJSON \n", "polyline_annotation_ndjson = {\n", " \"name\": \"polyline_geo\",\n", @@ -240,7 +236,7 @@ "id": "f3OoBByTTYda" }, "id": "f3OoBByTTYda", - "execution_count": 76, + "execution_count": 53, "outputs": [] }, { @@ -271,13 +267,13 @@ "polygon_points_ndjson = []\n", "\n", "for sub in coords_polygon: \n", - " polygon_points.append(Point(x=sub[0], y=sub[1]))\n", + " polygon_points.append(lb_types.Point(x=sub[0], y=sub[1]))\n", " polygon_points_ndjson.append({\"x\":sub[0], \"y\":sub[1]})\n", "\n", "# Python Annotation \n", - "polygon_annotation = ObjectAnnotation(\n", + "polygon_annotation = lb_types.ObjectAnnotation(\n", " name = \"polygon_geo\",\n", - " value = Polygon(points=polygon_points),\n", + " value = lb_types.Polygon(points=polygon_points),\n", ")\n", "\n", "# NDJSON \n", @@ -290,7 +286,7 @@ "id": "BSjRhlFvTdfS" }, "id": "BSjRhlFvTdfS", - "execution_count": 77, + "execution_count": 54, "outputs": [] }, { @@ -325,13 +321,13 @@ " }\n", "\n", "\n", - "bbox_top_left = Point(x=-122.31734455895823, y=37.873713376083884)\n", - "bbox_bottom_right = Point(x=-122.31673038840458, y=37.87385944699745)\n", + "bbox_top_left = lb_types.Point(x=-122.31734455895823, y=37.873713376083884)\n", + "bbox_bottom_right = lb_types.Point(x=-122.31673038840458, y=37.87385944699745)\n", "\n", "# Python Annotation\n", - "bbox_annotation = ObjectAnnotation(\n", + "bbox_annotation = lb_types.ObjectAnnotation(\n", " name = \"bbox_geo\",\n", - " value = Rectangle(start=bbox_top_left, end=bbox_bottom_right)\n", + " value = lb_types.Rectangle(start=bbox_top_left, end=bbox_bottom_right)\n", ")\n", "\n", "\n", @@ -350,7 +346,7 @@ "id": "oLX3adDOTmYS" }, "id": "oLX3adDOTmYS", - "execution_count": 78, + "execution_count": 55, "outputs": [] }, { @@ -359,11 +355,12 @@ "####### Classification - radio (single choice) #######\n", "\n", "# Python Annotation \n", - "radio_annotation = ClassificationAnnotation(\n", + "radio_annotation = lb_types.ClassificationAnnotation(\n", " name=\"radio_question_geo\", \n", - " value=Radio(answer=ClassificationAnswer(name=\"first_radio_answer\"))\n", + " value=lb_types.Radio(answer=lb_types.ClassificationAnswer(name=\"first_radio_answer\"))\n", ")\n", "\n", + "\n", "# NDJSON \n", "radio_annotation_ndjson = {\n", " \"name\": \"radio_question_geo\",\n", @@ -374,7 +371,7 @@ "id": "OsWf8Y_mTxLm" }, "id": "OsWf8Y_mTxLm", - "execution_count": 79, + "execution_count": 56, "outputs": [] }, { @@ -410,17 +407,17 @@ "}\n", "\n", "# Python Annotation\n", - "bbox_with_checklist_subclass = ObjectAnnotation(\n", + "bbox_with_checklist_subclass = lb_types.ObjectAnnotation(\n", " name=\"bbox_checklist_geo\",\n", - " value=Rectangle(\n", - " start=Point(x=-122.31711256877092, y=37.87340218056304), # Top left\n", - " end=Point(x=-122.31665529331502, y=37.87360752741479), # Bottom right\n", + " value=lb_types.Rectangle(\n", + " start=lb_types.Point(x=-122.31711256877092, y=37.87340218056304), # Top left\n", + " end=lb_types.Point(x=-122.31665529331502, y=37.87360752741479), # Bottom right\n", " ),\n", " classifications=[\n", - " ClassificationAnnotation(\n", + " lb_types.ClassificationAnnotation(\n", " name=\"checklist_class_name\",\n", - " value=Checklist(\n", - " answer=[ClassificationAnswer(name=\"first_checklist_answer\")]\n", + " value=lb_types.Checklist(\n", + " answer=[lb_types.ClassificationAnswer(name=\"first_checklist_answer\")]\n", " )\n", " )\n", " ]\n", @@ -448,7 +445,7 @@ "id": "2IZXIWP2UcOJ" }, "id": "2IZXIWP2UcOJ", - "execution_count": 80, + "execution_count": 57, "outputs": [] }, { @@ -483,16 +480,16 @@ " ]\n", "}\n", "# Python Annotation\n", - "bbox_with_free_text_subclass = ObjectAnnotation(\n", + "bbox_with_free_text_subclass = lb_types.ObjectAnnotation(\n", " name=\"bbox_text_geo\",\n", - " value=Rectangle(\n", - " start=Point(x=-122.31750814315438, y=37.87318201423049), # Top left\n", - " end=Point(x=-122.31710049991725, y=37.87337992476082), # Bottom right\n", + " value=lb_types.Rectangle(\n", + " start=lb_types.Point(x=-122.31750814315438, y=37.87318201423049), # Top left\n", + " end=lb_types.Point(x=-122.31710049991725, y=37.87337992476082), # Bottom right\n", " ),\n", " classifications=[\n", - " ClassificationAnnotation(\n", + " lb_types.ClassificationAnnotation(\n", " name=\"free_text_geo\",\n", - " value=Text(answer=\"sample text\")\n", + " value=lb_types.Text(answer=\"sample text\")\n", " )\n", " ]\n", ")\n", @@ -516,7 +513,7 @@ "id": "bnjcIB7FU21R" }, "id": "bnjcIB7FU21R", - "execution_count": 81, + "execution_count": 58, "outputs": [] }, { @@ -525,16 +522,17 @@ "####### Classification - Checklist (multi-choice) #######\n", "\n", "# Python Annotation\n", - "checklist_annotation = ClassificationAnnotation(\n", + "checklist_annotation = lb_types.ClassificationAnnotation(\n", " name=\"checklist_question_geo\",\n", - " value=Checklist(answer = [\n", - " ClassificationAnswer(name = \"first_checklist_answer\"),\n", - " ClassificationAnswer(name = \"second_checklist_answer\"),\n", - " ClassificationAnswer(name = \"third_checklist_answer\")\n", + " value=lb_types.Checklist(answer = [\n", + " lb_types.ClassificationAnswer(name = \"first_checklist_answer\"),\n", + " lb_types.ClassificationAnswer(name = \"second_checklist_answer\"),\n", + " lb_types.ClassificationAnswer(name = \"third_checklist_answer\")\n", " ])\n", " )\n", "\n", "\n", + "\n", "# NDJSON\n", "checklist_annotation_ndjson = {\n", " 'name': 'checklist_question_geo',\n", @@ -549,7 +547,39 @@ "id": "hIkLI1q7glMi" }, "id": "hIkLI1q7glMi", - "execution_count": 82, + "execution_count": 59, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "###### Nested Classifications ########\n", + "nested_radio_classification_ndjson = {\n", + " 'name': 'radio_question_nested',\n", + " 'answer': {'name': 'first_radio_question'},\n", + " 'classifications' : [\n", + " {'name': 'sub_question_radio', 'answer': {'name': 'sub_answer'}}\n", + " ]\n", + "}\n", + "\n", + "nested_checklist_annotation_ndjson = {\n", + " \"name\": \"nested_checklist_question\",\n", + " \"answer\": [{\n", + " \"name\": \"first_checklist_answer\",\n", + " \"classifications\" : [\n", + " {\n", + " \"name\": \"sub_checklist_question\",\n", + " \"answer\": {\"name\": \"first_sub_checklist_answer\"}\n", + " }\n", + " ]\n", + " }]\n", + "}" + ], + "metadata": { + "id": "MZ7XExt8Cx4H" + }, + "id": "MZ7XExt8Cx4H", + "execution_count": 60, "outputs": [] }, { @@ -574,14 +604,14 @@ }, { "cell_type": "code", - "execution_count": 83, + "execution_count": 61, "id": "IlwNSdRQB4gC", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "IlwNSdRQB4gC", - "outputId": "af2d84eb-d88d-410a-9d99-7aa31e313785" + "outputId": "0ed3087a-a903-4153-a894-4de486c48619" }, "outputs": [ { @@ -594,8 +624,8 @@ ], "source": [ "\n", - "top_left_bound = Point(x=-122.31764674186705, y=37.87276155898985)\n", - "bottom_right_bound = Point(x=-122.31635199317932, y=37.87398109727749)\n", + "top_left_bound = lb_types.Point(x=-122.31764674186705, y=37.87276155898985)\n", + "bottom_right_bound = lb_types.Point(x=-122.31635199317932, y=37.87398109727749)\n", "\n", "epsg = EPSG.EPSG4326\n", "bounds = TiledBounds(epsg=epsg, bounds=[top_left_bound, bottom_right_bound])\n", @@ -627,66 +657,97 @@ }, { "cell_type": "code", - "execution_count": 84, + "execution_count": 62, "id": "suburban-crowd", "metadata": { "id": "suburban-crowd" }, "outputs": [], "source": [ - "ontology_builder = OntologyBuilder(\n", + "ontology_builder = lb.OntologyBuilder(\n", " tools=[\n", - " Tool(tool=Tool.Type.POINT, name=\"point_geo\"),\n", - " Tool(tool=Tool.Type.LINE, name=\"polyline_geo\"),\n", - " Tool(tool=Tool.Type.POLYGON, name=\"polygon_geo\"),\n", - " Tool(tool=Tool.Type.POLYGON, name=\"polygon_geo_2\"),\n", - " Tool(tool=Tool.Type.BBOX, name=\"bbox_geo\"), \n", - " Tool( \n", - " tool=Tool.Type.BBOX, \n", + " lb.Tool(tool=lb.Tool.Type.POINT, name=\"point_geo\"),\n", + " lb.Tool(tool=lb.Tool.Type.LINE, name=\"polyline_geo\"),\n", + " lb.Tool(tool=lb.Tool.Type.POLYGON, name=\"polygon_geo\"),\n", + " lb.Tool(tool=lb.Tool.Type.POLYGON, name=\"polygon_geo_2\"),\n", + " lb.Tool(tool=lb.Tool.Type.BBOX, name=\"bbox_geo\"), \n", + " lb.Tool( \n", + " tool=lb.Tool.Type.BBOX, \n", " name=\"bbox_checklist_geo\",\n", " classifications=[\n", - " Classification(\n", - " class_type=Classification.Type.CHECKLIST,\n", - " instructions=\"checklist_class_name\",\n", + " lb.Classification(\n", + " class_type=lb.Classification.Type.CHECKLIST,\n", + " name=\"checklist_class_name\",\n", " options=[\n", - " Option(value=\"first_checklist_answer\")\n", + " lb.Option(value=\"first_checklist_answer\")\n", " ]\n", " ),\n", " ]\n", " ),\n", - " Tool( \n", - " tool=Tool.Type.BBOX, \n", + " lb.Tool( \n", + " tool=lb.Tool.Type.BBOX, \n", " name=\"bbox_text_geo\",\n", " classifications=[\n", - " Classification(\n", - " class_type=Classification.Type.TEXT,\n", - " instructions=\"free_text_geo\"\n", + " lb.Classification(\n", + " class_type=lb.Classification.Type.TEXT,\n", + " name=\"free_text_geo\"\n", " ),\n", " ]\n", " ) \n", " ],\n", " classifications = [\n", - " Classification(\n", - " class_type=Classification.Type.CHECKLIST, \n", - " instructions=\"checklist_question_geo\",\n", + " lb.Classification(\n", + " class_type=lb.Classification.Type.CHECKLIST, \n", + " name=\"checklist_question_geo\",\n", " options=[\n", - " Option(value=\"first_checklist_answer\"),\n", - " Option(value=\"second_checklist_answer\"), \n", - " Option(value=\"third_checklist_answer\")\n", + " lb.Option(value=\"first_checklist_answer\"),\n", + " lb.Option(value=\"second_checklist_answer\"), \n", + " lb.Option(value=\"third_checklist_answer\")\n", " ]\n", " ), \n", - " Classification(\n", - " class_type=Classification.Type.RADIO, \n", - " instructions=\"radio_question_geo\",\n", + " lb.Classification(\n", + " class_type=lb.Classification.Type.RADIO, \n", + " name=\"radio_question_geo\",\n", " options=[\n", - " Option(value=\"first_radio_answer\")\n", + " lb.Option(value=\"first_radio_answer\")\n", " ]\n", - " )\n", + " ),\n", + " \n", + " lb.Classification(\n", + " class_type=lb.Classification.Type.RADIO,\n", + " name=\"radio_question_nested\",\n", + " options=[\n", + " lb.Option(\"first_radio_question\",\n", + " options=[\n", + " lb.Classification(\n", + " class_type=lb.Classification.Type.RADIO,\n", + " name=\"sub_question_radio\",\n", + " options=[lb.Option(\"sub_answer\")]\n", + " )\n", + " ]\n", + " )\n", + " ] \n", + " ),\n", + " lb.Classification(\n", + " class_type=lb.Classification.Type.CHECKLIST,\n", + " name=\"nested_checklist_question\",\n", + " options=[\n", + " lb.Option(\"first_checklist_answer\",\n", + " options=[\n", + " lb.Classification(\n", + " class_type=lb.Classification.Type.CHECKLIST,\n", + " name=\"sub_checklist_question\",\n", + " options=[lb.Option(\"first_sub_checklist_answer\")]\n", + " )\n", + " ]\n", + " )\n", + " ]\n", + " )\n", " \n", " ]\n", ")\n", "\n", - "ontology = client.create_ontology(\"Ontology Geospatial Annotations\", ontology_builder.asdict())" + "ontology = client.create_ontology(\"Ontology Geospatial Annotations\", ontology_builder.asdict(), media_type=lb.MediaType.Geospatial_Tile)" ] }, { @@ -702,7 +763,7 @@ }, { "cell_type": "code", - "execution_count": 85, + "execution_count": 63, "id": "PhfXaqDB7hRt", "metadata": { "id": "PhfXaqDB7hRt" @@ -713,8 +774,8 @@ "# Queue mode will be deprecated once dataset mode is deprecated\n", "\n", "project = client.create_project(name=\"geospatial_project_demo\",\n", - " queue_mode=QueueMode.Batch,\n", - " media_type=MediaType.Geospatial_Tile)\n", + " queue_mode=lb_queue_mode.QueueMode.Batch,\n", + " media_type=lb.MediaType.Geospatial_Tile)\n", "\n", "\n", "project.setup_editor(ontology)\n", @@ -764,10 +825,10 @@ "base_uri": "https://localhost:8080/" }, "id": "FHXR6nyKw-8f", - "outputId": "5b53a7ee-093c-4518-eac8-5ef7936510e2" + "outputId": "1ee25460-b4a4-4500-ab27-795923da21f7" }, "id": "FHXR6nyKw-8f", - "execution_count": 86, + "execution_count": 64, "outputs": [ { "output_type": "stream", @@ -775,11 +836,11 @@ "text": [ "Batch: \n" ] } @@ -814,36 +875,72 @@ "source": [ " ## Lets create another polygon annotation with python annotation tools that draws the image using cv2 and PIL python libraries\n", "\n", - "\n", "hsv = cv2.cvtColor(tiled_image_data.value, cv2.COLOR_RGB2HSV)\n", - "mask = cv2.inRange(hsv, (50, 10, 25), (100, 150, 255))\n", - "kernel = np.ones((5, 5), np.uint8)\n", + "mask = cv2.inRange(hsv, (10, 25, 25), (100, 150, 255))\n", + "kernel = np.ones((15, 20), np.uint8)\n", "mask = cv2.erode(mask, kernel)\n", "mask = cv2.dilate(mask, kernel)\n", - "mask_annotation = MaskData.from_2D_arr(mask)\n", - "mask_data = Mask(mask=mask_annotation, color=[255, 255, 255])\n", + "mask_annotation = lb_types.MaskData.from_2D_arr(mask)\n", + "mask_data = lb_types.Mask(mask=mask_annotation, color=[255, 255, 255])\n", "h, w, _ = tiled_image_data.value.shape\n", "pixel_bounds = TiledBounds(epsg=EPSG.SIMPLEPIXEL,\n", - " bounds=[Point(x=0, y=0),\n", - " Point(x=w, y=h)])\n", + " bounds=[lb_types.Point(x=0, y=0),\n", + " lb_types.Point(x=w, y=h)])\n", "transformer = EPSGTransformer.create_pixel_to_geo_transformer(\n", " src_epsg=pixel_bounds.epsg,\n", " pixel_bounds=pixel_bounds,\n", " geo_bounds=tiled_image_data.tile_bounds,\n", " zoom=23)\n", "pixel_polygons = mask_data.shapely.simplify(3)\n", - "list_of_polygons = [transformer(Polygon.from_shapely(p)) for p in pixel_polygons.geoms]\n", - "polygon_annotation_two = ObjectAnnotation(value=list_of_polygons[0], name=\"polygon_geo_2\")" + "list_of_polygons = [transformer(lb_types.Polygon.from_shapely(p)) for p in pixel_polygons.geoms]\n", + "polygon_annotation_two = lb_types.ObjectAnnotation(value=list_of_polygons[0], name=\"polygon_geo_2\")\n", + "\n", + "\n", + "# Here is the NDJSON representation of the resulting polygon:\n", + "polygon_annotation_two_ndjson = {\n", + " \"name\": \"polygon_geo_2\",\n", + " \"polygon\": [\n", + " {'x': -122.31703039689702, 'y': 37.87397804081582},\n", + " {'x': -122.31702351036107, 'y': 37.87393525033866},\n", + " {'x': -122.31698907768116, 'y': 37.87389857276706},\n", + " {'x': -122.3169787478772, 'y': 37.87385883871054},\n", + " {'x': -122.31695808826926, 'y': 37.87385578224377},\n", + " {'x': -122.31695464500127, 'y': 37.873816048164166},\n", + " {'x': -122.31692021232138, 'y': 37.873779370533214},\n", + " {'x': -122.31690988251741, 'y': 37.87373352346883},\n", + " {'x': -122.3168857796415, 'y': 37.873696845796786},\n", + " {'x': -122.3168547902296, 'y': 37.873684619902065},\n", + " {'x': -122.31682035754969, 'y': 37.873611264491025},\n", + " {'x': -122.31676526526188, 'y': 37.87355013492598},\n", + " {'x': -122.3167583787259, 'y': 37.87351651364362},\n", + " {'x': -122.31671017297403, 'y': 37.87348900531027},\n", + " {'x': -122.31671017297403, 'y': 37.873452327516496},\n", + " {'x': -122.31667918356217, 'y': 37.87344010158117},\n", + " {'x': -122.31663442107829, 'y': 37.87335451997715},\n", + " {'x': -122.31660343166638, 'y': 37.87334840700161},\n", + " {'x': -122.31659998839841, 'y': 37.873320898605485},\n", + " {'x': -122.31654489611057, 'y': 37.87329033370888},\n", + " {'x': -122.31652767977064, 'y': 37.87319863894286},\n", + " {'x': -122.31648980382273, 'y': 37.8731833564708},\n", + " {'x': -122.31648980382273, 'y': 37.873161961004534},\n", + " {'x': -122.31641749519497, 'y': 37.87309166157168},\n", + " {'x': -122.316410608659, 'y': 37.873054983580076},\n", + " {'x': -122.31639683558704, 'y': 37.873039701078184},\n", + " {'x': -122.31635551637117, 'y': 37.873039701078184},\n", + " {'x': -122.31635551637117, 'y': 37.87398109727749},\n", + " {'x': -122.31703039689702, 'y': 37.87397804081582}\n", + " ]\n", + "}" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "dr1dEPzM_tHW", - "outputId": "cb9f30c9-0379-429b-fe19-eb84588666cd" + "outputId": "90ac4962-50b0-44fc-a93d-d11a1f473687" }, "id": "dr1dEPzM_tHW", - "execution_count": 87, + "execution_count": 65, "outputs": [ { "output_type": "stream", @@ -861,7 +958,7 @@ "\n", "tiled_image_data_row_id = next(dataset.export_data_rows()).uid\n", "\n", - "label = Label(\n", + "label = lb_types.Label(\n", " data=TiledImageData(\n", " uid=tiled_image_data_row_id ,\n", " tile_layer=tile_layer,\n", @@ -889,37 +986,37 @@ "colab": { "base_uri": "https://localhost:8080/" }, - "outputId": "e25c4962-303d-4818-ff45-063e281ff65b" + "outputId": "1344d897-6f1c-4dcb-ef42-cf5c4eae8a02" }, "id": "3_LZLZY7xS30", - "execution_count": 88, + "execution_count": 66, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ - "[{'uuid': 'c0f5e57b-2039-4b57-9494-1fb702ed0177',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'},\n", + "[{'uuid': '61ad497c-85bd-4f3c-a32e-4cb368844a22',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'},\n", " 'name': 'point_geo',\n", " 'classifications': [],\n", " 'point': {'x': -122.31741025134123, 'y': 37.87355669249922}},\n", - " {'uuid': '153d8ab2-85e4-446f-8c26-fd9608b859c5',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'},\n", + " {'uuid': '5d6f057f-a0cd-4e9f-b9c2-ade883874226',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'},\n", " 'name': 'polyline_geo',\n", " 'classifications': [],\n", " 'line': [{'x': -122.31757789012927, 'y': 37.87396317833991},\n", " {'x': -122.31639782443663, 'y': 37.87396741226917},\n", " {'x': -122.31638977853417, 'y': 37.87277872707839}]},\n", - " {'uuid': '64e1b3f3-5efc-4960-80a2-2ed260495027',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'},\n", + " {'uuid': '7f2190d0-ba76-4c26-9c95-5b152f1e522d',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'},\n", " 'name': 'polygon_geo',\n", " 'classifications': [],\n", " 'polygon': [{'x': -122.31691812612837, 'y': 37.873289980495024},\n", " {'x': -122.31710184090099, 'y': 37.87304335144298},\n", " {'x': -122.31680146054286, 'y': 37.87303594197371},\n", " {'x': -122.31691812612837, 'y': 37.873289980495024}]},\n", - " {'uuid': '2a474383-6986-4172-9651-a31742c671b7',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'},\n", + " {'uuid': '2c7b71f2-b0dc-4ea6-85bf-363794c1dac7',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'},\n", " 'name': 'bbox_geo',\n", " 'classifications': [],\n", " 'bbox': {'top': 37.873713376083884,\n", @@ -928,10 +1025,10 @@ " 'width': 0.0006141705536464315}},\n", " {'name': 'radio_question_geo',\n", " 'answer': {'name': 'first_radio_answer'},\n", - " 'uuid': '172f2ffa-da88-456d-b6ab-ecf35c1a1dd0',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'}},\n", - " {'uuid': 'a1957d02-da90-4a50-9406-de5aa47ef5a8',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'},\n", + " 'uuid': '3a14d7b8-409b-4f2a-b48d-70c27f2c03c2',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'}},\n", + " {'uuid': '5978bc1f-cc40-4588-8539-e905693b962d',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'},\n", " 'name': 'bbox_checklist_geo',\n", " 'classifications': [{'name': 'checklist_class_name',\n", " 'answer': [{'name': 'first_checklist_answer'}]}],\n", @@ -939,8 +1036,8 @@ " 'left': -122.31711256877092,\n", " 'height': 0.00020534685175022105,\n", " 'width': 0.0004572754559006853}},\n", - " {'uuid': '27beed41-ca07-4f28-9471-2d2fdfe9eb46',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'},\n", + " {'uuid': 'ebe20f18-b513-4645-a019-1f7732694d14',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'},\n", " 'name': 'bbox_text_geo',\n", " 'classifications': [{'name': 'free_text_geo', 'answer': 'sample text'}],\n", " 'bbox': {'top': 37.87318201423049,\n", @@ -948,24 +1045,48 @@ " 'height': 0.00019791053033202388,\n", " 'width': 0.00040764323713915473}},\n", " {'name': 'checklist_question_geo',\n", - " 'uuid': '6e010615-37b3-4af4-bdcc-01e982ae901d',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'},\n", + " 'uuid': 'fa58fd3d-8346-4c9a-bf55-65b27ed92508',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'},\n", " 'answer': [{'name': 'first_checklist_answer'},\n", " {'name': 'second_checklist_answer'},\n", " {'name': 'third_checklist_answer'}]},\n", - " {'uuid': 'f31ed137-9259-4f99-89dc-f6bb840b24b6',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'},\n", + " {'uuid': 'cdc124f7-5e1b-42d5-a9b7-1f98d50c141d',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'},\n", " 'name': 'polygon_geo_2',\n", " 'classifications': [],\n", - " 'polygon': [{'x': -122.31636240290715, 'y': 37.87296634502498},\n", - " {'x': -122.31636240290715, 'y': 37.87294800600024},\n", - " {'x': -122.31635551637117, 'y': 37.87294800600024},\n", - " {'x': -122.31635551637117, 'y': 37.87296634502498},\n", - " {'x': -122.31636240290715, 'y': 37.87296634502498}]}]" + " 'polygon': [{'x': -122.31703039689702, 'y': 37.87397804081582},\n", + " {'x': -122.31702351036107, 'y': 37.87393525033866},\n", + " {'x': -122.31698907768116, 'y': 37.87389857276706},\n", + " {'x': -122.3169787478772, 'y': 37.87385883871054},\n", + " {'x': -122.31695808826926, 'y': 37.87385578224377},\n", + " {'x': -122.31695464500127, 'y': 37.873816048164166},\n", + " {'x': -122.31692021232138, 'y': 37.873779370533214},\n", + " {'x': -122.31690988251741, 'y': 37.87373352346883},\n", + " {'x': -122.3168857796415, 'y': 37.873696845796786},\n", + " {'x': -122.3168547902296, 'y': 37.873684619902065},\n", + " {'x': -122.31682035754969, 'y': 37.873611264491025},\n", + " {'x': -122.31676526526188, 'y': 37.87355013492598},\n", + " {'x': -122.3167583787259, 'y': 37.87351651364362},\n", + " {'x': -122.31671017297403, 'y': 37.87348900531027},\n", + " {'x': -122.31671017297403, 'y': 37.873452327516496},\n", + " {'x': -122.31667918356217, 'y': 37.87344010158117},\n", + " {'x': -122.31663442107829, 'y': 37.87335451997715},\n", + " {'x': -122.31660343166638, 'y': 37.87334840700161},\n", + " {'x': -122.31659998839841, 'y': 37.873320898605485},\n", + " {'x': -122.31654489611057, 'y': 37.87329033370888},\n", + " {'x': -122.31652767977064, 'y': 37.87319863894286},\n", + " {'x': -122.31648980382273, 'y': 37.8731833564708},\n", + " {'x': -122.31648980382273, 'y': 37.873161961004534},\n", + " {'x': -122.31641749519497, 'y': 37.87309166157168},\n", + " {'x': -122.316410608659, 'y': 37.873054983580076},\n", + " {'x': -122.31639683558704, 'y': 37.873039701078184},\n", + " {'x': -122.31635551637117, 'y': 37.873039701078184},\n", + " {'x': -122.31635551637117, 'y': 37.87398109727749},\n", + " {'x': -122.31703039689702, 'y': 37.87397804081582}]}]" ] }, "metadata": {}, - "execution_count": 88 + "execution_count": 66 } ] }, @@ -992,7 +1113,11 @@ " radio_annotation_ndjson,\n", " bbox_with_checklist_subclass_ndjson, \n", " bbox_with_free_text_subclass_ndjson,\n", - " checklist_annotation_ndjson]:\n", + " checklist_annotation_ndjson,\n", + " nested_checklist_annotation_ndjson,\n", + " nested_radio_classification_ndjson,\n", + " polygon_annotation_two_ndjson\n", + " ]:\n", " annotations.update({\n", " 'uuid' : str(uuid.uuid4()),\n", " 'dataRow': {\n", @@ -1006,7 +1131,7 @@ "id": "M88fD66M0f63" }, "id": "M88fD66M0f63", - "execution_count": 89, + "execution_count": 67, "outputs": [] }, { @@ -1019,10 +1144,10 @@ "colab": { "base_uri": "https://localhost:8080/" }, - "outputId": "c8d8b9e7-15e6-48a7-a93e-a26266290c6e" + "outputId": "e24db130-941a-40a8-e5cf-bae9a7080f63" }, "id": "10pZtHgzfAJS", - "execution_count": 90, + "execution_count": 68, "outputs": [ { "output_type": "execute_result", @@ -1030,32 +1155,32 @@ "text/plain": [ "[{'name': 'point_geo',\n", " 'point': {'x': -122.31741025134123, 'y': 37.87355669249922},\n", - " 'uuid': '491ef98a-70cd-49d2-8a2d-e8753d91bd50',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'}},\n", + " 'uuid': 'b148343c-031b-40d5-a22c-6fe950f6c787',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'}},\n", " {'name': 'polyline_geo',\n", " 'line': [{'x': -122.31757789012927, 'y': 37.87396317833991},\n", " {'x': -122.31639782443663, 'y': 37.87396741226917},\n", " {'x': -122.31638977853417, 'y': 37.87277872707839}],\n", - " 'uuid': '8b27ab75-c07a-4afd-a9e6-afd5c059ee9d',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'}},\n", + " 'uuid': 'd087ec4e-80f7-4a96-8f32-77102883dca8',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'}},\n", " {'name': 'polygon_geo',\n", " 'polygon': [{'x': -122.31691812612837, 'y': 37.873289980495024},\n", " {'x': -122.31710184090099, 'y': 37.87304335144298},\n", " {'x': -122.31680146054286, 'y': 37.87303594197371},\n", " {'x': -122.31691812612837, 'y': 37.873289980495024}],\n", - " 'uuid': '2aafd451-f09d-4b16-9f27-a4dfbbbd5499',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'}},\n", + " 'uuid': '2bbd457a-dd3b-4647-b159-2222e2565cb1',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'}},\n", " {'name': 'bbox_geo',\n", " 'bbox': {'top': 37.87385944699745,\n", " 'left': -122.31734455895823,\n", " 'height': -0.0001460709135656657,\n", " 'width': 0.0006141705536464315},\n", - " 'uuid': 'e55ccd7c-8072-477a-b1ac-e7959d1d32c6',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'}},\n", + " 'uuid': '20bc88c9-6b10-471a-8551-794ac30d6be5',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'}},\n", " {'name': 'radio_question_geo',\n", " 'answer': {'name': 'first_radio_answer'},\n", - " 'uuid': '73b080a4-3207-4563-8ef0-984db6e5a39b',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'}},\n", + " 'uuid': '4449726a-6cff-4698-9faa-a28fe0dd7b8e',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'}},\n", " {'name': 'bbox_checklist_geo',\n", " 'classifications': [{'name': 'checklist_class_name',\n", " 'answer': [{'name': 'first_checklist_answer'}]}],\n", @@ -1063,26 +1188,70 @@ " 'left': -122.31711256877092,\n", " 'height': -0.00020534685175022105,\n", " 'width': 0.0004572754559006853},\n", - " 'uuid': '1b6b9f39-da86-4efa-b8e6-f8c4482651d8',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'}},\n", + " 'uuid': '10277b83-ddd2-4547-a959-aad86672bc39',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'}},\n", " {'name': 'bbox_text_geo',\n", " 'classifications': [{'name': 'free_text_geo', 'answer': 'sample text'}],\n", " 'bbox': {'top': 37.87337992476082,\n", " 'left': -122.31750814315438,\n", " 'height': -0.00019791053033202388,\n", " 'width': 0.00040764323713915473},\n", - " 'uuid': 'c83c5c29-4a50-43fa-909a-ff6a213d1ee4',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'}},\n", + " 'uuid': 'dcb8f081-f272-46bc-b59f-23ec127f3a78',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'}},\n", " {'name': 'checklist_question_geo',\n", " 'answer': [{'name': 'first_checklist_answer'},\n", " {'name': 'second_checklist_answer'},\n", " {'name': 'third_checklist_answer'}],\n", - " 'uuid': '47962318-310d-46ce-a2a1-26c70edf5e6b',\n", - " 'dataRow': {'id': 'cldkmpeur008s078t4uz04luf'}}]" + " 'uuid': '921033ce-ac18-49f7-9e1e-83185168dac6',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'}},\n", + " {'name': 'nested_checklist_question',\n", + " 'answer': [{'name': 'first_checklist_answer',\n", + " 'classifications': [{'name': 'sub_checklist_question',\n", + " 'answer': {'name': 'first_sub_checklist_answer'}}]}],\n", + " 'uuid': '05430419-22a1-472b-9b77-9cb2cf9027ba',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'}},\n", + " {'name': 'radio_question_nested',\n", + " 'answer': {'name': 'first_radio_question'},\n", + " 'classifications': [{'name': 'sub_question_radio',\n", + " 'answer': {'name': 'sub_answer'}}],\n", + " 'uuid': '975225be-aa9c-4b01-9307-4022fe29d810',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'}},\n", + " {'name': 'polygon_geo_2',\n", + " 'polygon': [{'x': -122.31703039689702, 'y': 37.87397804081582},\n", + " {'x': -122.31702351036107, 'y': 37.87393525033866},\n", + " {'x': -122.31698907768116, 'y': 37.87389857276706},\n", + " {'x': -122.3169787478772, 'y': 37.87385883871054},\n", + " {'x': -122.31695808826926, 'y': 37.87385578224377},\n", + " {'x': -122.31695464500127, 'y': 37.873816048164166},\n", + " {'x': -122.31692021232138, 'y': 37.873779370533214},\n", + " {'x': -122.31690988251741, 'y': 37.87373352346883},\n", + " {'x': -122.3168857796415, 'y': 37.873696845796786},\n", + " {'x': -122.3168547902296, 'y': 37.873684619902065},\n", + " {'x': -122.31682035754969, 'y': 37.873611264491025},\n", + " {'x': -122.31676526526188, 'y': 37.87355013492598},\n", + " {'x': -122.3167583787259, 'y': 37.87351651364362},\n", + " {'x': -122.31671017297403, 'y': 37.87348900531027},\n", + " {'x': -122.31671017297403, 'y': 37.873452327516496},\n", + " {'x': -122.31667918356217, 'y': 37.87344010158117},\n", + " {'x': -122.31663442107829, 'y': 37.87335451997715},\n", + " {'x': -122.31660343166638, 'y': 37.87334840700161},\n", + " {'x': -122.31659998839841, 'y': 37.873320898605485},\n", + " {'x': -122.31654489611057, 'y': 37.87329033370888},\n", + " {'x': -122.31652767977064, 'y': 37.87319863894286},\n", + " {'x': -122.31648980382273, 'y': 37.8731833564708},\n", + " {'x': -122.31648980382273, 'y': 37.873161961004534},\n", + " {'x': -122.31641749519497, 'y': 37.87309166157168},\n", + " {'x': -122.316410608659, 'y': 37.873054983580076},\n", + " {'x': -122.31639683558704, 'y': 37.873039701078184},\n", + " {'x': -122.31635551637117, 'y': 37.873039701078184},\n", + " {'x': -122.31635551637117, 'y': 37.87398109727749},\n", + " {'x': -122.31703039689702, 'y': 37.87397804081582}],\n", + " 'uuid': '06e010cf-7237-4dfa-839d-5365ba6d0d49',\n", + " 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'}}]" ] }, "metadata": {}, - "execution_count": 90 + "execution_count": 68 } ] }, @@ -1111,12 +1280,12 @@ "cell_type": "code", "source": [ "# Upload MAL label for this data row in project\n", - "upload_job = MALPredictionImport.create_from_objects(\n", + "upload_job = lb.MALPredictionImport.create_from_objects(\n", " client = client, \n", " project_id = project.uid, \n", " name=\"mal_import_job\"+str(uuid.uuid4()), \n", " ### use label_ndjson_method2 if labels were created using NDJSON tools\n", - " predictions=label_ndjson)\n", + " predictions=label_ndjson_method2)\n", "\n", "upload_job.wait_until_done();\n", "print(\"Errors:\", upload_job.errors)\n", @@ -1127,10 +1296,10 @@ "base_uri": "https://localhost:8080/" }, "id": "SrAMnM9L0cAb", - "outputId": "f033df57-6a04-48f8-dce7-4ccf8c87aed3" + "outputId": "4462ca45-f5e1-449c-9e70-d5c44c92a068" }, "id": "SrAMnM9L0cAb", - "execution_count": 91, + "execution_count": 69, "outputs": [ { "output_type": "stream", @@ -1156,12 +1325,12 @@ "cell_type": "code", "source": [ "# Upload label for this data row in project \n", - "upload_job = LabelImport.create_from_objects(\n", + "upload_job = lb.LabelImport.create_from_objects(\n", " client = client, \n", " project_id = project.uid, \n", " name=\"label_geo_import_job\"+str(uuid.uuid4()), \n", " # user label_ndjson if labels were created using python annotation tools\n", - " labels=label_ndjson)\n", + " labels=label_ndjson_method2)\n", "\n", "upload_job.wait_until_done();\n", "print(\"Errors:\", upload_job.errors)" @@ -1171,10 +1340,10 @@ "colab": { "base_uri": "https://localhost:8080/" }, - "outputId": "4b6e3124-1d90-472e-d8af-9ebee1683f80" + "outputId": "486e99e6-5baf-4ea6-ce0a-0e2a3cbcc14b" }, "id": "leIutAqA2_Uw", - "execution_count": 92, + "execution_count": 70, "outputs": [ { "output_type": "stream", @@ -1206,7 +1375,7 @@ "id": "ZLM9L5ggGqHG" }, "id": "ZLM9L5ggGqHG", - "execution_count": 93, + "execution_count": 71, "outputs": [] } ],