From c855b9873e7198645474de4dcaaace0fff2c9638 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Thu, 27 Jan 2022 00:51:52 +0800 Subject: [PATCH 01/10] Deploy docs with Material Sphinx Theme --- docs/requirements.txt | 2 +- docs/source/conf.py | 31 +++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 2b491a28..d2b965ac 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,5 @@ numpy jupyterlab sphinx==3.5.4 -insipid-sphinx-theme +sphinx-material nbsphinx==0.8.7 diff --git a/docs/source/conf.py b/docs/source/conf.py index 6f398bdc..dc5ccf8d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -19,8 +19,8 @@ # -- Project information ----------------------------------------------------- project = "yolort" -copyright = "2020-2021, yolort community" -author = "Zhiqiang Wang" +copyright = "2020-2022, yolort team" +author = "Zhiqiang Wang, Shiquan Yu, Fidan Kharrasov" # -- General configuration --------------------------------------------------- @@ -91,16 +91,31 @@ def setup(app): """ -html_theme = "insipid" +html_theme = "sphinx_material" -html_context = { - "display_github": True, - "github_user": "zhiqwang", - "github_repo": "yolov5-rt-stack", -} +# Material theme options (see theme.conf for more information) html_theme_options = { "left_buttons": [], "right_buttons": [ "repo-button.html", ], + # Set the name of the project to appear in the navigation. + "nav_title": "yolort", + # Set you GA account ID to enable tracking + # "google_analytics_account": "UA-XXXXX", + # Specify a base_url used to generate sitemap.xml. If not + # specified, then no sitemap will be built. + "base_url": "https://zhiqwang.com/yolov5-rt-stack", + # Set the color and the accent color + "color_primary": "blue", + "color_accent": "light-blue", + # Set the repo location to get a badge with stats + "repo_url": "https://github.com/zhiqwang/yolov5-rt-stack/", + "repo_name": "yolort", + # Visible levels of the global TOC; -1 means unlimited + "globaltoc_depth": 3, + # If False, expand all TOC entries + "globaltoc_collapse": False, + # If True, show hidden TOC entries + "globaltoc_includehidden": False, } From e93f24c069bd8b3629062c0cd43d82408a836be0 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Thu, 27 Jan 2022 01:42:56 +0800 Subject: [PATCH 02/10] Refactor index --- docs/source/index.rst | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 8cbed444..9b97c6ae 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,14 +1,6 @@ Welcome to yolort's documentation! ================================== -Runtime stack for YOLOv5 on specialized accelerators such as ``libtorch``, -``onnxruntime``, ``tvm`` and ``ncnn``. - -.. image:: _static/yolort_logo.png - :width: 400px - :align: center - - .. _what-is-yolort: **What is yolort?** @@ -19,7 +11,8 @@ structure as the official YOLOv5. The significant difference is that we adopt the dynamic shape mechanism, and within this, we can embed both pre-processing (``letterbox``) and post-processing (``nms``) into the model graph, which simplifies the deployment strategy. In this sense, ``yolort`` makes it possible -to be deployed more friendly on ``LibTorch``, ``ONNXRuntime``, ``TVM`` and so on. +to be deployed more friendly on ``LibTorch``, ``ONNX Runtime``, ``TensorRT``, ``TVM`` +and so on. .. _about-the-code: @@ -53,28 +46,3 @@ Read a source of image(s) and detect its objects: predictions = model.predict("bus.jpg") # Perform inference on a list of image files predictions = model.predict(["bus.jpg", "zidane.jpg"]) - -.. toctree:: - :maxdepth: 2 - :caption: Get started - - installation - -.. toctree:: - :maxdepth: 2 - :caption: Tutorials - - notebooks/inference-pytorch-export-libtorch - notebooks/how-to-align-with-ultralytics-yolov5 - notebooks/anchor-label-assignment-visualization - notebooks/model-graph-visualization - notebooks/export-onnx-inference-onnxruntime - notebooks/onnx-graphsurgeon-inference-tensorrt - notebooks/export-relay-inference-tvm - -.. toctree:: - :maxdepth: 2 - :caption: API Reference - - models - yolov5 From 6b2a4d5993b0842329eefc3e26a3f45344e67e32 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Thu, 27 Jan 2022 01:44:05 +0800 Subject: [PATCH 03/10] Update requirements for docs --- docs/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index d2b965ac..507c20ef 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,5 @@ numpy jupyterlab -sphinx==3.5.4 +sphinx sphinx-material -nbsphinx==0.8.7 +nbsphinx From 84d631e24135fe597d208cd8876c329c149a4ffd Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Thu, 27 Jan 2022 01:53:23 +0800 Subject: [PATCH 04/10] Update docs configuration --- docs/source/conf.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index dc5ccf8d..2b8fbaf9 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,6 +12,7 @@ # import os import sys +from datetime import datetime sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))) @@ -19,10 +20,9 @@ # -- Project information ----------------------------------------------------- project = "yolort" -copyright = "2020-2022, yolort team" +copyright = f"{datetime.now().year}, yolort team" author = "Zhiqiang Wang, Shiquan Yu, Fidan Kharrasov" - # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be @@ -95,12 +95,8 @@ def setup(app): # Material theme options (see theme.conf for more information) html_theme_options = { - "left_buttons": [], - "right_buttons": [ - "repo-button.html", - ], # Set the name of the project to appear in the navigation. - "nav_title": "yolort", + "nav_title": "Runtime Stack for Object Detection", # Set you GA account ID to enable tracking # "google_analytics_account": "UA-XXXXX", # Specify a base_url used to generate sitemap.xml. If not @@ -118,4 +114,22 @@ def setup(app): "globaltoc_collapse": False, # If True, show hidden TOC entries "globaltoc_includehidden": False, + # Text to appear at the top of the home page in a "hero" div. + "heroes": { + # We can have heroes for the home pages of training and inferencing in future. + "index": "A runtime stack for object detection on specialized accelerators." + }, } + +# Disable show source link. +html_show_sourcelink = False + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +html_sidebars = {"**": ["logo-text.html", "globaltoc.html", "localtoc.html", "searchbox.html"]} From dd7f2f34e7ede8283cf122cf483f5272fbe2ef0f Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Thu, 27 Jan 2022 01:58:12 +0800 Subject: [PATCH 05/10] Fix docs index --- docs/source/index.rst | 45 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 9b97c6ae..c66b9aa2 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -7,7 +7,7 @@ Welcome to yolort's documentation! ``yolort`` focus on making the training and inference of the object detection task integrate more seamlessly together. ``yolort`` now adopts the same model -structure as the official YOLOv5. The significant difference is that we adopt +structure as the official ``YOLOv5``. The significant difference is that we adopt the dynamic shape mechanism, and within this, we can embed both pre-processing (``letterbox``) and post-processing (``nms``) into the model graph, which simplifies the deployment strategy. In this sense, ``yolort`` makes it possible @@ -26,7 +26,7 @@ Follow the design principle of `detr ` not require complex libraries for training and inference. ``yolort`` is very simple to implement and experiment with. You like the implementation -of torchvision's faster-rcnn, retinanet or detr? You like yolov5? You love ``yolort``! +of torchvision's faster-rcnn, retinanet or detr? You like yolov5? You love yolort! .. _quick-get-stated: @@ -46,3 +46,44 @@ Read a source of image(s) and detect its objects: predictions = model.predict("bus.jpg") # Perform inference on a list of image files predictions = model.predict(["bus.jpg", "zidane.jpg"]) + +**Loading checkpoint from official yolov5** + +And we support loading the trained weights from YOLOv5: + +.. code:: python + + from yolort.models import YOLOv5 + from yolort.v5 import attempt_download + + # will downloaded from 'https://github.com/ultralytics/yolov5/releases/download/v6.0/yolov5n6.pt' + model_path = "yolov5n6.pt" + checkpoint_path = attempt_download(model_path) + + model = YOLOv5.load_from_yolov5(checkpoint_path, score_thresh=0.25) + + model.eval() + img_path = "bus.jpg" + predictions = model.predict(img_path) + + +.. toctree:: + :maxdepth: 2 + :titlesonly: + :hidden: + + installation + notebooks/inference-pytorch-export-libtorch + notebooks/how-to-align-with-ultralytics-yolov5 + notebooks/anchor-label-assignment-visualization + notebooks/model-graph-visualization + notebooks/export-onnx-inference-onnxruntime + notebooks/onnx-graphsurgeon-inference-tensorrt + notebooks/export-relay-inference-tvm + +.. toctree:: + :maxdepth: 2 + :caption: API Reference + + models + yolov5 From a56232ce6993e0ae56fcd15755de9a7efeaa1727 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Thu, 27 Jan 2022 02:14:47 +0800 Subject: [PATCH 06/10] Fixing navigation titles --- docs/source/conf.py | 2 +- docs/source/index.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 2b8fbaf9..61c393e9 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -96,7 +96,7 @@ def setup(app): # Material theme options (see theme.conf for more information) html_theme_options = { # Set the name of the project to appear in the navigation. - "nav_title": "Runtime Stack for Object Detection", + "nav_title": "YOLOv5 Runtime Stack", # Set you GA account ID to enable tracking # "google_analytics_account": "UA-XXXXX", # Specify a base_url used to generate sitemap.xml. If not diff --git a/docs/source/index.rst b/docs/source/index.rst index c66b9aa2..e3879aba 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -70,7 +70,6 @@ And we support loading the trained weights from YOLOv5: .. toctree:: :maxdepth: 2 :titlesonly: - :hidden: installation notebooks/inference-pytorch-export-libtorch @@ -83,6 +82,7 @@ And we support loading the trained weights from YOLOv5: .. toctree:: :maxdepth: 2 + :titlesonly: :caption: API Reference models From bba6b487b99cb698efdfe309a23668733cffbdaa Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Thu, 27 Jan 2022 02:25:04 +0800 Subject: [PATCH 07/10] Fixing navigation titles --- docs/source/index.rst | 14 +++++++++++++- notebooks/export-onnx-inference-onnxruntime.ipynb | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index e3879aba..8722640a 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -66,16 +66,28 @@ And we support loading the trained weights from YOLOv5: img_path = "bus.jpg" predictions = model.predict(img_path) - .. toctree:: :maxdepth: 2 :titlesonly: + :caption: Installation installation + +.. toctree:: + :maxdepth: 2 + :titlesonly: + :caption: Tutorials + notebooks/inference-pytorch-export-libtorch notebooks/how-to-align-with-ultralytics-yolov5 notebooks/anchor-label-assignment-visualization notebooks/model-graph-visualization + +.. toctree:: + :maxdepth: 2 + :titlesonly: + :caption: Deployment + notebooks/export-onnx-inference-onnxruntime notebooks/onnx-graphsurgeon-inference-tensorrt notebooks/export-relay-inference-tvm diff --git a/notebooks/export-onnx-inference-onnxruntime.ipynb b/notebooks/export-onnx-inference-onnxruntime.ipynb index 0d20d11e..b0d3a14b 100644 --- a/notebooks/export-onnx-inference-onnxruntime.ipynb +++ b/notebooks/export-onnx-inference-onnxruntime.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Deploying yolort on ONNXRuntime" + "# Deploying yolort on ONNX Runtime" ] }, { From 2570d6c417d617d62bc4ae5a45862e8933237c22 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Thu, 27 Jan 2022 02:36:09 +0800 Subject: [PATCH 08/10] Fixing configuration --- docs/requirements.txt | 1 + docs/source/conf.py | 5 +++++ docs/source/index.rst | 2 +- docs/source/installation.rst | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 507c20ef..b60d038b 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,6 @@ numpy jupyterlab +ipython sphinx sphinx-material nbsphinx diff --git a/docs/source/conf.py b/docs/source/conf.py index 61c393e9..dcd08ba9 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -30,8 +30,13 @@ # ones. extensions = [ "sphinx.ext.autodoc", + "sphinx.ext.mathjax", "sphinx.ext.napoleon", + "sphinx.ext.viewcode", + "sphinx.ext.intersphinx", + "sphinx.ext.extlinks", "nbsphinx", + "IPython.sphinxext.ipython_console_highlighting", ] # Add any paths that contain templates here, relative to this directory. diff --git a/docs/source/index.rst b/docs/source/index.rst index 8722640a..c17d3213 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -69,7 +69,7 @@ And we support loading the trained weights from YOLOv5: .. toctree:: :maxdepth: 2 :titlesonly: - :caption: Installation + :caption: Getting Started installation diff --git a/docs/source/installation.rst b/docs/source/installation.rst index c87633bc..e8f3eb05 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -1,4 +1,4 @@ -Installation +Install yolort ============ .. _required: From 9023937832760bef4aabc40ffa8aada4fa0188d1 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Thu, 27 Jan 2022 02:39:58 +0800 Subject: [PATCH 09/10] Minor fixes --- docs/source/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index c17d3213..0c807669 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -30,7 +30,7 @@ of torchvision's faster-rcnn, retinanet or detr? You like yolov5? You love yolor .. _quick-get-stated: -**Quick Get started** +**Introduction to yolort** Read a source of image(s) and detect its objects: From fed5d2ce37a46c996af2071f091eb8e760273976 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Thu, 27 Jan 2022 02:45:38 +0800 Subject: [PATCH 10/10] Fixed navigation titles --- docs/source/index.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 0c807669..2ed4295f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -66,6 +66,8 @@ And we support loading the trained weights from YOLOv5: img_path = "bus.jpg" predictions = model.predict(img_path) +**Use Cases and Solutions** + .. toctree:: :maxdepth: 2 :titlesonly: @@ -94,7 +96,6 @@ And we support loading the trained weights from YOLOv5: .. toctree:: :maxdepth: 2 - :titlesonly: :caption: API Reference models