|
40 | 40 | },
|
41 | 41 | {
|
42 | 42 | "cell_type": "code",
|
43 |
| - "execution_count": null, |
| 43 | + "execution_count": 1, |
44 | 44 | "id": "wooden-worship",
|
45 | 45 | "metadata": {},
|
46 | 46 | "outputs": [],
|
|
63 | 63 | },
|
64 | 64 | {
|
65 | 65 | "cell_type": "code",
|
66 |
| - "execution_count": null, |
| 66 | + "execution_count": 33, |
67 | 67 | "id": "committed-richards",
|
68 | 68 | "metadata": {},
|
69 | 69 | "outputs": [],
|
|
86 | 86 | " create_mask_ndjson, \n",
|
87 | 87 | " create_point_ndjson\n",
|
88 | 88 | ")\n",
|
89 |
| - "from labelbox.data.metrics.iou import datarow_miou" |
| 89 | + "from labelbox.data.metrics.iou import data_row_miou\n", |
| 90 | + "from labelbox.data.serialization import NDJsonConverter, LBV1Converter" |
90 | 91 | ]
|
91 | 92 | },
|
92 | 93 | {
|
|
99 | 100 | },
|
100 | 101 | {
|
101 | 102 | "cell_type": "code",
|
102 |
| - "execution_count": null, |
| 103 | + "execution_count": 3, |
103 | 104 | "id": "economic-chase",
|
104 | 105 | "metadata": {},
|
105 | 106 | "outputs": [],
|
|
122 | 123 | },
|
123 | 124 | {
|
124 | 125 | "cell_type": "code",
|
125 |
| - "execution_count": null, |
| 126 | + "execution_count": 4, |
126 | 127 | "id": "affecting-myanmar",
|
127 | 128 | "metadata": {},
|
128 | 129 | "outputs": [],
|
|
133 | 134 | },
|
134 | 135 | {
|
135 | 136 | "cell_type": "code",
|
136 |
| - "execution_count": null, |
| 137 | + "execution_count": 5, |
137 | 138 | "id": "saved-monitor",
|
138 | 139 | "metadata": {},
|
139 |
| - "outputs": [], |
| 140 | + "outputs": [ |
| 141 | + { |
| 142 | + "name": "stdout", |
| 143 | + "output_type": "stream", |
| 144 | + "text": [ |
| 145 | + "WARNING:tensorflow:From /Users/matthewsokoloff/Projects/labelbox-python/examples/model_assisted_labeling/image_model.py:17: load (from tensorflow.python.saved_model.loader_impl) is deprecated and will be removed in a future version.\n", |
| 146 | + "Instructions for updating:\n", |
| 147 | + "This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.loader.load or tf.compat.v1.saved_model.load. There will be a new function for importing SavedModels in Tensorflow 2.0.\n", |
| 148 | + "INFO:tensorflow:Restoring parameters from gs://cloud-tpu-checkpoints/mask-rcnn/1555659850/variables/variables\n" |
| 149 | + ] |
| 150 | + } |
| 151 | + ], |
140 | 152 | "source": [
|
141 | 153 | "load_model()"
|
142 | 154 | ]
|
|
159 | 171 | },
|
160 | 172 | {
|
161 | 173 | "cell_type": "code",
|
162 |
| - "execution_count": null, |
| 174 | + "execution_count": 6, |
163 | 175 | "id": "suburban-crowd",
|
164 | 176 | "metadata": {},
|
165 | 177 | "outputs": [],
|
|
184 | 196 | },
|
185 | 197 | {
|
186 | 198 | "cell_type": "code",
|
187 |
| - "execution_count": null, |
| 199 | + "execution_count": 13, |
188 | 200 | "id": "modern-program",
|
189 | 201 | "metadata": {},
|
190 |
| - "outputs": [], |
| 202 | + "outputs": [ |
| 203 | + { |
| 204 | + "data": { |
| 205 | + "text/plain": [ |
| 206 | + "True" |
| 207 | + ] |
| 208 | + }, |
| 209 | + "execution_count": 13, |
| 210 | + "metadata": {}, |
| 211 | + "output_type": "execute_result" |
| 212 | + } |
| 213 | + ], |
191 | 214 | "source": [
|
192 |
| - "\n", |
193 | 215 | "project = client.create_project(name=\"image_mea_project\")\n",
|
194 | 216 | "dataset = client.create_dataset(name=\"image_mea_dataset\")\n",
|
195 |
| - "test_img_url = \"https://upload.wikimedia.org/wikipedia/commons/thumb/0/08/Kitano_Street_Kobe01s5s4110.jpg/2560px-Kitano_Street_Kobe01s5s4110.jpg\"\n", |
| 217 | + "test_img_url = \"https://raw.githubusercontent.com/Labelbox/labelbox-python/develop/examples/assets/2560px-Kitano_Street_Kobe01s5s4110.jpg\"\n", |
196 | 218 | "dataset.create_data_row(row_data=test_img_url)\n",
|
197 | 219 | "editor = next(\n",
|
198 | 220 | " client.get_labeling_frontends(where=LabelingFrontend.name == \"Editor\"))\n",
|
|
214 | 236 | },
|
215 | 237 | {
|
216 | 238 | "cell_type": "code",
|
217 |
| - "execution_count": null, |
| 239 | + "execution_count": 15, |
218 | 240 | "id": "asian-savings",
|
219 | 241 | "metadata": {},
|
220 | 242 | "outputs": [],
|
|
244 | 266 | " predictions.append(create_polygon_ndjson(datarow.uid, schema_id, seg))"
|
245 | 267 | ]
|
246 | 268 | },
|
247 |
| - { |
248 |
| - "cell_type": "code", |
249 |
| - "execution_count": null, |
250 |
| - "id": "welsh-burlington", |
251 |
| - "metadata": {}, |
252 |
| - "outputs": [], |
253 |
| - "source": [] |
254 |
| - }, |
255 | 269 | {
|
256 | 270 | "cell_type": "markdown",
|
257 | 271 | "id": "perfect-seafood",
|
|
264 | 278 | },
|
265 | 279 | {
|
266 | 280 | "cell_type": "code",
|
267 |
| - "execution_count": null, |
| 281 | + "execution_count": 16, |
268 | 282 | "id": "subject-painting",
|
269 | 283 | "metadata": {},
|
270 |
| - "outputs": [], |
| 284 | + "outputs": [ |
| 285 | + { |
| 286 | + "name": "stdout", |
| 287 | + "output_type": "stream", |
| 288 | + "text": [ |
| 289 | + "AnnotationImportState.FINISHED\n" |
| 290 | + ] |
| 291 | + } |
| 292 | + ], |
271 | 293 | "source": [
|
272 | 294 | "upload_task = MALPredictionImport.create_from_objects(client, project.uid, f'mal-import-{uuid.uuid4()}', predictions)\n",
|
273 | 295 | "upload_task.wait_until_done()\n",
|
|
276 | 298 | },
|
277 | 299 | {
|
278 | 300 | "cell_type": "code",
|
279 |
| - "execution_count": null, |
| 301 | + "execution_count": 17, |
280 | 302 | "id": "pointed-export",
|
281 | 303 | "metadata": {},
|
282 |
| - "outputs": [], |
| 304 | + "outputs": [ |
| 305 | + { |
| 306 | + "data": { |
| 307 | + "text/plain": [ |
| 308 | + "[{'uuid': '6bc3e5fb-bec6-4268-ba1b-dc60552a52a6',\n", |
| 309 | + " 'dataRow': {'id': 'ckrm6lebo4f2l0z8efn5a9mdk'},\n", |
| 310 | + " 'status': 'SUCCESS'},\n", |
| 311 | + " {'uuid': 'bbf00e83-c591-4d43-b305-5062c8d60b3e',\n", |
| 312 | + " 'dataRow': {'id': 'ckrm6lebo4f2l0z8efn5a9mdk'},\n", |
| 313 | + " 'status': 'SUCCESS'},\n", |
| 314 | + " {'uuid': '3effa28d-0f07-4b45-85e4-8ed3d7099fcd',\n", |
| 315 | + " 'dataRow': {'id': 'ckrm6lebo4f2l0z8efn5a9mdk'},\n", |
| 316 | + " 'status': 'SUCCESS'},\n", |
| 317 | + " {'uuid': 'c7d0aade-7509-40ae-b898-012db003ccdf',\n", |
| 318 | + " 'dataRow': {'id': 'ckrm6lebo4f2l0z8efn5a9mdk'},\n", |
| 319 | + " 'status': 'SUCCESS'},\n", |
| 320 | + " {'uuid': 'a2a89721-31c8-42dd-b4d9-a6797beff649',\n", |
| 321 | + " 'dataRow': {'id': 'ckrm6lebo4f2l0z8efn5a9mdk'},\n", |
| 322 | + " 'status': 'SUCCESS'}]" |
| 323 | + ] |
| 324 | + }, |
| 325 | + "execution_count": 17, |
| 326 | + "metadata": {}, |
| 327 | + "output_type": "execute_result" |
| 328 | + } |
| 329 | + ], |
283 | 330 | "source": [
|
284 | 331 | "upload_task.statuses[:5]"
|
285 | 332 | ]
|
|
296 | 343 | },
|
297 | 344 | {
|
298 | 345 | "cell_type": "code",
|
299 |
| - "execution_count": null, |
| 346 | + "execution_count": 18, |
300 | 347 | "id": "christian-juvenile",
|
301 | 348 | "metadata": {},
|
302 |
| - "outputs": [], |
| 349 | + "outputs": [ |
| 350 | + { |
| 351 | + "name": "stdout", |
| 352 | + "output_type": "stream", |
| 353 | + "text": [ |
| 354 | + "https://app.labelbox.com/projects/ckrm6ldy85cmz0y7m4rc21zps\n" |
| 355 | + ] |
| 356 | + } |
| 357 | + ], |
303 | 358 | "source": [
|
304 | 359 | "print(f\"https://app.labelbox.com/projects/{project.uid}\")"
|
305 | 360 | ]
|
306 | 361 | },
|
307 | 362 | {
|
308 | 363 | "cell_type": "code",
|
309 |
| - "execution_count": null, |
| 364 | + "execution_count": 29, |
310 | 365 | "id": "excited-seminar",
|
311 | 366 | "metadata": {},
|
312 |
| - "outputs": [], |
| 367 | + "outputs": [ |
| 368 | + { |
| 369 | + "name": "stdout", |
| 370 | + "output_type": "stream", |
| 371 | + "text": [ |
| 372 | + "[]\n" |
| 373 | + ] |
| 374 | + } |
| 375 | + ], |
313 | 376 | "source": [
|
314 |
| - "labels = requests.get(project.export_labels()).json()" |
| 377 | + "labels = project.export_labels_json()\n", |
| 378 | + "print(labels)" |
315 | 379 | ]
|
316 | 380 | },
|
317 | 381 | {
|
|
332 | 396 | },
|
333 | 397 | {
|
334 | 398 | "cell_type": "code",
|
335 |
| - "execution_count": null, |
| 399 | + "execution_count": 27, |
336 | 400 | "id": "mental-minnesota",
|
337 | 401 | "metadata": {},
|
338 | 402 | "outputs": [],
|
339 | 403 | "source": [
|
340 |
| - "model = client.create_model(name = \"test-model\", ontology_id = project.ontology().uid)\n", |
| 404 | + "model = client.create_model(name = \"test-model-1\", ontology_id = project.ontology().uid)\n", |
341 | 405 | "model_run = model.create_model_run('test-run-1')"
|
342 | 406 | ]
|
343 | 407 | },
|
344 | 408 | {
|
345 | 409 | "cell_type": "code",
|
346 |
| - "execution_count": null, |
| 410 | + "execution_count": 23, |
347 | 411 | "id": "static-coordinate",
|
348 | 412 | "metadata": {},
|
349 |
| - "outputs": [], |
| 413 | + "outputs": [ |
| 414 | + { |
| 415 | + "ename": "ValueError", |
| 416 | + "evalue": "Must provide at least one label id", |
| 417 | + "output_type": "error", |
| 418 | + "traceback": [ |
| 419 | + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
| 420 | + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", |
| 421 | + "\u001b[0;32m<ipython-input-23-312f4540651d>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmodel_run\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mupsert_labels\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mlabel\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'ID'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mlabel\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mlabels\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", |
| 422 | + "\u001b[0;32m~/Projects/labelbox-python/labelbox/schema/model_run.py\u001b[0m in \u001b[0;36mupsert_labels\u001b[0;34m(self, label_ids)\u001b[0m\n\u001b[1;32m 19\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 20\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlabel_ids\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m<\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 21\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Must provide at least one label id\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 22\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 23\u001b[0m query_str = \"\"\"mutation upsertModelRunLabelsPyApi($modelRunId: ID!, $labelIds : [ID!]!) {\n", |
| 423 | + "\u001b[0;31mValueError\u001b[0m: Must provide at least one label id" |
| 424 | + ] |
| 425 | + } |
| 426 | + ], |
350 | 427 | "source": [
|
351 | 428 | "model_run.upsert_labels([label['ID'] for label in labels])"
|
352 | 429 | ]
|
|
362 | 439 | "# For large projects this logic should be wrapped in a threadpool for faster execution.\n",
|
363 | 440 | "\n",
|
364 | 441 | "\n",
|
| 442 | + "\n", |
365 | 443 | "metric_annotations = []\n",
|
366 | 444 | "grouped_predictions = defaultdict(list)\n",
|
367 | 445 | "\n",
|
|
0 commit comments