|
33 | 33 | "metadata": {}, |
34 | 34 | "outputs": [], |
35 | 35 | "source": [ |
36 | | - "!pip install \"labelbox[data]==3.0.0rc1\"" |
| 36 | + "!pip install \"labelbox[data]\" --pre" |
37 | 37 | ] |
38 | 38 | }, |
39 | 39 | { |
|
55 | 55 | "source": [ |
56 | 56 | "from labelbox.data.annotation_types import (\n", |
57 | 57 | " Label,\n", |
58 | | - " RasterData,\n", |
| 58 | + " ImageData,\n", |
59 | 59 | " LabelList,\n", |
60 | 60 | " TextData,\n", |
61 | 61 | " VideoData,\n", |
|
176 | 176 | "outputs": [], |
177 | 177 | "source": [ |
178 | 178 | "labels = [Label(\n", |
179 | | - " data = RasterData(url = \"http://my-img.jpg\"),\n", |
| 179 | + " data = ImageData(url = \"http://my-img.jpg\"),\n", |
180 | 180 | " annotations = [\n", |
181 | 181 | " ObjectAnnotation(\n", |
182 | 182 | " value = Point(x = 10, y = 10),\n", |
|
215 | 215 | "* There are three classes to represent data\n", |
216 | 216 | " * TextData\n", |
217 | 217 | " * VideoData\n", |
218 | | - " * RasterData\n", |
| 218 | + " * ImageData\n", |
219 | 219 | "* The data objects can be constructed from various representations\n", |
220 | 220 | " - remote (url, uri)\n", |
221 | 221 | " - disk ( file path)\n", |
|
229 | 229 | "id": "associate-cutting", |
230 | 230 | "metadata": {}, |
231 | 231 | "source": [ |
232 | | - "### RasterData" |
| 232 | + "### ImageData" |
233 | 233 | ] |
234 | 234 | }, |
235 | 235 | { |
|
240 | 240 | "outputs": [], |
241 | 241 | "source": [ |
242 | 242 | "# Data can be instantiated with any of the following\n", |
243 | | - "image = RasterData(im_bytes = b'bytes')\n", |
244 | | - "image = RasterData(arr = np.zeros((10,10,3)).astype(np.uint8))\n", |
245 | | - "image = RasterData(file_path = '/tmp/img.jpg')\n", |
| 243 | + "image = ImageData(im_bytes = b'bytes')\n", |
| 244 | + "image = ImageData(arr = np.zeros((10,10,3)).astype(np.uint8))\n", |
| 245 | + "image = ImageData(file_path = '/tmp/img.jpg')\n", |
246 | 246 | "image_url = \"https://picsum.photos/id/1003/200/300\"\n", |
247 | | - "image = RasterData(url = image_url)\n", |
| 247 | + "image = ImageData(url = image_url)\n", |
248 | 248 | "# All of these can access the numpy representation the same way:\n", |
249 | | - "np_data = image.data\n", |
| 249 | + "np_data = image.value\n", |
250 | 250 | "\n", |
251 | 251 | "\n", |
252 | 252 | "im = Image.fromarray(np_data)\n", |
|
273 | 273 | "text = TextData(text = \" some text content...\")\n", |
274 | 274 | "text = TextData(url = \"https://filesamples.com/samples/document/txt/sample3.txt\")\n", |
275 | 275 | "\n", |
276 | | - "print(text.data[:100])" |
| 276 | + "print(text.value[:100])" |
277 | 277 | ] |
278 | 278 | }, |
279 | 279 | { |
|
306 | 306 | "outputs": [], |
307 | 307 | "source": [ |
308 | 308 | "\n", |
309 | | - "for idx, frame in video.data:\n", |
| 309 | + "for idx, frame in video.value:\n", |
310 | 310 | " # Show every 50th frame\n", |
311 | 311 | " if idx % 50 == 0:\n", |
312 | 312 | " video_im = Image.fromarray(frame)\n", |
|
342 | 342 | "outputs": [], |
343 | 343 | "source": [ |
344 | 344 | "td = TextData(text = \"some text\", uid = \"ckrey6o07000008l50uk2gcr3\", external_id = \"my_text_data_row\")\n", |
345 | | - "rd = RasterData(url = image_url, uid = \"ckrey7te2000108l5hl8564dr\", external_id = \"my_raster_data_row\")\n", |
| 345 | + "rd = ImageData(url = image_url, uid = \"ckrey7te2000108l5hl8564dr\", external_id = \"my_raster_data_row\")\n", |
346 | 346 | "vd = VideoData(url = video_url, uid = \"ckrey7xef000208l57hwfgi3v\", external_id = \"my_video_data_row\")" |
347 | 347 | ] |
348 | 348 | }, |
|
539 | 539 | "metadata": {}, |
540 | 540 | "source": [ |
541 | 541 | "##### Mask\n", |
542 | | - "* The mask can be any RasterData object.\n" |
| 542 | + "* The mask can be any ImageData object.\n" |
543 | 543 | ] |
544 | 544 | }, |
545 | 545 | { |
|
551 | 551 | "source": [ |
552 | 552 | "\n", |
553 | 553 | "mask_annotation = ObjectAnnotation(\n", |
554 | | - " value = Mask(mask = RasterData(arr = np.zeros((32,32,3), dtype = np.uint8)), color = (255,255,255)),\n", |
| 554 | + " value = Mask(mask = ImageData(arr = np.zeros((32,32,3), dtype = np.uint8)), color = (255,255,255)),\n", |
555 | 555 | " name = \"mask class name\"\n", |
556 | 556 | ")\n", |
557 | 557 | "\n", |
558 | 558 | "mask_annotation = ObjectAnnotation(\n", |
559 | | - " value = Mask(mask = RasterData(arr = np.zeros((32,32,3), dtype = np.uint8)), color = (255,255,255)),\n", |
| 559 | + " value = Mask(mask = ImageData(arr = np.zeros((32,32,3), dtype = np.uint8)), color = (255,255,255)),\n", |
560 | 560 | " schema_id = \"ckrgcel71000008jtd9mn0szu\"\n", |
561 | 561 | ")" |
562 | 562 | ] |
|
577 | 577 | "metadata": {}, |
578 | 578 | "outputs": [], |
579 | 579 | "source": [ |
580 | | - "raster_data = RasterData(arr = np.zeros((32,32,3), dtype = np.uint8))\n", |
| 580 | + "raster_data = ImageData(arr = np.zeros((32,32,3), dtype = np.uint8))\n", |
581 | 581 | "mask_annotation = ObjectAnnotation(\n", |
582 | 582 | " value = Mask(mask = raster_data, color = [255,255,255]),\n", |
583 | 583 | " name = \"eyes\"\n", |
|
604 | 604 | "metadata": {}, |
605 | 605 | "outputs": [], |
606 | 606 | "source": [ |
607 | | - "raster_data = RasterData(arr = np.zeros((32,32, 3), dtype = np.uint8))\n", |
| 607 | + "raster_data = ImageData(arr = np.zeros((32,32, 3), dtype = np.uint8))\n", |
608 | 608 | "mask_annotation = ObjectAnnotation(\n", |
609 | 609 | " value = Mask(mask = raster_data, color = (128,255,255)),\n", |
610 | 610 | " name = \"eye\"\n", |
|
734 | 734 | "outputs": [], |
735 | 735 | "source": [ |
736 | 736 | "mask_annotation = Mask(\n", |
737 | | - " mask = RasterData(arr = np_mask),\n", |
| 737 | + " mask = ImageData(arr = np_mask),\n", |
738 | 738 | " color = color \n", |
739 | 739 | ")\n", |
740 | 740 | "\n", |
|
790 | 790 | "metadata": {}, |
791 | 791 | "outputs": [], |
792 | 792 | "source": [ |
793 | | - "mask_data = RasterData(arr = np_seg_mask)\n", |
| 793 | + "mask_data = ImageData(arr = np_seg_mask)\n", |
794 | 794 | "eye_mask = Mask(mask = mask_data, color = eye_color)\n", |
795 | 795 | "nose_mask = Mask(mask = mask_data, color = nose_color)\n" |
796 | 796 | ] |
|
946 | 946 | "outputs": [], |
947 | 947 | "source": [ |
948 | 948 | "label = Label(\n", |
949 | | - " data = RasterData(url = image_url),\n", |
| 949 | + " data = ImageData(url = image_url),\n", |
950 | 950 | " annotations = [\n", |
951 | 951 | " ObjectAnnotation(\n", |
952 | 952 | " value = Polygon(points = [Point(x = x, y = y) for x,y in xy_poly]),\n", |
953 | 953 | " name = \"deer\"\n", |
954 | 954 | " ),\n", |
955 | 955 | " ObjectAnnotation(\n", |
956 | 956 | " name = \"deer_eyes\",\n", |
957 | | - " value = Mask(mask = RasterData(arr = np_mask), color = color)\n", |
| 957 | + " value = Mask(mask = ImageData(arr = np_mask), color = color)\n", |
958 | 958 | " )\n", |
959 | 959 | " ]\n", |
960 | 960 | ")" |
|
994 | 994 | "outputs": [], |
995 | 995 | "source": [ |
996 | 996 | "# Manually set just by adding a value:\n", |
997 | | - "image = RasterData(arr = np_data)\n", |
| 997 | + "image = ImageData(arr = np_data)\n", |
998 | 998 | "image.url = \"http://myurl\"" |
999 | 999 | ] |
1000 | 1000 | }, |
|
1048 | 1048 | "source": [ |
1049 | 1049 | "\n", |
1050 | 1050 | "label = Label(\n", |
1051 | | - " data = RasterData(arr = np_data),\n", |
| 1051 | + " data = ImageData(arr = np_data),\n", |
1052 | 1052 | " annotations = [\n", |
1053 | 1053 | " ObjectAnnotation(\n", |
1054 | 1054 | " name = \"deer_nose\",\n", |
|
0 commit comments