{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", " \n", " \n", " \n", " \n", "
\n", " \n", " \n", " Try in Google Colab\n", " \n", " \n", " \n", " \n", " Share via nbviewer\n", " \n", " \n", " \n", " \n", " View on GitHub\n", " \n", " \n", " \n", " \n", " Download notebook\n", " \n", "
\n" ] }, { "cell_type": "markdown", "id": "abc8d229", "metadata": {}, "source": [ "# FiftyOne CLI Tips and Tricks" ] }, { "cell_type": "markdown", "id": "a1337b1d", "metadata": {}, "source": [ " Leveraging CLI commands can be a powerful way to improve your workflow. We will do a quick dive on some powerful options FiftyOne provides that can save you time on your next computer vision project. Let's take a look: " ] }, { "cell_type": "markdown", "id": "4ce1dec5", "metadata": {}, "source": [ "## Tab Completion" ] }, { "cell_type": "code", "execution_count": 2, "id": "06402547", "metadata": {}, "outputs": [], "source": [ "!eval \"$(register-python-argcomplete fiftyone)\"" ] }, { "cell_type": "markdown", "id": "e1bc2fa7", "metadata": {}, "source": [ "## Load Quickstart for demo" ] }, { "cell_type": "code", "execution_count": 3, "id": "18b79d81", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Downloading dataset to '/home/dan/fiftyone/quickstart'\n", "Downloading dataset...\n", " 100% |████| 187.5Mb/187.5Mb [775.2ms elapsed, 0s remaining, 241.9Mb/s] \n", "Extracting dataset...\n", "Parsing dataset metadata\n", "Found 200 samples\n", "Dataset info written to '/home/dan/fiftyone/quickstart/info.json'\n", "Loading 'quickstart'\n", " 100% |█████████████████| 200/200 [2.1s elapsed, 0s remaining, 94.8 samples/s] \n", "Dataset 'quickstart' created\n" ] } ], "source": [ "import fiftyone as fo\n", "import fiftyone.zoo as foz\n", "\n", "dataset = foz.load_zoo_dataset(\"quickstart\")\n", "dataset.persistent = True" ] }, { "cell_type": "code", "execution_count": 4, "id": "14784f20", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "session = fo.launch_app(dataset)" ] }, { "cell_type": "markdown", "id": "b16d799b", "metadata": {}, "source": [ "## List Datasets" ] }, { "cell_type": "code", "execution_count": 13, "id": "f3af938e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2023.08.24.12.07.07\r\n", "evaluate-detections-tutorial\r\n", "malaria-cell-images\r\n", "malaria-cell-images2\r\n", "open-images-v6-validation-200\r\n", "quickstart\r\n", "tips+tricks\r\n", "tips_and_tricks\r\n" ] } ], "source": [ "!fiftyone datasets list" ] }, { "cell_type": "markdown", "id": "2e2ff6d2", "metadata": {}, "source": [ "## Sort By Date Created and Delete Old" ] }, { "cell_type": "code", "execution_count": 12, "id": "bed7d368", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "name created_at last_loaded_at version persistent media_type tags num_samples\r\n", "----------------------------- ------------------- ------------------- --------- ------------ ------------ ------ -------------\r\n", "quickstart 2023-08-24 20:40:54 2023-08-24 20:41:01 0.21.6 ✓ image 200\r\n", "tips_and_tricks 2023-08-24 18:47:00 2023-08-24 20:30:03 0.21.6 ✓ image 200\r\n", "2023.08.24.12.07.07 2023-08-24 16:07:07 2023-08-24 16:09:21 0.21.6 ✓ image 15474\r\n", "malaria-cell-images2 2023-08-21 20:59:22 2023-08-21 21:08:58 0.21.4 ✓ image 55120\r\n", "open-images-v6-validation-200 2023-06-29 19:17:58 2023-08-24 17:44:21 0.21.6 ✓ image 200\r\n", "malaria-cell-images 2023-06-29 15:32:21 2023-06-29 17:10:03 0.21.0 ✓ image 27558\r\n", "evaluate-detections-tutorial 2023-06-28 20:27:39 2023-08-24 17:55:04 0.21.6 ✓ image 5005\r\n", "tips+tricks ??? ??? ??? ??? ??? ??? ???\r\n" ] } ], "source": [ "!fiftyone datasets info --sort-by created_at" ] }, { "cell_type": "code", "execution_count": 11, "id": "3f058dcf", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Dataset '2023.08.24.11.30.28' deleted\r\n" ] } ], "source": [ "!fiftyone datasets delete NAME" ] }, { "cell_type": "code", "execution_count": 14, "id": "c5664ea9", "metadata": {}, "outputs": [], "source": [ "# Delete all non-persistent datasets\n", "!fiftyone datasets delete --non-persistent" ] }, { "cell_type": "markdown", "id": "fc87e50e", "metadata": {}, "source": [ "## Grab Quick Information of Your Dataset" ] }, { "cell_type": "code", "execution_count": 15, "id": "32a17c64", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "key value\r\n", "------------- -------\r\n", "samples_count 200\r\n", "samples_bytes 1270762\r\n", "samples_size 1.2MB\r\n", "total_bytes 1270762\r\n", "total_size 1.2MB\r\n" ] } ], "source": [ "!fiftyone datasets stats quickstart" ] }, { "cell_type": "code", "execution_count": 16, "id": "5b4a50e5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Name: quickstart\r\n", "Media type: image\r\n", "Num samples: 200\r\n", "Persistent: True\r\n", "Tags: []\r\n", "Sample fields:\r\n", " id: fiftyone.core.fields.ObjectIdField\r\n", " filepath: fiftyone.core.fields.StringField\r\n", " tags: fiftyone.core.fields.ListField(fiftyone.core.fields.StringField)\r\n", " metadata: fiftyone.core.fields.EmbeddedDocumentField(fiftyone.core.metadata.ImageMetadata)\r\n", " ground_truth: fiftyone.core.fields.EmbeddedDocumentField(fiftyone.core.labels.Detections)\r\n", " uniqueness: fiftyone.core.fields.FloatField\r\n", " predictions: fiftyone.core.fields.EmbeddedDocumentField(fiftyone.core.labels.Detections)\r\n" ] } ], "source": [ "!fiftyone datasets info quickstart" ] }, { "cell_type": "markdown", "id": "a97d3c97", "metadata": {}, "source": [ "## Draw on Labels to Samples and Store" ] }, { "cell_type": "code", "execution_count": 17, "id": "0c3f2a9d", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 100% |█████████████████| 200/200 [19.7s elapsed, 0s remaining, 8.6 samples/s] \n", "Rendered media written to 'drawn_labels'\n" ] } ], "source": [ "!fiftyone datasets draw -d drawn_labels -f predictions quickstart" ] }, { "cell_type": "markdown", "id": "081d7674", "metadata": {}, "source": [ "## Rename Dataset" ] }, { "cell_type": "code", "execution_count": 27, "id": "fbb6352e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Dataset 'quickstart' renamed to 'tips_and_tricks'\r\n" ] } ], "source": [ "!fiftyone datasets rename quickstart tips_and_tricks" ] }, { "cell_type": "markdown", "id": "b080cdd0", "metadata": {}, "source": [ "## Plugins CLI" ] }, { "cell_type": "code", "execution_count": 19, "id": "07987e7e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "plugin version enabled directory\r\n", "-------- --------- --------- -----------\r\n" ] } ], "source": [ "!fiftyone plugins list" ] }, { "cell_type": "code", "execution_count": 20, "id": "56d7a04b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "uri enabled builtin on_startup unlisted dynamic\r\n", "------------------------------------------ --------- --------- ------------ ---------- ---------\r\n", "@voxel51/operators/clone_selected_samples ✓ ✓ ✓\r\n", "@voxel51/operators/clone_sample_field ✓ ✓ ✓\r\n", "@voxel51/operators/rename_sample_field ✓ ✓ ✓\r\n", "@voxel51/operators/delete_selected_samples ✓ ✓ ✓\r\n", "@voxel51/operators/delete_sample_field ✓ ✓ ✓\r\n", "@voxel51/operators/print_stdout ✓ ✓ ✓\r\n" ] } ], "source": [ "!fiftyone operators list" ] }, { "cell_type": "code", "execution_count": null, "id": "72a9b5e5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Downloading voxel51/fiftyone-plugins...\n", " 311.4Mb [4.2s elapsed, ? remaining, 88.0Mb/s] " ] } ], "source": [ "!fiftyone plugins download \\\n", " https://github.com/voxel51/fiftyone-plugins \\\n", " --plugin-names @voxel51/hello-world" ] }, { "cell_type": "code", "execution_count": 30, "id": "a609bff2", "metadata": {}, "outputs": [], "source": [ "!fiftyone plugins disable @voxel51/hello-world" ] }, { "cell_type": "code", "execution_count": 32, "id": "bf32bc79", "metadata": {}, "outputs": [], "source": [ "!fiftyone plugins enable @voxel51/hello-world" ] }, { "cell_type": "code", "execution_count": 33, "id": "a6d5beab", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\r\n", "Could not connect session, trying again in 10 seconds\r\n", "\n" ] } ], "source": [ "# Try it yourself!\n", "session = fo.launch_app(dataset)" ] }, { "cell_type": "code", "execution_count": null, "id": "7d6501e7", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" } }, "nbformat": 4, "nbformat_minor": 5 }