|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "boxed-football", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "# Project Setup\n", |
| 9 | + "* This section describes how to create and configure a project" |
| 10 | + ] |
| 11 | + }, |
| 12 | + { |
| 13 | + "cell_type": "code", |
| 14 | + "execution_count": 7, |
| 15 | + "id": "ordered-notice", |
| 16 | + "metadata": {}, |
| 17 | + "outputs": [], |
| 18 | + "source": [ |
| 19 | + "from labelbox import Client, Project, LabelingFrontend\n", |
| 20 | + "from labelbox.schema.ontology import Tool, OntologyBuilder\n", |
| 21 | + "client = Client()" |
| 22 | + ] |
| 23 | + }, |
| 24 | + { |
| 25 | + "cell_type": "markdown", |
| 26 | + "id": "least-stone", |
| 27 | + "metadata": {}, |
| 28 | + "source": [ |
| 29 | + "### Identify project, dataset, and ontology" |
| 30 | + ] |
| 31 | + }, |
| 32 | + { |
| 33 | + "cell_type": "code", |
| 34 | + "execution_count": 5, |
| 35 | + "id": "mobile-south", |
| 36 | + "metadata": {}, |
| 37 | + "outputs": [], |
| 38 | + "source": [ |
| 39 | + "ontology_builder = OntologyBuilder(tools = [\n", |
| 40 | + " Tool(name = \"cat\", tool = Tool.Type.BBOX)\n", |
| 41 | + "])\n", |
| 42 | + "project = client.create_project(name = \"my_new_project\")\n", |
| 43 | + "dataset = client.create_dataset(name = \"my_new_dataset\")\n", |
| 44 | + "#Add data_rows (see basics/dataset to do this)" |
| 45 | + ] |
| 46 | + }, |
| 47 | + { |
| 48 | + "cell_type": "code", |
| 49 | + "execution_count": 8, |
| 50 | + "id": "neural-scanning", |
| 51 | + "metadata": {}, |
| 52 | + "outputs": [], |
| 53 | + "source": [ |
| 54 | + "#Unless you are using a custom editor you should always use the following editor:\n", |
| 55 | + "editor = next(client.get_labeling_frontends(where=LabelingFrontend.name == \"Editor\"))" |
| 56 | + ] |
| 57 | + }, |
| 58 | + { |
| 59 | + "cell_type": "code", |
| 60 | + "execution_count": 11, |
| 61 | + "id": "attended-twist", |
| 62 | + "metadata": {}, |
| 63 | + "outputs": [], |
| 64 | + "source": [ |
| 65 | + "#Note that you can use any dataset or ontology even if they already exist.\n", |
| 66 | + "existing_project = client.get_project(\"ckm4xyfncfgja0760vpfdxoro\")\n", |
| 67 | + "ontology = existing_project.ontology()" |
| 68 | + ] |
| 69 | + }, |
| 70 | + { |
| 71 | + "cell_type": "markdown", |
| 72 | + "id": "limiting-bleeding", |
| 73 | + "metadata": {}, |
| 74 | + "source": [ |
| 75 | + "### Setup and attach dataset" |
| 76 | + ] |
| 77 | + }, |
| 78 | + { |
| 79 | + "cell_type": "code", |
| 80 | + "execution_count": 9, |
| 81 | + "id": "reserved-vietnam", |
| 82 | + "metadata": {}, |
| 83 | + "outputs": [], |
| 84 | + "source": [ |
| 85 | + "project.setup(editor, ontology_builder.asdict())\n", |
| 86 | + "# Could also do if ontology is a normalized ontology\n", |
| 87 | + "# project.setup(editor, ontology.normalized)" |
| 88 | + ] |
| 89 | + }, |
| 90 | + { |
| 91 | + "cell_type": "code", |
| 92 | + "execution_count": 10, |
| 93 | + "id": "unexpected-vegetarian", |
| 94 | + "metadata": {}, |
| 95 | + "outputs": [], |
| 96 | + "source": [ |
| 97 | + "project.datasets.connect(dataset)" |
| 98 | + ] |
| 99 | + }, |
| 100 | + { |
| 101 | + "cell_type": "markdown", |
| 102 | + "id": "afraid-trademark", |
| 103 | + "metadata": {}, |
| 104 | + "source": [ |
| 105 | + "### Review" |
| 106 | + ] |
| 107 | + }, |
| 108 | + { |
| 109 | + "cell_type": "code", |
| 110 | + "execution_count": 16, |
| 111 | + "id": "vanilla-diamond", |
| 112 | + "metadata": {}, |
| 113 | + "outputs": [ |
| 114 | + { |
| 115 | + "name": "stdout", |
| 116 | + "output_type": "stream", |
| 117 | + "text": [ |
| 118 | + "2021-03-17 12:35:00+00:00\n", |
| 119 | + "<labelbox.orm.db_object.RelationshipManager object at 0x1046030d0>\n", |
| 120 | + "['my_new_dataset']\n" |
| 121 | + ] |
| 122 | + } |
| 123 | + ], |
| 124 | + "source": [ |
| 125 | + "#Note setup_complete will be None if it fails.\n", |
| 126 | + "print(project.setup_complete)\n", |
| 127 | + "print(project.ontology)\n", |
| 128 | + "print([ds.name for ds in project.datasets()])" |
| 129 | + ] |
| 130 | + }, |
| 131 | + { |
| 132 | + "cell_type": "code", |
| 133 | + "execution_count": null, |
| 134 | + "id": "graphic-minimum", |
| 135 | + "metadata": {}, |
| 136 | + "outputs": [], |
| 137 | + "source": [] |
| 138 | + } |
| 139 | + ], |
| 140 | + "metadata": { |
| 141 | + "kernelspec": { |
| 142 | + "display_name": "Python 3", |
| 143 | + "language": "python", |
| 144 | + "name": "python3" |
| 145 | + }, |
| 146 | + "language_info": { |
| 147 | + "codemirror_mode": { |
| 148 | + "name": "ipython", |
| 149 | + "version": 3 |
| 150 | + }, |
| 151 | + "file_extension": ".py", |
| 152 | + "mimetype": "text/x-python", |
| 153 | + "name": "python", |
| 154 | + "nbconvert_exporter": "python", |
| 155 | + "pygments_lexer": "ipython3", |
| 156 | + "version": "3.8.2" |
| 157 | + } |
| 158 | + }, |
| 159 | + "nbformat": 4, |
| 160 | + "nbformat_minor": 5 |
| 161 | +} |
0 commit comments