diff --git a/classification/evaluation/evaluation-end2end.ipynb b/classification/evaluation/evaluation-end2end.ipynb index ce96d60..a089fd6 100644 --- a/classification/evaluation/evaluation-end2end.ipynb +++ b/classification/evaluation/evaluation-end2end.ipynb @@ -61,25 +61,10 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "6343aa55", "metadata": {}, - "outputs": [ - { - "ename": "ValueError", - "evalue": "Dataset 'dataset' already exists; use `fiftyone.load_dataset()` to load an existing dataset", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/tmp/ipykernel_395832/1016218199.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0;31m# Load the dataset, using tags to mark the samples in each split\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 8\u001b[0;31m \u001b[0mdataset\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfo\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDataset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\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 9\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0msplit\u001b[0m \u001b[0;32min\u001b[0m \u001b[0msplits\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10\u001b[0m dataset.add_dir(\n", - "\u001b[0;32m~/.local/share/miniconda3/lib/python3.7/site-packages/fiftyone/core/singletons.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(cls, name, _create, *args, **kwargs)\u001b[0m\n\u001b[1;32m 31\u001b[0m ):\n\u001b[1;32m 32\u001b[0m \u001b[0minstance\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcls\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__new__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcls\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 33\u001b[0;31m \u001b[0minstance\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0m_create\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0m_create\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\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 34\u001b[0m \u001b[0mname\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minstance\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m \u001b[0;31m# `__init__` may have changed `name`\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 35\u001b[0m \u001b[0mcls\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_instances\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minstance\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/.local/share/miniconda3/lib/python3.7/site-packages/fiftyone/core/dataset.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, name, persistent, overwrite, _create, _virtual, **kwargs)\u001b[0m\n\u001b[1;32m 240\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0m_create\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 241\u001b[0m doc, sample_doc_cls, frame_doc_cls = _create_dataset(\n\u001b[0;32m--> 242\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpersistent\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mpersistent\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 243\u001b[0m )\n\u001b[1;32m 244\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/.local/share/miniconda3/lib/python3.7/site-packages/fiftyone/core/dataset.py\u001b[0m in \u001b[0;36m_create_dataset\u001b[0;34m(obj, name, persistent, _patches, _frames, _clips, _src_collection)\u001b[0m\n\u001b[1;32m 5881\u001b[0m \u001b[0;34m\"to load an existing dataset\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5882\u001b[0m )\n\u001b[0;32m-> 5883\u001b[0;31m \u001b[0;34m%\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5884\u001b[0m )\n\u001b[1;32m 5885\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mValueError\u001b[0m: Dataset 'dataset' already exists; use `fiftyone.load_dataset()` to load an existing dataset" - ] - } - ], + "outputs": [], "source": [ "name = \"dataset\"\n", "dataset_dir = \"dataset\"\n", @@ -110,7 +95,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "8681fc92", "metadata": {}, "outputs": [], @@ -131,18 +116,10 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "29827e3f", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " 100% |█████████████████| 640/640 [6.2m elapsed, 0s remaining, 2.1 samples/s] \n" - ] - } - ], + "outputs": [], "source": [ "# Do detections with model and save bounding boxes\n", "with fo.ProgressBar() as pb:\n", @@ -179,7 +156,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "id": "06e1b4c0", "metadata": {}, "outputs": [], @@ -200,21 +177,10 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "8ad67806", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Evaluating detections...\n", - " 100% |█████████████████| 640/640 [2.1s elapsed, 0s remaining, 307.0 samples/s] \n", - "Performing IoU sweep...\n", - " 100% |█████████████████| 640/640 [2.3s elapsed, 0s remaining, 280.1 samples/s] \n" - ] - } - ], + "outputs": [], "source": [ "results = dataset.view().evaluate_detections(\n", " \"predictions\",\n", @@ -236,259 +202,10 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "b180420b", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " precision recall f1-score support\n", - "\n", - " Healthy 0.82 0.74 0.78 662\n", - " Stressed 0.71 0.78 0.74 488\n", - "\n", - " micro avg 0.77 0.76 0.76 1150\n", - " macro avg 0.77 0.76 0.76 1150\n", - "weighted avg 0.77 0.76 0.77 1150\n", - "\n", - "0.6225848121901868\n" - ] - }, - { - "data": { - "text/plain": [] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "2faa9ee3a0ce499986d12b6f9c4e1ef8", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "FigureWidget({\n", - " 'data': [{'mode': 'markers',\n", - " 'opacity': 0.1,\n", - " 'type': 'scatter',\n", - " 'uid': 'a30f32cd-dedd-40c9-b4e8-755f4a701673',\n", - " 'x': array([0, 1, 2, 0, 1, 2, 0, 1, 2]),\n", - " 'y': array([0, 0, 0, 1, 1, 1, 2, 2, 2])},\n", - " {'colorscale': [[0.0, 'rgb(255,245,235)'], [0.125,\n", - " 'rgb(254,230,206)'], [0.25, 'rgb(253,208,162)'],\n", - " [0.375, 'rgb(253,174,107)'], [0.5, 'rgb(253,141,60)'],\n", - " [0.625, 'rgb(241,105,19)'], [0.75, 'rgb(217,72,1)'],\n", - " [0.875, 'rgb(166,54,3)'], [1.0, 'rgb(127,39,4)']],\n", - " 'hoverinfo': 'skip',\n", - " 'showscale': False,\n", - " 'type': 'heatmap',\n", - " 'uid': '352f91ad-547a-412a-ad31-a9cef7ad7c16',\n", - " 'z': array([[105, 158, 0],\n", - " [ 0, 382, 106],\n", - " [493, 0, 169]]),\n", - " 'zmax': 493,\n", - " 'zmin': 0},\n", - " {'colorbar': {'len': 1, 'lenmode': 'fraction'},\n", - " 'colorscale': [[0.0, 'rgb(255,245,235)'], [0.125,\n", - " 'rgb(254,230,206)'], [0.25, 'rgb(253,208,162)'],\n", - " [0.375, 'rgb(253,174,107)'], [0.5, 'rgb(253,141,60)'],\n", - " [0.625, 'rgb(241,105,19)'], [0.75, 'rgb(217,72,1)'],\n", - " [0.875, 'rgb(166,54,3)'], [1.0, 'rgb(127,39,4)']],\n", - " 'hovertemplate': 'count: %{z}
truth: %{y}
predicted: %{x}',\n", - " 'opacity': 0.25,\n", - " 'type': 'heatmap',\n", - " 'uid': 'd8669a84-9bf1-4f67-a3aa-32ce811302b7',\n", - " 'z': array([[105, 158, 0],\n", - " [ 0, 382, 106],\n", - " [493, 0, 169]]),\n", - " 'zmax': 493,\n", - " 'zmin': 0}],\n", - " 'layout': {'clickmode': 'event',\n", - " 'margin': {'b': 0, 'l': 0, 'r': 0, 't': 30},\n", - " 'template': '...',\n", - " 'title': {},\n", - " 'xaxis': {'constrain': 'domain',\n", - " 'range': [-0.5, 2.5],\n", - " 'tickmode': 'array',\n", - " 'ticktext': [Healthy, Stressed, (none)],\n", - " 'tickvals': array([0, 1, 2])},\n", - " 'yaxis': {'constrain': 'domain',\n", - " 'range': [-0.5, 2.5],\n", - " 'scaleanchor': 'x',\n", - " 'scaleratio': 1,\n", - " 'tickmode': 'array',\n", - " 'ticktext': array(['(none)', 'Stressed', 'Healthy'], dtype=object),\n", - " 'tickvals': array([0, 1, 2])}}\n", - "})" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "09acc41587fe4bed8572f205b7456502", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "FigureWidget({\n", - " 'data': [{'customdata': array([99., 99., 99., 99., 99., 99., 99., 99., 99., 99., 99., 98., 98., 98.,\n", - " 97., 97., 97., 97., 96., 96., 96., 95., 94., 93., 93., 92., 91., 91.,\n", - " 90., 89., 88., 87., 87., 86., 86., 85., 85., 84., 82., 82., 81., 80.,\n", - " 80., 79., 78., 78., 77., 76., 75., 74., 72., 70., 70., 68., 67., 66.,\n", - " 65., 64., 62., 62., 61., 59., 58., 56., 53., 52., 51., 50., 0., 0.,\n", - " 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n", - " 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n", - " 0., 0., 0.]),\n", - " 'hovertemplate': ('class: %{text}
recal' ... 'customdata:.3f}'),\n", - " 'line': {'color': '#3366CC'},\n", - " 'mode': 'lines',\n", - " 'name': 'Healthy (AP = 0.562)',\n", - " 'text': array(['Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy',\n", - " 'Healthy', 'Healthy', 'Healthy', 'Healthy', 'Healthy'], dtype='class: %{text}
recal' ... 'customdata:.3f}'),\n", - " 'line': {'color': '#DC3912'},\n", - " 'mode': 'lines',\n", - " 'name': 'Stressed (AP = 0.532)',\n", - " 'text': array(['Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed',\n", - " 'Stressed', 'Stressed', 'Stressed', 'Stressed', 'Stressed'], dtype='" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "session = fo.launch_app(dataset, auto=False)\n", "session.view = dataset.view()\n", @@ -548,7 +245,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "6eed9a86", "metadata": {}, "outputs": [], @@ -589,28 +286,15 @@ "source": [ "### Load OIDv6 \n", "\n", - "Since we are only interested in evaluating the model, we only load the _test_ split of the dataset. The only classes of interest to us are _Plant_ and _Houseplant_ and we do not want to load keypoint detections or segmentation masks, which is why we specify the `label_types` parameter. There are 12106 images in the test split." + "Since we are only interested in evaluating the model, we only load the _test_ split of the dataset. The only classes of interest to us are _Plant_ and _Houseplant_ and we do not want to load keypoint detections or segmentation masks, which is why we specify the `label_types` parameter. There are 9148 images in the test split." ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "id": "19c5b271", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Downloading split 'test' to '/home/zenon/fiftyone/open-images-v6/test' if necessary\n", - "Necessary images already downloaded\n", - "Existing download of split 'test' is sufficient\n", - "Loading 'open-images-v6' split 'test'\n", - " 100% |█████████████| 12106/12106 [1.0m elapsed, 0s remaining, 161.8 samples/s] \n", - "Dataset 'open-images-v6-test' created\n" - ] - } - ], + "outputs": [], "source": [ "import fiftyone as fo\n", "import fiftyone.zoo as foz\n", @@ -635,7 +319,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "id": "ebdde519", "metadata": {}, "outputs": [], @@ -693,31 +377,24 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "id": "002ae8fa", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " 100% |█████████████| 12106/12106 [14.9s elapsed, 0s remaining, 804.0 samples/s] \n" - ] - } - ], + "outputs": [], "source": [ - "yolo_dataset_dir = export_dir\n", + "yolo_dataset_dir = '/mnt/yolo-second-run/data'\n", "\n", "# The type of the dataset being imported\n", "dataset_type = fo.types.YOLOv5Dataset\n", "\n", "# Import the dataset\n", - "yolo = fo.Dataset.from_dir(\n", + "yolo_test = fo.Dataset.from_dir(\n", " dataset_dir=yolo_dataset_dir,\n", " dataset_type=dataset_type,\n", + " split='test'\n", ")\n", - "yolo.name = 'yolo'\n", - "yolo.persistent = True" + "yolo_test.name = 'yolo_test'\n", + "yolo_test.persistent = True" ] }, { @@ -730,23 +407,23 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 2, "id": "0b86639e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['dataset', 'yolo']" + "['2023.02.28.10.28.50', 'dataset', 'dataset-small', 'yolo', 'yolo_test']" ] }, - "execution_count": 28, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "yolo = fo.load_dataset('yolo')\n", + "yolo_test = fo.load_dataset('yolo_test')\n", "fo.list_datasets()" ] }, @@ -757,12 +434,12 @@ "source": [ "### Perform detections \n", "\n", - "We can proceed as before by calling the model and saving the detections to the `predictions` field of each sample. Note that line 7 does not call `detect()` but `detect_yolo_only()`. The detections on all 12106 images take around 1.2h on a GTX 750Ti." + "We can proceed as before by calling the model and saving the detections to the `predictions` field of each sample. Note that line 7 does not call `detect()` but `detect_yolo_only()`. The detections on all 9148 images take around 1h on a GTX 750Ti." ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "id": "030e9c7c", "metadata": {}, "outputs": [ @@ -770,13 +447,13 @@ "name": "stdout", "output_type": "stream", "text": [ - " 100% |█████████████| 12106/12106 [1.2h elapsed, 0s remaining, 2.7 samples/s] \n" + " 100% |███████████████| 9184/9184 [56.3m elapsed, 0s remaining, 2.7 samples/s] \n" ] } ], "source": [ "# Do detections with model and save bounding boxes\n", - "yolo_view = yolo.view()\n", + "yolo_view = yolo_test.view()\n", "with fo.ProgressBar() as pb:\n", " for sample in pb(yolo_view):\n", " image = Image.open(sample.filepath)\n", @@ -811,7 +488,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 3, "id": "4aaa4577", "metadata": {}, "outputs": [ @@ -820,14 +497,14 @@ "output_type": "stream", "text": [ "Evaluating detections...\n", - " 100% |█████████████| 12106/12106 [42.8s elapsed, 0s remaining, 294.8 samples/s] \n", + " 100% |███████████████| 9184/9184 [24.5s elapsed, 0s remaining, 341.6 samples/s] \n", "Performing IoU sweep...\n", - " 100% |█████████████| 12106/12106 [43.5s elapsed, 0s remaining, 300.3 samples/s] \n" + " 100% |███████████████| 9184/9184 [26.9s elapsed, 0s remaining, 301.2 samples/s] \n" ] } ], "source": [ - "results = yolo.evaluate_detections(\"predictions\", gt_field=\"ground_truth\", eval_key=\"eval\", compute_mAP=True)" + "results = yolo_test.evaluate_detections(\"predictions\", gt_field=\"ground_truth\", eval_key=\"eval\", compute_mAP=True)" ] }, { @@ -842,7 +519,43 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 4, + "id": "59355da5", + "metadata": {}, + "outputs": [], + "source": [ + "from helpers import set_size\n", + "import matplotlib.pyplot as plt\n", + "import seaborn as sns\n", + "import pandas as pd" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "c77a4844", + "metadata": {}, + "outputs": [], + "source": [ + "# Style the plots\n", + "width = 418\n", + "sns.set_theme(style='whitegrid',\n", + " rc={'text.usetex': True, 'font.family': 'serif', 'axes.labelsize': 10,\n", + " 'font.size': 10, 'legend.fontsize': 8,\n", + " 'xtick.labelsize': 8, 'ytick.labelsize': 8})" + ] + }, + { + "cell_type": "markdown", + "id": "ea22d143", + "metadata": {}, + "source": [ + "The code for the LaTeX table of the classification report can be printed by first converting the results to a pandas DataFrame and then calling the `to_latex()` method of the DataFrame. This code can then be inserted into the LaTeX document." + ] + }, + { + "cell_type": "code", + "execution_count": 13, "id": "0c3c446e", "metadata": {}, "outputs": [ @@ -852,195 +565,62 @@ "text": [ " precision recall f1-score support\n", "\n", - " Plant 0.52 0.54 0.53 22535\n", + " Plant 0.55 0.74 0.63 12238\n", "\n", - " micro avg 0.52 0.54 0.53 22535\n", - " macro avg 0.52 0.54 0.53 22535\n", - "weighted avg 0.52 0.54 0.53 22535\n", - "\n", - "0.3623395579880134\n" + " micro avg 0.55 0.74 0.63 12238\n", + " macro avg 0.55 0.74 0.63 12238\n", + "weighted avg 0.55 0.74 0.63 12238\n", + "\n" ] - }, - { - "data": { - "text/plain": [] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "06770c63d5d34d6cb9c7c09821916697", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "FigureWidget({\n", - " 'data': [{'mode': 'markers',\n", - " 'opacity': 0.1,\n", - " 'type': 'scatter',\n", - " 'uid': '245dadac-2cdf-4379-b02c-25054e792f00',\n", - " 'x': array([0, 1, 0, 1]),\n", - " 'y': array([0, 0, 1, 1])},\n", - " {'colorscale': [[0.0, 'rgb(255,245,235)'], [0.125,\n", - " 'rgb(254,230,206)'], [0.25, 'rgb(253,208,162)'],\n", - " [0.375, 'rgb(253,174,107)'], [0.5, 'rgb(253,141,60)'],\n", - " [0.625, 'rgb(241,105,19)'], [0.75, 'rgb(217,72,1)'],\n", - " [0.875, 'rgb(166,54,3)'], [1.0, 'rgb(127,39,4)']],\n", - " 'hoverinfo': 'skip',\n", - " 'showscale': False,\n", - " 'type': 'heatmap',\n", - " 'uid': 'feaf31e2-40ce-4a97-953b-36efe673c3d7',\n", - " 'z': array([[11496, 0],\n", - " [12237, 10298]]),\n", - " 'zmax': 12237,\n", - " 'zmin': 0},\n", - " {'colorbar': {'len': 1, 'lenmode': 'fraction'},\n", - " 'colorscale': [[0.0, 'rgb(255,245,235)'], [0.125,\n", - " 'rgb(254,230,206)'], [0.25, 'rgb(253,208,162)'],\n", - " [0.375, 'rgb(253,174,107)'], [0.5, 'rgb(253,141,60)'],\n", - " [0.625, 'rgb(241,105,19)'], [0.75, 'rgb(217,72,1)'],\n", - " [0.875, 'rgb(166,54,3)'], [1.0, 'rgb(127,39,4)']],\n", - " 'hovertemplate': 'count: %{z}
truth: %{y}
predicted: %{x}',\n", - " 'opacity': 0.25,\n", - " 'type': 'heatmap',\n", - " 'uid': '7aa2a8da-7437-4ccc-a929-903b3de13a4b',\n", - " 'z': array([[11496, 0],\n", - " [12237, 10298]]),\n", - " 'zmax': 12237,\n", - " 'zmin': 0}],\n", - " 'layout': {'clickmode': 'event',\n", - " 'margin': {'b': 0, 'l': 0, 'r': 0, 't': 30},\n", - " 'template': '...',\n", - " 'title': {},\n", - " 'xaxis': {'constrain': 'domain',\n", - " 'range': [-0.5, 1.5],\n", - " 'tickmode': 'array',\n", - " 'ticktext': [Plant, (none)],\n", - " 'tickvals': array([0, 1])},\n", - " 'yaxis': {'constrain': 'domain',\n", - " 'range': [-0.5, 1.5],\n", - " 'scaleanchor': 'x',\n", - " 'scaleratio': 1,\n", - " 'tickmode': 'array',\n", - " 'ticktext': array(['(none)', 'Plant'], dtype=object),\n", - " 'tickvals': array([0, 1])}}\n", - "})" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, + } + ], + "source": [ + "results_df = pd.DataFrame(results.report()).transpose()\n", + "\n", + "# Export DataFrame to LaTeX tabular environment\n", + "# print(results_df.to_latex())\n", + "\n", + "# Print classification report\n", + "results.print_report()" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "6d857d9d", + "metadata": {}, + "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "\n" + "0.5726538843333254\n" + ] + } + ], + "source": [ + "print(results.mAP())" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "98122829", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Ignoring unsupported argument `thresholds` for the 'matplotlib' backend\n", + "Ignoring unsupported argument `thresholds` for the 'matplotlib' backend\n" ] }, { "data": { - "text/plain": [] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "972da7a137ab49bab9498d1deba213ef", - "version_major": 2, - "version_minor": 0 - }, + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjgAAACoCAYAAADtjJScAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAActklEQVR4nO3db2gb9/0H8LeWOq2z6qyBMZT4RFqsFlt2aEuzzRfYg5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676soClRVhSiKrvr3FQQB8Xhc/zk6+fsnyzKmpqaQz+cRi8Vc1zeaBXNM/WNknrEeXyvkmZYrcIiIiMj7WmqKioiIiFoDCxwiIiLyHBY4RERE5DkscIiIiMhzWOAQERGR57DAIVul02mMj4/jueeew6lTpxCPxxGPxzE+Pl63tTRkWUY0GtV3qF39moi8hXmGjOBj4mQ7VVWxY8cOXLlypWy9iqNHj+KDDz7Qj9mpuKZDLBar+JqIvIV5hjbCERxyhCRJUFXVNcuBE5H3MM9QKRY45IjiPjFO7kpMRK2FeYZKPdboAMi7ivvZpNNpLC0tYXZ2tmwp9eIGeaIoIpVKYWxsDMCjfVumpqYwMDAARVEwNDSkL98tCAKy2SwWFxf19kTUuphnqBqO4FDdSJKk/5mbmyvbzC2bzWJyclLfNC8YDCIej0NVVYyOjuLw4cOIRCJYXFzUb+I7evQoRFFELBZDPp/X9yshotbFPEPVcASH6i4cDqO/vx+Tk5OYmJgAAExNTaGjo6NsrjyVSkEQBIiiqN8gePjwYf394s2E2WwWS0tLju5wTETuxjxDq7HAIUf4/X5cvHix7FhfXx8kSdJfx2IxxONx+P1+/VjpkxBnzpxBIBBAJBJxbNdgImoezDNUilNU5IhgMKhfCaXTaQwPD2Nubq6sjSzLiEQiuHbt2prjsizj2rVrOHjwIERRRD6f198rUlW17PtWvyYib2OeoVJcB4dslU6nceHCBWSzWQwMDECSJP2JhiNHjmBgYEBfN0KWZXz00UcYGBgA8GguXRCEiscB4Ne//jX27t2rn2tqagrDw8MQRRHHjx8HAJw8eRIAyl7ziQoib2GeISNY4BAREZHncIqKiIiIPIcFDhEREXkOCxwiIiLyHBY4RERE5DkscIiIiMhzWOAQERGR57DAISIiIs9hgUNERESewwKHiIiIPIcFDhEREXkOCxwiIiLyHBY4RERE5Dn/B7bGNnWF/RAwAAAAAElFTkSuQmCC\n", "text/plain": [ - "FigureWidget({\n", - " 'data': [{'customdata': array([0.9709574 , 0.94905514, 0.94097441, 0.93560362, 0.93146831, 0.92766279,\n", - " 0.92468315, 0.92186761, 0.91872227, 0.91542256, 0.91216522, 0.90852749,\n", - " 0.90351772, 0.89783657, 0.8911835 , 0.88456821, 0.87576878, 0.86684024,\n", - " 0.85590148, 0.84403592, 0.82939762, 0.81318164, 0.79340947, 0.77035546,\n", - " 0.74586266, 0.72073823, 0.69323456, 0.65981126, 0.61941642, 0.57270879,\n", - " 0.52519083, 0.46561444, 0.40196586, 0.3248868 , 0. , 0. ,\n", - " 0. , 0. , 0. , 0. , 0. , 0. ,\n", - " 0. , 0. , 0. , 0. , 0. , 0. ,\n", - " 0. , 0. , 0. , 0. , 0. , 0. ,\n", - " 0. , 0. , 0. , 0. , 0. , 0. ,\n", - " 0. , 0. , 0. , 0. , 0. , 0. ,\n", - " 0. , 0. , 0. , 0. , 0. , 0. ,\n", - " 0. , 0. , 0. , 0. , 0. , 0. ,\n", - " 0. , 0. , 0. , 0. , 0. , 0. ,\n", - " 0. , 0. , 0. , 0. , 0. , 0. ,\n", - " 0. , 0. , 0. , 0. , 0. , 0. ,\n", - " 0. , 0. , 0. , 0. , 0. ]),\n", - " 'hovertemplate': ('class: %{text}
recal' ... 'customdata:.3f}'),\n", - " 'line': {'color': '#FF6D04'},\n", - " 'mode': 'lines',\n", - " 'name': 'Plant (AP = 0.278)',\n", - " 'text': array(['Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant',\n", - " 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant',\n", - " 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant',\n", - " 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant',\n", - " 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant',\n", - " 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant',\n", - " 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant',\n", - " 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant',\n", - " 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant',\n", - " 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant',\n", - " 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant',\n", - " 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant', 'Plant',\n", - " 'Plant', 'Plant', 'Plant', 'Plant', 'Plant'], dtype='" ] }, "metadata": {}, @@ -1048,18 +628,17 @@ } ], "source": [ - "# Print a classification report for all classes\n", - "results.print_report()\n", + "fig_save_dir = '../../thesis/graphics/'\n", "\n", - "print(results.mAP())\n", - "\n", - "# Plot confusion matrix\n", - "matrix = results.plot_confusion_matrix(classes=['Plant'])\n", - "matrix.show()\n", - "\n", - "pr_curves = results.plot_pr_curves(classes=['Plant'], iou_thresh=0.9)\n", - "print(pr_curves)\n", - "pr_curves.show()" + "fig, ax = plt.subplots(1, 2, figsize=set_size(width, subplots=(1,2)))\n", + "results.plot_pr_curves(iou_thresh=0.5, backend='matplotlib', ax=ax[0], color='black', linewidth=1)\n", + "results.plot_pr_curves(iou_thresh=0.95, backend='matplotlib', ax=ax[1], color='black', linewidth=1)\n", + "# Set the labels for the legends manually because\n", + "# the default ones contain a line for the classes (irrelevant).\n", + "ax[0].legend(['AP = 0.66'], frameon=False)\n", + "ax[1].legend(['AP = 0.41'], frameon=False)\n", + "fig.tight_layout()\n", + "fig.savefig(fig_save_dir + 'APpt5-pt95.pdf', format='pdf', bbox_inches='tight')" ] }, { @@ -1074,30 +653,10 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "id": "75fd090c", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Session launched. Run `session.show()` to open the App in a cell output.\n" - ] - }, - { - "data": { - "application/javascript": [ - "window.open('http://localhost:5151/');" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "session = fo.launch_app(yolo_view, auto=False)\n", "session.plots.attach(matrix)\n", diff --git a/thesis/graphics/APpt5-pt95.pdf b/thesis/graphics/APpt5-pt95.pdf new file mode 100644 index 0000000..bec6344 Binary files /dev/null and b/thesis/graphics/APpt5-pt95.pdf differ diff --git a/thesis/graphics/model_fitness.pdf b/thesis/graphics/model_fitness.pdf index 5cf9ba5..eaa3d9b 100644 Binary files a/thesis/graphics/model_fitness.pdf and b/thesis/graphics/model_fitness.pdf differ diff --git a/thesis/graphics/precision_recall.pdf b/thesis/graphics/precision_recall.pdf index 7288be6..923ee32 100644 Binary files a/thesis/graphics/precision_recall.pdf and b/thesis/graphics/precision_recall.pdf differ diff --git a/thesis/graphics/val_box_obj_loss.pdf b/thesis/graphics/val_box_obj_loss.pdf index 56a9315..231791a 100644 Binary files a/thesis/graphics/val_box_obj_loss.pdf and b/thesis/graphics/val_box_obj_loss.pdf differ