From 07d8011e46ad78ed763ffa1a3e9427d4995d7913 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Thu, 5 May 2022 20:55:52 -0700 Subject: [PATCH] Update tutorial.ipynb (#7715) * Update tutorial.ipynb * Created using Colaboratory * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- tutorial.ipynb | 788 +++++++++++++++++++++++++------------------------ 1 file changed, 403 insertions(+), 385 deletions(-) diff --git a/tutorial.ipynb b/tutorial.ipynb index 19761bc7bff5..1f537c516ede 100644 --- a/tutorial.ipynb +++ b/tutorial.ipynb @@ -6,6 +6,7 @@ "name": "YOLOv5 Tutorial", "provenance": [], "collapsed_sections": [], + "machine_shape": "hm", "include_colab_link": true }, "kernelspec": { @@ -15,346 +16,346 @@ "accelerator": "GPU", "widgets": { "application/vnd.jupyter.widget-state+json": { - "eb95db7cae194218b3fcefb439b6352f": { + "d90eeb56398f458086e3b2b41dbd9fec": { "model_module": "@jupyter-widgets/controls", "model_name": "HBoxModel", "model_module_version": "1.5.0", "state": { - "_view_name": "HBoxView", "_dom_classes": [], - "_model_name": "HBoxModel", - "_view_module": "@jupyter-widgets/controls", + "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", "_view_count": null, + "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", + "_view_name": "HBoxView", "box_style": "", - "layout": "IPY_MODEL_769ecde6f2e64bacb596ce972f8d3d2d", - "_model_module": "@jupyter-widgets/controls", "children": [ - "IPY_MODEL_384a001876054c93b0af45cd1e960bfe", - "IPY_MODEL_dded0aeae74440f7ba2ffa0beb8dd612", - "IPY_MODEL_5296d28be75740b2892ae421bbec3657" - ] + "IPY_MODEL_d91d8347f17349a4987cea29eac0a49c", + "IPY_MODEL_8f4ffda703ac4348ab7edf1d12a188e1", + "IPY_MODEL_8c2d91f564de45f8a403386eeeccac27" + ], + "layout": "IPY_MODEL_5dd95d3eda8b49f7910620edcdcbdcdc" } }, - "769ecde6f2e64bacb596ce972f8d3d2d": { - "model_module": "@jupyter-widgets/base", - "model_name": "LayoutModel", - "model_module_version": "1.2.0", - "state": { - "_view_name": "LayoutView", - "grid_template_rows": null, - "right": null, - "justify_content": null, - "_view_module": "@jupyter-widgets/base", - "overflow": null, - "_model_module_version": "1.2.0", - "_view_count": null, - "flex_flow": null, - "width": null, - "min_width": null, - "border": null, - "align_items": null, - "bottom": null, - "_model_module": "@jupyter-widgets/base", - "top": null, - "grid_column": null, - "overflow_y": null, - "overflow_x": null, - "grid_auto_flow": null, - "grid_area": null, - "grid_template_columns": null, - "flex": null, - "_model_name": "LayoutModel", - "justify_items": null, - "grid_row": null, - "max_height": null, - "align_content": null, - "visibility": null, - "align_self": null, - "height": null, - "min_height": null, - "padding": null, - "grid_auto_rows": null, - "grid_gap": null, - "max_width": null, - "order": null, - "_view_module_version": "1.2.0", - "grid_template_areas": null, - "object_position": null, - "object_fit": null, - "grid_auto_columns": null, - "margin": null, - "display": null, - "left": null - } - }, - "384a001876054c93b0af45cd1e960bfe": { + "d91d8347f17349a4987cea29eac0a49c": { "model_module": "@jupyter-widgets/controls", "model_name": "HTMLModel", "model_module_version": "1.5.0", "state": { - "_view_name": "HTMLView", - "style": "IPY_MODEL_9f09facb2a6c4a7096810d327c8b551c", "_dom_classes": [], - "description": "", - "_model_name": "HTMLModel", - "placeholder": "​", - "_view_module": "@jupyter-widgets/controls", + "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", - "value": "100%", + "_model_name": "HTMLModel", "_view_count": null, + "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", "description_tooltip": null, - "_model_module": "@jupyter-widgets/controls", - "layout": "IPY_MODEL_25621cff5d16448cb7260e839fd0f543" + "layout": "IPY_MODEL_520e5b7e80eb450188261cffbc574d25", + "placeholder": "​", + "style": "IPY_MODEL_3cef138c5f7743858bb0f87b65dd3c76", + "value": "100%" } }, - "dded0aeae74440f7ba2ffa0beb8dd612": { + "8f4ffda703ac4348ab7edf1d12a188e1": { "model_module": "@jupyter-widgets/controls", "model_name": "FloatProgressModel", "model_module_version": "1.5.0", "state": { - "_view_name": "ProgressView", - "style": "IPY_MODEL_0ce7164fc0c74bb9a2b5c7037375a727", "_dom_classes": [], - "description": "", - "_model_name": "FloatProgressModel", - "bar_style": "success", - "max": 818322941, - "_view_module": "@jupyter-widgets/controls", + "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", - "value": 818322941, + "_model_name": "FloatProgressModel", "_view_count": null, + "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", - "orientation": "horizontal", - "min": 0, + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", "description_tooltip": null, - "_model_module": "@jupyter-widgets/controls", - "layout": "IPY_MODEL_c4c4593c10904cb5b8a5724d60c7e181" + "layout": "IPY_MODEL_c3782c6dda80400ba7f8c5345624bf87", + "max": 818322941, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_11415bab172a4904b73e29ff60f6fce1", + "value": 818322941 } }, - "5296d28be75740b2892ae421bbec3657": { + "8c2d91f564de45f8a403386eeeccac27": { "model_module": "@jupyter-widgets/controls", "model_name": "HTMLModel", "model_module_version": "1.5.0", "state": { - "_view_name": "HTMLView", - "style": "IPY_MODEL_473371611126476c88d5d42ec7031ed6", "_dom_classes": [], - "description": "", - "_model_name": "HTMLModel", - "placeholder": "​", - "_view_module": "@jupyter-widgets/controls", + "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", - "value": " 780M/780M [00:11<00:00, 91.9MB/s]", + "_model_name": "HTMLModel", "_view_count": null, + "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", "description_tooltip": null, - "_model_module": "@jupyter-widgets/controls", - "layout": "IPY_MODEL_65efdfd0d26c46e79c8c5ff3b77126cc" + "layout": "IPY_MODEL_eac18040908042dbae67a47d23e95b47", + "placeholder": "​", + "style": "IPY_MODEL_e0fc1d6eb478469c9098aa9518d7b358", + "value": " 780M/780M [01:17<00:00, 17.7MB/s]" } }, - "9f09facb2a6c4a7096810d327c8b551c": { - "model_module": "@jupyter-widgets/controls", - "model_name": "DescriptionStyleModel", - "model_module_version": "1.5.0", + "5dd95d3eda8b49f7910620edcdcbdcdc": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", "state": { - "_view_name": "StyleView", - "_model_name": "DescriptionStyleModel", - "description_width": "", - "_view_module": "@jupyter-widgets/base", - "_model_module_version": "1.5.0", + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", "_view_count": null, + "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", - "_model_module": "@jupyter-widgets/controls" + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null } }, - "25621cff5d16448cb7260e839fd0f543": { + "520e5b7e80eb450188261cffbc574d25": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "model_module_version": "1.2.0", "state": { - "_view_name": "LayoutView", - "grid_template_rows": null, - "right": null, - "justify_content": null, - "_view_module": "@jupyter-widgets/base", - "overflow": null, + "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", "_view_count": null, - "flex_flow": null, - "width": null, - "min_width": null, - "border": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, "align_items": null, + "align_self": null, + "border": null, "bottom": null, - "_model_module": "@jupyter-widgets/base", - "top": null, - "grid_column": null, - "overflow_y": null, - "overflow_x": null, - "grid_auto_flow": null, + "display": null, + "flex": null, + "flex_flow": null, "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, "grid_template_columns": null, - "flex": null, - "_model_name": "LayoutModel", + "grid_template_rows": null, + "height": null, + "justify_content": null, "justify_items": null, - "grid_row": null, + "left": null, + "margin": null, "max_height": null, - "align_content": null, - "visibility": null, - "align_self": null, - "height": null, - "min_height": null, - "padding": null, - "grid_auto_rows": null, - "grid_gap": null, "max_width": null, - "order": null, - "_view_module_version": "1.2.0", - "grid_template_areas": null, - "object_position": null, + "min_height": null, + "min_width": null, "object_fit": null, - "grid_auto_columns": null, - "margin": null, - "display": null, - "left": null + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null } }, - "0ce7164fc0c74bb9a2b5c7037375a727": { + "3cef138c5f7743858bb0f87b65dd3c76": { "model_module": "@jupyter-widgets/controls", - "model_name": "ProgressStyleModel", + "model_name": "DescriptionStyleModel", "model_module_version": "1.5.0", "state": { - "_view_name": "StyleView", - "_model_name": "ProgressStyleModel", - "description_width": "", - "_view_module": "@jupyter-widgets/base", + "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", "_view_count": null, + "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", - "bar_color": null, - "_model_module": "@jupyter-widgets/controls" + "_view_name": "StyleView", + "description_width": "" } }, - "c4c4593c10904cb5b8a5724d60c7e181": { + "c3782c6dda80400ba7f8c5345624bf87": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "model_module_version": "1.2.0", "state": { - "_view_name": "LayoutView", - "grid_template_rows": null, - "right": null, - "justify_content": null, - "_view_module": "@jupyter-widgets/base", - "overflow": null, + "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", "_view_count": null, - "flex_flow": null, - "width": null, - "min_width": null, - "border": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, "align_items": null, + "align_self": null, + "border": null, "bottom": null, - "_model_module": "@jupyter-widgets/base", - "top": null, - "grid_column": null, - "overflow_y": null, - "overflow_x": null, - "grid_auto_flow": null, + "display": null, + "flex": null, + "flex_flow": null, "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, "grid_template_columns": null, - "flex": null, - "_model_name": "LayoutModel", + "grid_template_rows": null, + "height": null, + "justify_content": null, "justify_items": null, - "grid_row": null, + "left": null, + "margin": null, "max_height": null, - "align_content": null, - "visibility": null, - "align_self": null, - "height": null, - "min_height": null, - "padding": null, - "grid_auto_rows": null, - "grid_gap": null, "max_width": null, - "order": null, - "_view_module_version": "1.2.0", - "grid_template_areas": null, - "object_position": null, + "min_height": null, + "min_width": null, "object_fit": null, - "grid_auto_columns": null, - "margin": null, - "display": null, - "left": null + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null } }, - "473371611126476c88d5d42ec7031ed6": { + "11415bab172a4904b73e29ff60f6fce1": { "model_module": "@jupyter-widgets/controls", - "model_name": "DescriptionStyleModel", + "model_name": "ProgressStyleModel", "model_module_version": "1.5.0", "state": { - "_view_name": "StyleView", - "_model_name": "DescriptionStyleModel", - "description_width": "", - "_view_module": "@jupyter-widgets/base", + "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", "_view_count": null, + "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", - "_model_module": "@jupyter-widgets/controls" + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" } }, - "65efdfd0d26c46e79c8c5ff3b77126cc": { + "eac18040908042dbae67a47d23e95b47": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "model_module_version": "1.2.0", "state": { - "_view_name": "LayoutView", - "grid_template_rows": null, - "right": null, - "justify_content": null, - "_view_module": "@jupyter-widgets/base", - "overflow": null, + "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", "_view_count": null, - "flex_flow": null, - "width": null, - "min_width": null, - "border": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, "align_items": null, + "align_self": null, + "border": null, "bottom": null, - "_model_module": "@jupyter-widgets/base", - "top": null, - "grid_column": null, - "overflow_y": null, - "overflow_x": null, - "grid_auto_flow": null, + "display": null, + "flex": null, + "flex_flow": null, "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, "grid_template_columns": null, - "flex": null, - "_model_name": "LayoutModel", + "grid_template_rows": null, + "height": null, + "justify_content": null, "justify_items": null, - "grid_row": null, + "left": null, + "margin": null, "max_height": null, - "align_content": null, - "visibility": null, - "align_self": null, - "height": null, - "min_height": null, - "padding": null, - "grid_auto_rows": null, - "grid_gap": null, "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "e0fc1d6eb478469c9098aa9518d7b358": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "model_module_version": "1.5.0", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", - "grid_template_areas": null, - "object_position": null, - "object_fit": null, - "grid_auto_columns": null, - "margin": null, - "display": null, - "left": null + "_view_name": "StyleView", + "description_width": "" } } } @@ -368,7 +369,7 @@ "colab_type": "text" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -402,7 +403,7 @@ "colab": { "base_uri": "https://localhost:8080/" }, - "outputId": "3809e5a9-dd41-4577-fe62-5531abf7cca2" + "outputId": "ebf225bd-e109-4dbd-8561-3b15514ca47c" }, "source": [ "!git clone https://github.com/ultralytics/yolov5 # clone\n", @@ -413,14 +414,20 @@ "import utils\n", "display = utils.notebook_init() # checks" ], - "execution_count": null, + "execution_count": 1, "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "YOLOv5 🚀 v6.1-174-gc4cb7c6 torch 1.11.0+cu113 CUDA:0 (Tesla V100-SXM2-16GB, 16160MiB)\n" + ] + }, { "output_type": "stream", "name": "stdout", "text": [ - "YOLOv5 🚀 v6.0-48-g84a8099 torch 1.10.0+cu102 CUDA:0 (Tesla V100-SXM2-16GB, 16160MiB)\n", - "Setup complete ✅ (2 CPUs, 12.7 GB RAM, 42.2/166.8 GB disk)\n" + "Setup complete ✅ (8 CPUs, 51.0 GB RAM, 38.2/166.8 GB disk)\n" ] } ] @@ -453,26 +460,29 @@ "colab": { "base_uri": "https://localhost:8080/" }, - "outputId": "8f7e6588-215d-4ebd-93af-88b871e770a7" + "outputId": "2f43338d-f533-4277-ef9f-b37b565e2702" }, "source": [ "!python detect.py --weights yolov5s.pt --img 640 --conf 0.25 --source data/images\n", "display.Image(filename='runs/detect/exp/zidane.jpg', width=600)" ], - "execution_count": null, + "execution_count": 2, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ - "\u001b[34m\u001b[1mdetect: \u001b[0mweights=['yolov5s.pt'], source=data/images, imgsz=[640, 640], conf_thres=0.25, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs/detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False\n", - "YOLOv5 🚀 v6.0-48-g84a8099 torch 1.10.0+cu102 CUDA:0 (Tesla V100-SXM2-16GB, 16160MiB)\n", + "\u001b[34m\u001b[1mdetect: \u001b[0mweights=['yolov5s.pt'], source=data/images, data=data/coco128.yaml, imgsz=[640, 640], conf_thres=0.25, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs/detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False\n", + "YOLOv5 🚀 v6.1-174-gc4cb7c6 torch 1.11.0+cu113 CUDA:0 (Tesla V100-SXM2-16GB, 16160MiB)\n", + "\n", + "Downloading https://github.com/ultralytics/yolov5/releases/download/v6.1/yolov5s.pt to yolov5s.pt...\n", + "100% 14.1M/14.1M [00:00<00:00, 220MB/s]\n", "\n", "Fusing layers... \n", - "Model Summary: 213 layers, 7225885 parameters, 0 gradients\n", - "image 1/2 /content/yolov5/data/images/bus.jpg: 640x480 4 persons, 1 bus, Done. (0.007s)\n", - "image 2/2 /content/yolov5/data/images/zidane.jpg: 384x640 2 persons, 1 tie, Done. (0.007s)\n", - "Speed: 0.5ms pre-process, 6.9ms inference, 1.3ms NMS per image at shape (1, 3, 640, 640)\n", + "YOLOv5s summary: 213 layers, 7225885 parameters, 0 gradients\n", + "image 1/2 /content/yolov5/data/images/bus.jpg: 640x480 4 persons, 1 bus, Done. (0.012s)\n", + "image 2/2 /content/yolov5/data/images/zidane.jpg: 384x640 2 persons, 2 ties, Done. (0.013s)\n", + "Speed: 0.5ms pre-process, 12.5ms inference, 17.3ms NMS per image at shape (1, 3, 640, 640)\n", "Results saved to \u001b[1mruns/detect/exp\u001b[0m\n" ] } @@ -514,41 +524,41 @@ "id": "WQPtK1QYVaD_", "colab": { "base_uri": "https://localhost:8080/", - "height": 48, + "height": 49, "referenced_widgets": [ - "eb95db7cae194218b3fcefb439b6352f", - "769ecde6f2e64bacb596ce972f8d3d2d", - "384a001876054c93b0af45cd1e960bfe", - "dded0aeae74440f7ba2ffa0beb8dd612", - "5296d28be75740b2892ae421bbec3657", - "9f09facb2a6c4a7096810d327c8b551c", - "25621cff5d16448cb7260e839fd0f543", - "0ce7164fc0c74bb9a2b5c7037375a727", - "c4c4593c10904cb5b8a5724d60c7e181", - "473371611126476c88d5d42ec7031ed6", - "65efdfd0d26c46e79c8c5ff3b77126cc" + "d90eeb56398f458086e3b2b41dbd9fec", + "d91d8347f17349a4987cea29eac0a49c", + "8f4ffda703ac4348ab7edf1d12a188e1", + "8c2d91f564de45f8a403386eeeccac27", + "5dd95d3eda8b49f7910620edcdcbdcdc", + "520e5b7e80eb450188261cffbc574d25", + "3cef138c5f7743858bb0f87b65dd3c76", + "c3782c6dda80400ba7f8c5345624bf87", + "11415bab172a4904b73e29ff60f6fce1", + "eac18040908042dbae67a47d23e95b47", + "e0fc1d6eb478469c9098aa9518d7b358" ] }, - "outputId": "bcf9a448-1f9b-4a41-ad49-12f181faf05a" + "outputId": "26f3c005-cc13-4b7c-8523-844b56a0b0e3" }, "source": [ "# Download COCO val\n", "torch.hub.download_url_to_file('https://ultralytics.com/assets/coco2017val.zip', 'tmp.zip')\n", "!unzip -q tmp.zip -d ../datasets && rm tmp.zip" ], - "execution_count": null, + "execution_count": 3, "outputs": [ { "output_type": "display_data", "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "eb95db7cae194218b3fcefb439b6352f", - "version_minor": 0, - "version_major": 2 - }, "text/plain": [ " 0%| | 0.00/780M [00:00