Skip to content

Commit 88a35eb

Browse files
author
Matt Sokoloff
committed
rename RasterData -> ImageData
1 parent 071121d commit 88a35eb

File tree

24 files changed

+99
-100
lines changed

24 files changed

+99
-100
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Version 3.0.0-rc2 (2021-08-09)
44
## Updates
5-
* Rename `data` property of TextData, RasterData, and VideoData types to `value`.
5+
* Rename `data` property of TextData, ImageData, and VideoData types to `value`.
66
* Decrease wait time between updates for `BulkImportRequest.wait_until_done()`
77
* Organization is no longer used to create the LFO in `Project.setup()`
88

examples/annotation_types/basics.ipynb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"source": [
5656
"from labelbox.data.annotation_types import (\n",
5757
" Label,\n",
58-
" RasterData,\n",
58+
" ImageData,\n",
5959
" LabelList,\n",
6060
" TextData,\n",
6161
" VideoData,\n",
@@ -176,7 +176,7 @@
176176
"outputs": [],
177177
"source": [
178178
"labels = [Label(\n",
179-
" data = RasterData(url = \"http://my-img.jpg\"),\n",
179+
" data = ImageData(url = \"http://my-img.jpg\"),\n",
180180
" annotations = [\n",
181181
" ObjectAnnotation(\n",
182182
" value = Point(x = 10, y = 10),\n",
@@ -215,7 +215,7 @@
215215
"* There are three classes to represent data\n",
216216
" * TextData\n",
217217
" * VideoData\n",
218-
" * RasterData\n",
218+
" * ImageData\n",
219219
"* The data objects can be constructed from various representations\n",
220220
" - remote (url, uri)\n",
221221
" - disk ( file path)\n",
@@ -229,7 +229,7 @@
229229
"id": "associate-cutting",
230230
"metadata": {},
231231
"source": [
232-
"### RasterData"
232+
"### ImageData"
233233
]
234234
},
235235
{
@@ -240,11 +240,11 @@
240240
"outputs": [],
241241
"source": [
242242
"# 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",
246246
"image_url = \"https://picsum.photos/id/1003/200/300\"\n",
247-
"image = RasterData(url = image_url)\n",
247+
"image = ImageData(url = image_url)\n",
248248
"# All of these can access the numpy representation the same way:\n",
249249
"np_data = image.value\n",
250250
"\n",
@@ -342,7 +342,7 @@
342342
"outputs": [],
343343
"source": [
344344
"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",
346346
"vd = VideoData(url = video_url, uid = \"ckrey7xef000208l57hwfgi3v\", external_id = \"my_video_data_row\")"
347347
]
348348
},
@@ -539,7 +539,7 @@
539539
"metadata": {},
540540
"source": [
541541
"##### Mask\n",
542-
"* The mask can be any RasterData object.\n"
542+
"* The mask can be any ImageData object.\n"
543543
]
544544
},
545545
{
@@ -551,12 +551,12 @@
551551
"source": [
552552
"\n",
553553
"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",
555555
" name = \"mask class name\"\n",
556556
")\n",
557557
"\n",
558558
"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",
560560
" schema_id = \"ckrgcel71000008jtd9mn0szu\"\n",
561561
")"
562562
]
@@ -577,7 +577,7 @@
577577
"metadata": {},
578578
"outputs": [],
579579
"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",
581581
"mask_annotation = ObjectAnnotation(\n",
582582
" value = Mask(mask = raster_data, color = [255,255,255]),\n",
583583
" name = \"eyes\"\n",
@@ -604,7 +604,7 @@
604604
"metadata": {},
605605
"outputs": [],
606606
"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",
608608
"mask_annotation = ObjectAnnotation(\n",
609609
" value = Mask(mask = raster_data, color = (128,255,255)),\n",
610610
" name = \"eye\"\n",
@@ -734,7 +734,7 @@
734734
"outputs": [],
735735
"source": [
736736
"mask_annotation = Mask(\n",
737-
" mask = RasterData(arr = np_mask),\n",
737+
" mask = ImageData(arr = np_mask),\n",
738738
" color = color \n",
739739
")\n",
740740
"\n",
@@ -790,7 +790,7 @@
790790
"metadata": {},
791791
"outputs": [],
792792
"source": [
793-
"mask_data = RasterData(arr = np_seg_mask)\n",
793+
"mask_data = ImageData(arr = np_seg_mask)\n",
794794
"eye_mask = Mask(mask = mask_data, color = eye_color)\n",
795795
"nose_mask = Mask(mask = mask_data, color = nose_color)\n"
796796
]
@@ -946,15 +946,15 @@
946946
"outputs": [],
947947
"source": [
948948
"label = Label(\n",
949-
" data = RasterData(url = image_url),\n",
949+
" data = ImageData(url = image_url),\n",
950950
" annotations = [\n",
951951
" ObjectAnnotation(\n",
952952
" value = Polygon(points = [Point(x = x, y = y) for x,y in xy_poly]),\n",
953953
" name = \"deer\"\n",
954954
" ),\n",
955955
" ObjectAnnotation(\n",
956956
" 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",
958958
" )\n",
959959
" ]\n",
960960
")"
@@ -994,7 +994,7 @@
994994
"outputs": [],
995995
"source": [
996996
"# Manually set just by adding a value:\n",
997-
"image = RasterData(arr = np_data)\n",
997+
"image = ImageData(arr = np_data)\n",
998998
"image.url = \"http://myurl\""
999999
]
10001000
},
@@ -1048,7 +1048,7 @@
10481048
"source": [
10491049
"\n",
10501050
"label = Label(\n",
1051-
" data = RasterData(arr = np_data),\n",
1051+
" data = ImageData(arr = np_data),\n",
10521052
" annotations = [\n",
10531053
" ObjectAnnotation(\n",
10541054
" name = \"deer_nose\",\n",

examples/annotation_types/label_containers.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"from labelbox import LabelingFrontend\n",
3737
"from labelbox.data.annotation_types import (\n",
3838
" Label, \n",
39-
" RasterData, \n",
39+
" ImageData, \n",
4040
" Mask, \n",
4141
" Point, \n",
4242
" Polygon, \n",
@@ -136,9 +136,9 @@
136136
" Point(x = 99, y = 181).raster(im_h, im_w, thickness = 3),\n",
137137
" ]\n",
138138
" mask_arr = np.max([*eye_masks,nose_mask] , axis = 0)\n",
139-
" mask = RasterData(arr = mask_arr)\n",
139+
" mask = ImageData(arr = mask_arr)\n",
140140
" return [Label(\n",
141-
" data = RasterData(im_bytes = requests.get(image_url).content),\n",
141+
" data = ImageData(im_bytes = requests.get(image_url).content),\n",
142142
" annotations = [\n",
143143
" ObjectAnnotation(value = get_polygon(),name = \"deer\"),\n",
144144
" ObjectAnnotation(name = \"deer_eyes\", value = Mask(mask = mask, color = eye_color)), \n",

examples/annotation_types/mal_using_annotation_types.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"\n",
6767
"from labelbox.data.annotation_types import (\n",
6868
" LabelList,\n",
69-
" RasterData,\n",
69+
" ImageData,\n",
7070
" Rectangle,\n",
7171
" ObjectAnnotation,\n",
7272
" ClassificationAnnotation,\n",
@@ -170,7 +170,7 @@
170170
" start = Point(x = box[1], y = box[0]), end = Point(x = box[3], y = box[2])\n",
171171
" )\n",
172172
" elif name == 'car':\n",
173-
" value = Mask(mask = RasterData.from_2D_arr(arr = seg), color = (1,1,1))\n",
173+
" value = Mask(mask = ImageData.from_2D_arr(arr = seg), color = (1,1,1))\n",
174174
" if value is not None:\n",
175175
" annotations.append(\n",
176176
" ObjectAnnotation(\n",
@@ -202,7 +202,7 @@
202202
"\n",
203203
"labellist = LabelList()\n",
204204
"for image_url in image_urls:\n",
205-
" image_data = RasterData(url = image_url)\n",
205+
" image_data = ImageData(url = image_url)\n",
206206
" height, width = image_data.value.shape[:2]\n",
207207
" prediction = predict(np.array([image_data.im_bytes]), min_score=0.5, height=height, width = width)\n",
208208
" annotations = get_annotations(prediction['boxes'], prediction['class_indices'], prediction['seg_masks'])\n",

examples/model_diagnostics/model_diagnostics_demo.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
" ScalarMetric, \n",
136136
" LabelList, \n",
137137
" Label, \n",
138-
" RasterData, \n",
138+
" ImageData, \n",
139139
" Mask, \n",
140140
" Polygon,\n",
141141
" Point, \n",
@@ -253,7 +253,7 @@
253253
"source": [
254254
"predictions = LabelList()\n",
255255
"for (image_url, external_id) in notebook.tqdm(image_data):\n",
256-
" image = RasterData(url = image_url, external_id = external_id)\n",
256+
" image = ImageData(url = image_url, external_id = external_id)\n",
257257
" height, width = image.value.shape[:2]\n",
258258
" prediction = predict(np.array([image.im_bytes]), min_score=0.5, height=height, width = width)\n",
259259
" boxes, classes, seg_masks = prediction[\"boxes\"], prediction[\"class_indices\"], prediction[\"seg_masks\"]\n",
@@ -270,7 +270,7 @@
270270
" elif class_info['kind'] == Tool.Type.POINT:\n",
271271
" value = Point(x=(box[1] + box[3]) / 2., y = (box[0] + box[2]) / 2.)\n",
272272
" elif class_info['kind'] == Tool.Type.SEGMENTATION:\n",
273-
" value = Mask(mask = RasterData.from_2D_arr(seg * class_info['color']), color = (class_info['color'],)* 3)\n",
273+
" value = Mask(mask = ImageData.from_2D_arr(seg * class_info['color']), color = (class_info['color'],)* 3)\n",
274274
" else:\n",
275275
" raise ValueError(f\"Unsupported kind found. {class_info['kind']}\")\n",
276276
" annotations.append(ObjectAnnotation(name = class_info['name'], value = value))\n",

examples/model_diagnostics/model_diagnostics_guide.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
" ScalarMetric, \n",
138138
" LabelList, \n",
139139
" Label, \n",
140-
" RasterData, \n",
140+
" ImageData, \n",
141141
" Mask,\n",
142142
" Polygon,\n",
143143
" Line,\n",
@@ -271,7 +271,7 @@
271271
" value = Rectangle(start = Point(x = xmin, y = ymin), end = Point(x=xmax, y=ymax))\n",
272272
" value = Point(x=x, y =y)\n",
273273
" value = Line(points = [Point(x = x, y = y) for x,y in instance])\n",
274-
" value = Mask(mask = RasterData.from_2D_arr(seg * grayscale_color), color = (grayscale_color,)* 3)\n",
274+
" value = Mask(mask = ImageData.from_2D_arr(seg * grayscale_color), color = (grayscale_color,)* 3)\n",
275275
" \n",
276276
" annotations.append(ObjectAnnotation(name =class_name, value = value))\n",
277277
" \n",

labelbox/data/annotation_types/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from .classification import Radio
1919
from .classification import Text
2020

21-
from .data import RasterData
21+
from .data import ImageData
2222
from .data import TextData
2323
from .data import VideoData
2424

labelbox/data/annotation_types/collection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def add_to_dataset(self,
7777
def add_url_to_masks(self, signer, max_concurrency=20) -> "LabelList":
7878
"""
7979
Creates signed urls for all masks in the LabelList.
80-
Multiple masks can reference the same RasterData mask so this makes sure we only upload that url once.
80+
Multiple masks can reference the same ImageData mask so this makes sure we only upload that url once.
8181
Only uploads url if one doesn't already exist.
8282
8383
Args:
@@ -235,7 +235,7 @@ def add_url_to_masks(self, signer: Callable[[bytes],
235235
str]) -> "LabelGenerator":
236236
"""
237237
Creates signed urls for all masks in the LabelGenerator.
238-
Multiple masks can reference the same RasterData mask so this makes sure we only upload that url once.
238+
Multiple masks can reference the same ImageData mask so this makes sure we only upload that url once.
239239
Only uploads url if one doesn't already exist.
240240
241241
Args:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from .raster import RasterData
1+
from .raster import ImageData
22
from .text import TextData
33
from .video import VideoData

labelbox/data/annotation_types/data/raster.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from ..types import TypedArray
1313

1414

15-
class RasterData(BaseData):
15+
class ImageData(BaseData):
1616
"""
1717
Represents an image or segmentation mask.
1818
"""
@@ -50,7 +50,7 @@ def np_to_bytes(self, arr: np.ndarray) -> bytes:
5050
"""
5151
if len(arr.shape) != 3:
5252
raise ValueError("unsupported image format. Must be 3D ([H,W,C])."
53-
"Use RasterData.from_2D_arr to construct from 2D")
53+
"Use ImageData.from_2D_arr to construct from 2D")
5454
if arr.dtype != np.uint8:
5555
raise TypeError(f"image data type must be uint8. Found {arr.dtype}")
5656

@@ -140,12 +140,12 @@ def validate_args(cls, values):
140140
elif len(arr.shape) != 3:
141141
raise ValueError(
142142
"unsupported image format. Must be 3D ([H,W,C])."
143-
"Use RasterData.from_2D_arr to construct from 2D")
143+
"Use ImageData.from_2D_arr to construct from 2D")
144144
return values
145145

146146
def __repr__(self) -> str:
147147
symbol_or_none = lambda data: '...' if data is not None else None
148-
return f"RasterData(im_bytes={symbol_or_none(self.im_bytes)}," \
148+
return f"ImageData(im_bytes={symbol_or_none(self.im_bytes)}," \
149149
f"file_path={self.file_path}," \
150150
f"url={self.url}," \
151151
f"arr={symbol_or_none(self.arr)})"

0 commit comments

Comments
 (0)