Skip to content

Commit 14dd298

Browse files
authored
Merge pull request #168 from Labelbox/ms/mea-beta-release
prep for beta release
2 parents feb3dfb + a150f1f commit 14dd298

File tree

3 files changed

+40
-32
lines changed

3 files changed

+40
-32
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
# Next Release
3+
# Version 2.5b0+mea (2021-06-11)
44
## Added
55
* Added new `Model` and 'ModelRun` entities
66
* Update client to support creating and querying for `Model`s

examples/model_assisted_labeling/image_mea.ipynb

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
18-
"!pip install labelbox \\\n",
18+
"!pip install labelbox==2.5b0+mea \\\n",
1919
" requests \\\n",
2020
" ndjson \\\n",
2121
" scikit-image \\\n",
@@ -34,12 +34,6 @@
3434
"from labelbox.schema.ontology import OntologyBuilder, Tool\n",
3535
"from labelbox import Client, LabelingFrontend, MALPredictionImport\n",
3636
"from image_model import predict, class_mappings, load_model\n",
37-
"from image_mal_utils import (\n",
38-
" visualize_bbox_ndjsons, \n",
39-
" visualize_poly_ndjsons, \n",
40-
" visualize_point_ndjsons, \n",
41-
" visualize_mask_ndjsons\n",
42-
")\n",
4337
"from io import BytesIO\n",
4438
"from getpass import getpass\n",
4539
"import uuid\n",
@@ -55,18 +49,30 @@
5549
" create_mask_ndjson, \n",
5650
" create_point_ndjson\n",
5751
")\n",
58-
"from labelbox.data.metrics.iou import datarow_miou\n",
59-
"import random"
52+
"from labelbox.data.metrics.iou import datarow_miou"
6053
]
6154
},
6255
{
6356
"cell_type": "code",
6457
"execution_count": null,
65-
"id": "wooden-western",
58+
"id": "economic-chase",
6659
"metadata": {},
6760
"outputs": [],
6861
"source": [
69-
"load_model()"
62+
"# If you don't want to give google access to drive you can skip this cell\n",
63+
"# and manually set `API_KEY` below.\n",
64+
"\n",
65+
"COLAB = \"google.colab\" in str(get_ipython())\n",
66+
"if COLAB:\n",
67+
" !pip install colab-env -qU\n",
68+
" from colab_env import envvar_handler\n",
69+
" envvar_handler.envload()\n",
70+
"\n",
71+
"API_KEY = os.environ.get(\"LABELBOX_API_KEY\")\n",
72+
"if not os.environ.get(\"LABELBOX_API_KEY\"):\n",
73+
" API_KEY = getpass(\"Please enter your labelbox api key\")\n",
74+
" if COLAB:\n",
75+
" envvar_handler.add_env(\"LABELBOX_API_KEY\", API_KEY)"
7076
]
7177
},
7278
{
@@ -76,10 +82,17 @@
7682
"metadata": {},
7783
"outputs": [],
7884
"source": [
79-
"#ENDPOINT = \"https://api.labelbox.com/_gql\"\n",
80-
"API_KEY = os.environ['LOCAL_LABELBOX_API_KEY']\n",
81-
"ENDPOINT = \"http://localhost:8080/_gql\"\n",
82-
"client = Client(api_key=API_KEY, endpoint=ENDPOINT)"
85+
"client = Client(api_key=API_KEY)"
86+
]
87+
},
88+
{
89+
"cell_type": "code",
90+
"execution_count": null,
91+
"id": "saved-monitor",
92+
"metadata": {},
93+
"outputs": [],
94+
"source": [
95+
"load_model()"
8396
]
8497
},
8598
{
@@ -222,7 +235,7 @@
222235
"metadata": {},
223236
"outputs": [],
224237
"source": [
225-
"print(f\"http://localhost:3000/projects/{project.uid}\")"
238+
"print(f\"https://app.labelbox.com/projects/{project.uid}\")"
226239
]
227240
},
228241
{
@@ -275,10 +288,8 @@
275288
"metadata": {},
276289
"outputs": [],
277290
"source": [
278-
"# Note this will be fairly slow until we add annotation objects where data is stored as numpy arrays\n",
279-
"# Or we use RLE\n",
280291
"\n",
281-
"metic_annotations = []\n",
292+
"metric_annotations = []\n",
282293
"grouped_predictions = defaultdict(list)\n",
283294
"\n",
284295
"for prediction in predictions:\n",
@@ -290,7 +301,7 @@
290301
" if score is None:\n",
291302
" continue\n",
292303
" \n",
293-
" metic_annotations.append( {\n",
304+
" metric_annotations.append( {\n",
294305
" \"uuid\" : str(uuid.uuid4()),\n",
295306
" \"dataRow\" : {\n",
296307
" \"id\": datarow_id,\n",
@@ -307,7 +318,7 @@
307318
"metadata": {},
308319
"outputs": [],
309320
"source": [
310-
"upload_task = model_run.add_predictions(f'mea-import-{uuid.uuid4()}', predictions + metic_annotations)"
321+
"upload_task = model_run.add_predictions(f'mea-import-{uuid.uuid4()}', predictions + metric_annotations)"
311322
]
312323
},
313324
{

labelbox/client.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ def __init__(self,
6969
logger.info("Experimental features have been enabled")
7070

7171
logger.info("Initializing Labelbox client at '%s'", endpoint)
72-
self.endpoint = endpoint
72+
73+
# TODO: Make endpoints non-internal or support them as experimental
74+
self.endpoint = endpoint.replace('/graphql', '/_gql')
7375
self.headers = {
7476
'Accept': 'application/json',
7577
'Content-Type': 'application/json',
@@ -139,15 +141,10 @@ def convert_value(value):
139141
raise ValueError("query and data cannot both be none")
140142
try:
141143
request = {
142-
'url':
143-
self.endpoint.replace('/graphql', '/_gql')
144-
if experimental else self.endpoint,
145-
'data':
146-
data,
147-
'headers':
148-
self.headers,
149-
'timeout':
150-
timeout
144+
'url': self.endpoint,
145+
'data': data,
146+
'headers': self.headers,
147+
'timeout': timeout
151148
}
152149
if files:
153150
request.update({'files': files})

0 commit comments

Comments
 (0)