|
15 | 15 | "metadata": {}, |
16 | 16 | "outputs": [], |
17 | 17 | "source": [ |
18 | | - "!pip install labelbox \\\n", |
| 18 | + "!pip install labelbox==2.5b0+mea \\\n", |
19 | 19 | " requests \\\n", |
20 | 20 | " ndjson \\\n", |
21 | 21 | " scikit-image \\\n", |
|
34 | 34 | "from labelbox.schema.ontology import OntologyBuilder, Tool\n", |
35 | 35 | "from labelbox import Client, LabelingFrontend, MALPredictionImport\n", |
36 | 36 | "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", |
43 | 37 | "from io import BytesIO\n", |
44 | 38 | "from getpass import getpass\n", |
45 | 39 | "import uuid\n", |
|
55 | 49 | " create_mask_ndjson, \n", |
56 | 50 | " create_point_ndjson\n", |
57 | 51 | ")\n", |
58 | | - "from labelbox.data.metrics.iou import datarow_miou\n", |
59 | | - "import random" |
| 52 | + "from labelbox.data.metrics.iou import datarow_miou" |
60 | 53 | ] |
61 | 54 | }, |
62 | 55 | { |
63 | 56 | "cell_type": "code", |
64 | 57 | "execution_count": null, |
65 | | - "id": "wooden-western", |
| 58 | + "id": "economic-chase", |
66 | 59 | "metadata": {}, |
67 | 60 | "outputs": [], |
68 | 61 | "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)" |
70 | 76 | ] |
71 | 77 | }, |
72 | 78 | { |
|
76 | 82 | "metadata": {}, |
77 | 83 | "outputs": [], |
78 | 84 | "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()" |
83 | 96 | ] |
84 | 97 | }, |
85 | 98 | { |
|
222 | 235 | "metadata": {}, |
223 | 236 | "outputs": [], |
224 | 237 | "source": [ |
225 | | - "print(f\"http://localhost:3000/projects/{project.uid}\")" |
| 238 | + "print(f\"https://app.labelbox.com/projects/{project.uid}\")" |
226 | 239 | ] |
227 | 240 | }, |
228 | 241 | { |
|
275 | 288 | "metadata": {}, |
276 | 289 | "outputs": [], |
277 | 290 | "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", |
280 | 291 | "\n", |
281 | | - "metic_annotations = []\n", |
| 292 | + "metric_annotations = []\n", |
282 | 293 | "grouped_predictions = defaultdict(list)\n", |
283 | 294 | "\n", |
284 | 295 | "for prediction in predictions:\n", |
|
290 | 301 | " if score is None:\n", |
291 | 302 | " continue\n", |
292 | 303 | " \n", |
293 | | - " metic_annotations.append( {\n", |
| 304 | + " metric_annotations.append( {\n", |
294 | 305 | " \"uuid\" : str(uuid.uuid4()),\n", |
295 | 306 | " \"dataRow\" : {\n", |
296 | 307 | " \"id\": datarow_id,\n", |
|
307 | 318 | "metadata": {}, |
308 | 319 | "outputs": [], |
309 | 320 | "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)" |
311 | 322 | ] |
312 | 323 | }, |
313 | 324 | { |
|
0 commit comments