Skip to content

Commit 25cfb37

Browse files
author
Matt Sokoloff
committed
remove param for tiled imagery
1 parent 2dfecda commit 25cfb37

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

examples/model_assisted_labeling/tiled_imagery_mal.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
{
3737
"cell_type": "code",
38-
"execution_count": 1,
38+
"execution_count": 2,
3939
"id": "committed-richards",
4040
"metadata": {},
4141
"outputs": [],
@@ -62,7 +62,7 @@
6262
},
6363
{
6464
"cell_type": "code",
65-
"execution_count": 2,
65+
"execution_count": 3,
6666
"id": "thirty-grocery",
6767
"metadata": {},
6868
"outputs": [],
@@ -84,7 +84,7 @@
8484
},
8585
{
8686
"cell_type": "code",
87-
"execution_count": 3,
87+
"execution_count": 4,
8888
"id": "conservative-marsh",
8989
"metadata": {},
9090
"outputs": [],
@@ -95,7 +95,7 @@
9595
},
9696
{
9797
"cell_type": "code",
98-
"execution_count": 4,
98+
"execution_count": 5,
9999
"id": "affecting-myanmar",
100100
"metadata": {},
101101
"outputs": [],
@@ -113,7 +113,7 @@
113113
},
114114
{
115115
"cell_type": "code",
116-
"execution_count": 5,
116+
"execution_count": 6,
117117
"id": "suburban-crowd",
118118
"metadata": {},
119119
"outputs": [],
@@ -126,7 +126,7 @@
126126
},
127127
{
128128
"cell_type": "code",
129-
"execution_count": 6,
129+
"execution_count": 7,
130130
"id": "modern-program",
131131
"metadata": {},
132132
"outputs": [],
@@ -174,7 +174,7 @@
174174
},
175175
{
176176
"cell_type": "code",
177-
"execution_count": 7,
177+
"execution_count": 8,
178178
"id": "generic-freedom",
179179
"metadata": {},
180180
"outputs": [],
@@ -187,7 +187,7 @@
187187
"\n",
188188
"# DataRows can only be created as bulk operations for tiled imagery data\n",
189189
"\n",
190-
"dataset.create_data_rows([img_info], tiled_imagery = True)\n",
190+
"dataset.create_data_rows([img_info])\n",
191191
"editor = next(\n",
192192
" client.get_labeling_frontends(where=LabelingFrontend.name == \"Editor\"))\n",
193193
"project.setup(editor, ontology_builder.asdict())\n",

labelbox/schema/dataset.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,25 @@ def create_data_row(self, **kwargs):
6767

6868
return self.client._create(DataRow, kwargs)
6969

70-
def create_data_rows(self, items, tiled_imagery=False):
70+
def create_data_rows(self, items):
7171
""" Creates multiple DataRow objects based on the given `items`.
7272
7373
Each element in `items` can be either a `str` or a `dict`. If
7474
it is a `str`, then it is interpreted as a local file path. The file
7575
is uploaded to Labelbox and a DataRow referencing it is created.
76-
If an item is a `dict`, then it should map `DataRow` fields (or their
77-
names) to values. At the minimum an `item` passed as a `dict` must
78-
contain a `DataRow.row_data` key and value.
7976
77+
If an item is a `dict`, then it could support one of the two following structures
78+
1. For static imagery, video, and text it should map `DataRow` fields (or their names) to values.
79+
At the minimum an `item` passed as a `dict` must contain a `DataRow.row_data` key and value.
80+
2. For tiled imagery the dict must match the import structure specified in the link below
81+
https://docs.labelbox.com/data-model/en/index-en#tiled-imagery-import
82+
8083
>>> dataset.create_data_rows([
8184
>>> {DataRow.row_data:"http://my_site.com/photos/img_01.jpg"},
82-
>>> "path/to/file2.jpg"
85+
>>> "path/to/file2.jpg",
86+
>>> {tileLayerUrl : "http://", ...}
8387
>>> ])
8488
85-
If tiled_imagery = True, See the link below for supported fields:
86-
https://docs.labelbox.com/data-model/en/index-en#tiled-imagery-import
87-
8889
For an example showing how to upload tiled data_rows see the following notebook:
8990
https://github.com/Labelbox/labelbox-python/blob/ms/develop/model_assisted_labeling/tiled_imagery_mal.ipynb
9091
@@ -120,6 +121,9 @@ def upload_if_necessary(item):
120121
items = thread_pool.map(upload_if_necessary, items)
121122

122123
def convert_item(item):
124+
# Don't make any changes to tms data
125+
if "tileLayerUrl" in item:
126+
return item
123127
# Convert string names to fields.
124128
item = {
125129
key if isinstance(key, Field) else DataRow.field(key): value
@@ -142,9 +146,7 @@ def convert_item(item):
142146
}
143147

144148
# Prepare and upload the desciptor file
145-
if not tiled_imagery:
146-
items = [convert_item(item) for item in items]
147-
149+
items = [convert_item(item) for item in items]
148150
data = json.dumps(items)
149151
descriptor_url = self.client.upload_data(data)
150152

0 commit comments

Comments
 (0)