Skip to content

Commit 93f40e9

Browse files
authored
Merge pull request #139 from Labelbox/ms/tms-mal-example
ms/tms mal example
2 parents 86221cb + 69da8f4 commit 93f40e9

File tree

3 files changed

+699
-5
lines changed

3 files changed

+699
-5
lines changed

examples/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
| Named Entity Recognition MAL | [Github](model_assisted_labeling/ner_mal.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/develop/examples/model_assisted_labeling/ner_mal.ipynb) |
3838
| Debugging MAL | [Github](model_assisted_labeling/debugging_mal.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/develop/examples/model_assisted_labeling/debugging_mal.ipynb) |
3939
| MAL with Subclasses | [Github](model_assisted_labeling/mal_with_subclasses.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/develop/examples/model_assisted_labeling/mal_with_subclasses.ipynb) |
40+
| Tiled Imagery MAL | [Github](model_assisted_labeling/tiled_imagery_mal.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/develop/examples/model_assisted_labeling/tiled_imagery_mal.ipynb) |
41+
4042
------
4143

4244
## [Project Configuration](project_configuration)

examples/model_assisted_labeling/tiled_imagery_mal.ipynb

Lines changed: 681 additions & 0 deletions
Large diffs are not rendered by default.

labelbox/schema/dataset.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,22 @@ def create_data_rows(self, items):
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
89+
For an example showing how to upload tiled data_rows see the following notebook:
90+
https://github.com/Labelbox/labelbox-python/blob/ms/develop/model_assisted_labeling/tiled_imagery_mal.ipynb
91+
8592
Args:
8693
items (iterable of (dict or str)): See above for details.
8794
@@ -113,6 +120,9 @@ def upload_if_necessary(item):
113120
items = thread_pool.map(upload_if_necessary, items)
114121

115122
def convert_item(item):
123+
# Don't make any changes to tms data
124+
if "tileLayerUrl" in item:
125+
return item
116126
# Convert string names to fields.
117127
item = {
118128
key if isinstance(key, Field) else DataRow.field(key): value
@@ -135,7 +145,8 @@ def convert_item(item):
135145
}
136146

137147
# Prepare and upload the desciptor file
138-
data = json.dumps([convert_item(item) for item in items])
148+
items = [convert_item(item) for item in items]
149+
data = json.dumps(items)
139150
descriptor_url = self.client.upload_data(data)
140151

141152
# Create data source

0 commit comments

Comments
 (0)