From fe75a9ce6773dacdea1ef9d886384d727b3232d6 Mon Sep 17 00:00:00 2001 From: Ayush Chaurasia Date: Mon, 5 Dec 2022 06:04:57 +0530 Subject: [PATCH] docs setup (#61) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 3 +- CONTRIBUTING.md | 31 +++++++++++++ docs/README.md | 7 +++ docs/assets/logo.png | Bin 0 -> 6354 bytes docs/cli.md | 72 +++++++++++++++++++++++++++++ docs/conf.md | 0 docs/index.md | 3 ++ docs/quickstart.md | 45 +++++++++++++++++++ docs/reference/ref.md | 0 docs/sdk.md | 11 +++++ docs/tasks/classification.md | 0 docs/tasks/detection.md | 0 docs/tasks/segmentation.md | 0 docs/trainer.md | 0 mkdocs.yml | 85 +++++++++++++++++++++++++++++++++++ setup.py | 4 +- 16 files changed, 258 insertions(+), 3 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 docs/README.md create mode 100644 docs/assets/logo.png create mode 100644 docs/cli.md create mode 100644 docs/conf.md create mode 100644 docs/index.md create mode 100644 docs/quickstart.md create mode 100644 docs/reference/ref.md create mode 100644 docs/sdk.md create mode 100644 docs/tasks/classification.md create mode 100644 docs/tasks/detection.md create mode 100644 docs/tasks/segmentation.md create mode 100644 docs/trainer.md create mode 100644 mkdocs.yml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ba80055..661d1f8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,6 +4,7 @@ default_language_version: python: python3.8 +exclude: 'docs/' # Define bot property if installed via https://github.com/marketplace/pre-commit-ci ci: autofix_prs: true @@ -50,7 +51,7 @@ repos: additional_dependencies: - mdformat-gfm - mdformat-black - exclude: "README.md|README_cn.md" + exclude: "README.md|README_cn.md| CONTRIBUTING.md" - repo: https://github.com/asottile/yesqa rev: v1.4.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..9c11216 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,31 @@ +## Contributing to Ultralytics: The YOLO framework + +We love your input! We want to make contributing to YOLOv5 as easy and transparent as possible, whether it's: + +Reporting a bug +Discussing the current state of the code +Submitting a fix +Proposing a new feature +Becoming a maintainer + +Here are some things to keep in mind when making PRs: + +### Docstrings + +Not all functions or classes require docstrings but when they do, we follow [google-stlye docstrings format](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings). Here is an example: + +``` +''' + What the function does - performs nms on given detection predictions + + Args: + arg1: The description of the 1st argument + arg2: The description of the 2nd argument + + Returns: + What the function returns. Empty if nothing is returned + + Raises: + Exception Class: When and why this exception can be raised by the function. +''' +``` diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..2236b87 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,7 @@ +## To serve docs +* Install ultralytics repo in Dev mode: +``` +cd ultralytics +pip install -e '.[dev]' +``` +* Run `mkdocs serve` diff --git a/docs/assets/logo.png b/docs/assets/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..fb41ad61ed57d0316220fc61f7212be21b87d7c4 GIT binary patch literal 6354 zcmX9jc|4Te_YY=jY#G~Y&-SWpSu#XfvQ*1?cv z3?*4g%vh5O*^6X1zo+l-kNdgLIrp4<@44sPv)m`e?$TL7K50Gx00hsUvvdFeE*97z zumd0_Yf(HJ?0E6#T!R3BU-WO|0&?>uK_pj@!&!5H+9x{)0uY}wwr2pK>OcNncPIcz z`kc2s<9LT_X~GRBbGGr#uaaXnM^C`ueSGE>ZNK@H+zwR9`a+9ik$>o^ueq5DqL8^(h@;QOUJ!enpv8O$JI|1eU&r!%ie%S2vJ`-sP(->RYB3jGS4;y9T@V@%e>>KpVasTm1^`Zo-(~U zeWj$#rX@s+4lUzEt%|wHl#}@7Lhn_n$76F~&V!>T&$%U2>5H#@?`B5)*@Fva^wJ&v zSg_7;5_QBkw9hpp-p5!ijdMmq$M62Au5uk>|6D9b zpAjBzg9~@_E6{n=z=@D7^(koxLE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uh4Me^v)hkDKRKHjw! ziT=F4uRbOYID(n5on!ghue|fSRRx-47r?8?Lr~0V;qI=tNYR@kGuOBtr=}t>j^&0r zMpYKKmd16WxXc(ZRvSIFZ1!4dW8jy(yj>&r)|cl2J2(M>cP!sp<63Chyj<_n`y5d4 zfnXt}D1KdOC6m?RxXLF~O# z)pFrUr5jv5shISxIG&w1C|ZKUrVT5JvU7qnch~+bB?YR@OF$@rCGd1&@G(cGQ_b;P z|0P*-Rx9FSGoI!_e<~6Xx*Hoy#L33XFhYgj#QQ2b1;<&sx1=`y$dp5;-wpUI<*RLd z>)Y)6^cKA7*lkYVbVbd*AJNgJ%}b|d9srgpnDic|+t}f2`ntr=pc}Kj3=}f66CZ@v zJ?~w+Eg3N(H6i}jc!Z5)ex&FGB+1xY=)L0l2nzCD#``#BnHPY|5)ckWh;09N2Z2~c zr1DH+eAG~P;C~TcgP=-QmDc{Xi4PU0jC3LDaCNYNFA_ybiX4bBgHsS+lH%vUPi^qi z?1?rIABQRDomBBBm6#hNXOOW-VG1J9#ICJLa^;1 zX_q`B_hh>`uxeEansFr{k~KXDCF-vJtb4j6Jb(pdCr3sIma8Pj<^E%YYHi#Y&M zr#?8>sKoKYV2;n2j>Roj z`0;EE^ef2qBRwf~;h$KO~1&mD@3`xBy^QG9HKV)Onkdhh7Mj3ZF^`}*q8UYloW*8=zp O0yuAV$&zZ0A^aZ=y4)xL literal 0 HcmV?d00001 diff --git a/docs/cli.md b/docs/cli.md new file mode 100644 index 0000000..8b8f41b --- /dev/null +++ b/docs/cli.md @@ -0,0 +1,72 @@ +## CLI Basics +If you want to train, validate or run inference on models and don't need to make any modifications to the code, using YOLO command line interface is the easiest way to get started. + +!!! tip "Syntax" + ```bash + yolo task=detect mode=train model=s.yaml epochs=1 ... + ... ... ... + segment infer s-cls.pt + classify val s-seg.pt + ``` + +The experiment arguments can be overridden directly by pass `arg=val` covered in the next section. You can run any supported task by setting `task` and `mode` in cli. +=== "Training" + + | | `task` | snippet | + | ----------- | ------------- | ----------------------------------------------------------- | + | Detection | `detect` |
yolo task=detect mode=train       
| + | Instance Segment | `segment` |
yolo task=segment mode=train      
| + | Classification | `classify` |
yolo task=classify mode=train    
| + +=== "Inference" + + | | `task` | snippet | + | ----------- | ------------- | ------------------------------------------------------------ | + | Detection | `detect` |
yolo task=detect mode=infer       
| + | Instance Segment | `segment` |
yolo task=segment mode=infer     
| + | Classification | `classify` |
yolo task=classify mode=infer    
| + +=== "Validation" + + | | `task` | snippet | + | ----------- | ------------- | ------------------------------------------------------------- | + | Detection | `detect` |
yolo task=detect mode=val        
| + | Instance Segment | `segment` |
yolo task=segment mode=val       
| + | Classification | `classify` |
yolo task=classify mode=val      
| + +!!! note "" + Note: The arguments don't require `'--'` prefix. These are reserved for special commands covered later +--- +## Overriding default config arguments +All global default arguments can be overriden by simply passing them as arguments in the cli. +!!! tip "" + === "Syntax" + ```yolo task= ... mode= ... {++ arg=val ++}``` + + === "Example" + Perform detection training for `10 epochs` with `learning_rate` of `0.01` + ``` + yolo task=detect mode=train {++ epochs=10 lr0=0.01 ++} + + ``` +--- +## Overriding default config file +You can override config file entirely by passing a new file. You can create a copy of default config file in your current working dir as follows: +```bash +yolo task=init +``` +You can then use special `--cfg name.yaml` command to pass the new config file +```bash +yolo task=detect mode=train {++ --cfg default.yaml ++} +``` + +??? example + === "Command" + ``` + yolo task=init + yolo task=detect mode=train --cfg default.yaml + ``` + === "Result" + TODO: add terminal output + + diff --git a/docs/conf.md b/docs/conf.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..208b23c --- /dev/null +++ b/docs/index.md @@ -0,0 +1,3 @@ +# Welcome to Ultralytics YOLO + +TODO diff --git a/docs/quickstart.md b/docs/quickstart.md new file mode 100644 index 0000000..3af3dbf --- /dev/null +++ b/docs/quickstart.md @@ -0,0 +1,45 @@ +## Installation +!!! note "Latest Stable Release" + ``` + pip install ultralytics + ``` +??? tip "Development and Contributing" + ``` + git clone https://github.com/ultralytics/ultralytics + cd ultralytics + pip install -e '.[dev]' + ``` + See contributing section to know more about contributing to the project + + +## CLI +The command line YOLO interface let's you simply train, validate or infer models on various tasks and versions. +CLI requires no customization or code. You can simply run all tasks from the terminal +!!! tip + === "Syntax" + ```bash + yolo task=detect mode=train model=s.yaml epochs=1 ... + ... ... ... + segment infer s-cls.pt + classify val s-seg.pt + ``` + + === "Example" + ```bash + yolo task=detect mode=val model=s.yaml + ``` + TODO: add terminal screen/gif +[CLI Guide](#){ .md-button .md-button--primary} + +## Python API +Ultralytics YOLO comes with pythonic Model and Trainer interface. +!!! tip + ```python + import ultralytics + from ultralytics import YOLO + model = YOLO() + model.new("s-seg.yaml") # automatically detects task type + model.load("s-seg.pt") # load checkpoint + model.train(data="coco128-segments", epochs=1, lr0=0.01, ...) + ``` +[API Guide](#){ .md-button .md-button--primary} \ No newline at end of file diff --git a/docs/reference/ref.md b/docs/reference/ref.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/sdk.md b/docs/sdk.md new file mode 100644 index 0000000..cbe361b --- /dev/null +++ b/docs/sdk.md @@ -0,0 +1,11 @@ +# Python SDK + +We provide 2 pythonic interfaces for YOLO models: + + Model Interface - To simply build, load, train or run inference on a model in a python application + + Trainer Interface - To customize trainier elements depending on the task. Suitable for R&D ideas like architecutres. + +______________________________________________________________________ + +### Model Interface diff --git a/docs/tasks/classification.md b/docs/tasks/classification.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/tasks/detection.md b/docs/tasks/detection.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/tasks/segmentation.md b/docs/tasks/segmentation.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/trainer.md b/docs/trainer.md new file mode 100644 index 0000000..e69de29 diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..04240ff --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,85 @@ +site_name: Ultralytics YOLO Docs +repo_url: https://github.com/ultralytics/yolov5 +repo_name: Ultralytics + +theme: + name: "material" + logo: assets/logo.png + icon: + repo: fontawesome/brands/github + admonition: + note: octicons/tag-16 + abstract: octicons/checklist-16 + info: octicons/info-16 + tip: octicons/squirrel-16 + success: octicons/check-16 + question: octicons/question-16 + warning: octicons/alert-16 + failure: octicons/x-circle-16 + danger: octicons/zap-16 + bug: octicons/bug-16 + example: octicons/beaker-16 + quote: octicons/quote-16 + + palette: + # Palette toggle for light mode + - scheme: default + toggle: + icon: material/brightness-7 + name: Switch to dark mode + + # Palette toggle for dark mode + - scheme: slate + toggle: + icon: material/brightness-4 + name: Switch to light mode + features: + - content.code.annotate + - content.tooltips + - search.highlight + - search.share + - search.suggest + - toc.follow + +markdown_extensions: + # Div text decorators + - admonition + - pymdownx.details + - pymdownx.superfences + - tables + + # Syntax highlight + - pymdownx.highlight: + anchor_linenums: true + - pymdownx.inlinehilite + - pymdownx.snippets + + # button + - attr_list + + # content tabs + - pymdownx.superfences + - pymdownx.tabbed: + alternate_style: true + + # highlight + - pymdownx.critic + - pymdownx.caret + - pymdownx.keys + - pymdownx.mark + - pymdownx.tilde +plugins: + - mkdocstrings + +# primary navigation +nav: + - Quickstart: quickstart.md + - CLI: cli.md + - Python SDK: sdk.md + - Trainer: trainer.md + - Configuration: conf.md + - Tasks: + - Detection: tasks/detection.md + - Segmentation: tasks/segmentation.md + - Classification: tasks/classification.md + - Reference: reference/ref.md \ No newline at end of file diff --git a/setup.py b/setup.py index cd1c0db..6b2c302 100644 --- a/setup.py +++ b/setup.py @@ -35,8 +35,8 @@ setup( include_package_data=True, install_requires=REQUIREMENTS, extras_require={ - 'dev': ['check-manifest'], - 'test': ['pytest', 'pytest-cov', 'coverage'],}, + 'dev': + ['check-manifest', 'pytest', 'pytest-cov', 'coverage', 'mkdocs', 'mkdocstrings[python]', 'mkdocs-material'],}, classifiers=[ "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python :: 3",