|
80 | 80 | "cell_type": "code",
|
81 | 81 | "outputs": [
|
82 | 82 | {
|
83 |
| - "output_type": "stream", |
84 | 83 | "name": "stdout",
|
| 84 | + "output_type": "stream", |
85 | 85 | "text": [
|
86 | 86 | "\u001b[K |\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 185 kB 29.6 MB/s \n",
|
87 | 87 | "\u001b[K |\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 7.8 MB 53.9 MB/s \n",
|
|
101 | 101 | {
|
102 | 102 | "metadata": {},
|
103 | 103 | "source": [
|
104 |
| - "from labelbox.schema.ontology import OntologyBuilder, Tool, Classification, Option\n", |
105 |
| - "from labelbox import Client, LabelingFrontend, MALPredictionImport, LabelImport\n", |
106 |
| - "from labelbox.schema.media_type import MediaType\n", |
107 |
| - "import uuid\n", |
108 |
| - "import json" |
| 104 | + "import labelbox as lb\n", |
| 105 | + "import uuid" |
109 | 106 | ],
|
110 | 107 | "cell_type": "code",
|
111 | 108 | "outputs": [],
|
|
124 | 121 | "source": [
|
125 | 122 | "# Add your api key\n",
|
126 | 123 | "API_KEY = None\n",
|
127 |
| - "client = Client(api_key=API_KEY)" |
| 124 | + "client = lb.Client(api_key=API_KEY)" |
128 | 125 | ],
|
129 | 126 | "cell_type": "code",
|
130 | 127 | "outputs": [],
|
|
218 | 215 | "cell_type": "code",
|
219 | 216 | "outputs": [
|
220 | 217 | {
|
221 |
| - "output_type": "stream", |
222 | 218 | "name": "stdout",
|
| 219 | + "output_type": "stream", |
223 | 220 | "text": [
|
224 | 221 | "<DataRow {\n",
|
225 | 222 | " \"created_at\": \"2022-12-23 20:18:48+00:00\",\n",
|
|
251 | 248 | {
|
252 | 249 | "metadata": {},
|
253 | 250 | "source": [
|
254 |
| - "ontology_builder = OntologyBuilder(\n", |
| 251 | + "ontology_builder = lb.OntologyBuilder(\n", |
255 | 252 | " tools=[ \n",
|
256 |
| - " Tool( # NER tool given the name \"ner\"\n", |
257 |
| - " tool=Tool.Type.NER, \n", |
| 253 | + " lb.Tool( # NER tool given the name \"ner\"\n", |
| 254 | + " tool=lb.Tool.Type.NER, \n", |
258 | 255 | " name=\"ner\")], \n",
|
259 | 256 | " classifications=[ \n",
|
260 |
| - " Classification( # Text classification given the name \"text\"\n", |
261 |
| - " class_type=Classification.Type.TEXT,\n", |
262 |
| - " scope=Classification.Scope.INDEX, \n", |
| 257 | + " lb.Classification( # Text classification given the name \"text\"\n", |
| 258 | + " class_type=lb.Classification.Type.TEXT,\n", |
| 259 | + " scope=lb.Classification.Scope.INDEX, \n", |
263 | 260 | " instructions=\"text_convo\"), \n",
|
264 |
| - " Classification( # Checklist classification given the name \"text\" with two options: \"first_checklist_answer\" and \"second_checklist_answer\"\n", |
265 |
| - " class_type=Classification.Type.CHECKLIST, \n", |
266 |
| - " scope=Classification.Scope.INDEX, \n", |
| 261 | + " lb.Classification( # Checklist classification given the name \"text\" with two options: \"first_checklist_answer\" and \"second_checklist_answer\"\n", |
| 262 | + " class_type=lb.Classification.Type.CHECKLIST, \n", |
| 263 | + " scope=lb.Classification.Scope.INDEX, \n", |
267 | 264 | " instructions=\"checklist_convo\", \n",
|
268 | 265 | " options=[\n",
|
269 |
| - " Option(value=\"first_checklist_answer\"),\n", |
270 |
| - " Option(value=\"second_checklist_answer\") \n", |
| 266 | + " lb.Option(value=\"first_checklist_answer\"),\n", |
| 267 | + " lb.Option(value=\"second_checklist_answer\") \n", |
271 | 268 | " ]\n",
|
272 | 269 | " ), \n",
|
273 |
| - " Classification( # Radio classification given the name \"text\" with two options: \"first_radio_answer\" and \"second_radio_answer\"\n", |
274 |
| - " class_type=Classification.Type.RADIO, \n", |
| 270 | + " lb.Classification( # Radio classification given the name \"text\" with two options: \"first_radio_answer\" and \"second_radio_answer\"\n", |
| 271 | + " class_type=lb.Classification.Type.RADIO, \n", |
275 | 272 | " instructions=\"radio_convo\", \n",
|
276 |
| - " scope=Classification.Scope.INDEX, \n", |
| 273 | + " scope=lb.Classification.Scope.INDEX, \n", |
277 | 274 | " options=[\n",
|
278 |
| - " Option(value=\"first_radio_answer\"),\n", |
279 |
| - " Option(value=\"second_radio_answer\")\n", |
| 275 | + " lb.Option(value=\"first_radio_answer\"),\n", |
| 276 | + " lb.Option(value=\"second_radio_answer\")\n", |
280 | 277 | " ]\n",
|
281 | 278 | " )\n",
|
282 | 279 | " ]\n",
|
|
300 | 297 | "source": [
|
301 | 298 | "# Create Labelbox project\n",
|
302 | 299 | "project = client.create_project(name=\"conversational_mal_project\", \n",
|
303 |
| - " media_type=MediaType.Conversational)\n", |
| 300 | + " media_type=lb.MediaType.Conversational)\n", |
304 | 301 | "\n",
|
305 | 302 | "# Setup your ontology / labeling editor\n",
|
306 |
| - "editor = next(client.get_labeling_frontends(where=LabelingFrontend.name == \"Editor\")) # Unless using a custom editor, do not modify this\n", |
| 303 | + "editor = next(client.get_labeling_frontends(where=lb.LabelingFrontend.name == \"Editor\")) # Unless using a custom editor, do not modify this\n", |
307 | 304 | "\n",
|
308 | 305 | "project.setup(editor, ontology_builder.asdict()) # Connect your ontology and editor to your project\n"
|
309 | 306 | ],
|
310 | 307 | "cell_type": "code",
|
311 | 308 | "outputs": [
|
312 | 309 | {
|
313 |
| - "output_type": "stream", |
314 | 310 | "name": "stderr",
|
| 311 | + "output_type": "stream", |
315 | 312 | "text": [
|
316 | 313 | "WARNING:labelbox.client:Default createProject behavior will soon be adjusted to prefer batch projects. Pass in `queue_mode` parameter explicitly to opt-out for the time being.\n"
|
317 | 314 | ]
|
|
343 | 340 | "cell_type": "code",
|
344 | 341 | "outputs": [
|
345 | 342 | {
|
346 |
| - "output_type": "stream", |
347 | 343 | "name": "stdout",
|
| 344 | + "output_type": "stream", |
348 | 345 | "text": [
|
349 | 346 | "Batch: <Batch {\n",
|
350 | 347 | " \"consensus_settings_json\": \"{\\\"numberOfLabels\\\":1,\\\"coveragePercentage\\\":0}\",\n",
|
|
405 | 402 | "cell_type": "code",
|
406 | 403 | "outputs": [
|
407 | 404 | {
|
408 |
| - "output_type": "execute_result", |
409 | 405 | "data": {
|
410 | 406 | "text/plain": [
|
411 | 407 | "[{'name': 'ner',\n",
|
|
431 | 427 | " 'dataRow': {'id': 'clc0ygvde029307yn96gv2byu'}}]"
|
432 | 428 | ]
|
433 | 429 | },
|
| 430 | + "execution_count": 13, |
434 | 431 | "metadata": {},
|
435 |
| - "execution_count": 13 |
| 432 | + "output_type": "execute_result" |
436 | 433 | }
|
437 | 434 | ],
|
438 | 435 | "execution_count": null
|
|
456 | 453 | "metadata": {},
|
457 | 454 | "source": [
|
458 | 455 | "# Upload our label using Model-Assisted Labeling\n",
|
459 |
| - "upload_job = MALPredictionImport.create_from_objects(\n", |
| 456 | + "upload_job = lb.MALPredictionImport.create_from_objects(\n", |
460 | 457 | " client = client, \n",
|
461 | 458 | " project_id = project.uid, \n",
|
462 | 459 | " name=f\"mal_job-{str(uuid.uuid4())}\", \n",
|
|
469 | 466 | "cell_type": "code",
|
470 | 467 | "outputs": [
|
471 | 468 | {
|
472 |
| - "output_type": "stream", |
473 | 469 | "name": "stdout",
|
| 470 | + "output_type": "stream", |
474 | 471 | "text": [
|
475 | 472 | "Errors: []\n",
|
476 | 473 | " \n"
|
|
487 | 484 | "cell_type": "code",
|
488 | 485 | "outputs": [
|
489 | 486 | {
|
490 |
| - "output_type": "execute_result", |
491 | 487 | "data": {
|
492 | 488 | "text/plain": [
|
493 | 489 | "[{'name': 'ner', 'location': {'start': 0, 'end': 8}, 'messageId': '4'},\n",
|
|
509 | 505 | " 'messageId': '0'}]"
|
510 | 506 | ]
|
511 | 507 | },
|
| 508 | + "execution_count": 45, |
512 | 509 | "metadata": {},
|
513 |
| - "execution_count": 45 |
| 510 | + "output_type": "execute_result" |
514 | 511 | }
|
515 | 512 | ],
|
516 | 513 | "execution_count": null
|
|
526 | 523 | "metadata": {},
|
527 | 524 | "source": [
|
528 | 525 | "# Upload label for this data row in project \n",
|
529 |
| - "upload_job = LabelImport.create_from_objects(\n", |
| 526 | + "upload_job = lb.LabelImport.create_from_objects(\n", |
530 | 527 | " client = client, \n",
|
531 | 528 | " project_id = project.uid, \n",
|
532 | 529 | " name=\"label_geo_import_job\"+str(uuid.uuid4()), \n",
|
|
539 | 536 | "cell_type": "code",
|
540 | 537 | "outputs": [
|
541 | 538 | {
|
542 |
| - "output_type": "stream", |
543 | 539 | "name": "stdout",
|
| 540 | + "output_type": "stream", |
544 | 541 | "text": [
|
545 | 542 | "Errors: []\n"
|
546 | 543 | ]
|
|
0 commit comments