Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Muhammad Rizwan Munawar <chr043416@gmail.com>
This commit is contained in:
Glenn Jocher 2024-01-24 19:28:02 +01:00 committed by GitHub
parent 3c1170769a
commit a2222b4283
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 80 additions and 32 deletions

View File

@ -53,16 +53,19 @@ I have read the CLA Document and I sign the CLA
When adding new functions or classes, please include a [Google-style docstring](https://google.github.io/styleguide/pyguide.html) to provide clear and concise documentation for other developers. This will help ensure that your contributions are easy to understand and maintain. When adding new functions or classes, please include a [Google-style docstring](https://google.github.io/styleguide/pyguide.html) to provide clear and concise documentation for other developers. This will help ensure that your contributions are easy to understand and maintain.
Example Google-style docstring: !!! Example "Example Docstrings"
```python === "Google-style"
def example_function(arg1: int, arg2: int) -> bool:
This example shows both Google-style docstrings. Note that both input and output `types` must always be enclosed by parentheses, i.e. `(bool)`.
```python
def example_function(arg1, arg2=4):
""" """
Example function that demonstrates Google-style docstrings. Example function that demonstrates Google-style docstrings.
Args: Args:
arg1 (int): The first argument. arg1 (int): The first argument.
arg2 (int): The second argument. arg2 (int): The second argument. Default value is 4.
Returns: Returns:
(bool): True if successful, False otherwise. (bool): True if successful, False otherwise.
@ -73,7 +76,39 @@ def example_function(arg1: int, arg2: int) -> bool:
if arg1 == arg2: if arg1 == arg2:
return True return True
return False return False
``` ```
=== "Google-style with type hints"
This example shows both Google-style docstrings and argument and return type hints, though both are not required, one can be used without the other.
```python
def example_function(arg1: int, arg2: int = 4) -> bool:
"""
Example function that demonstrates Google-style docstrings.
Args:
arg1: The first argument.
arg2: The second argument. Default value is 4.
Returns:
True if successful, False otherwise.
Examples:
>>> result = example_function(1, 2) # returns False
"""
if arg1 == arg2:
return True
return False
```
=== "Single-line"
Smaller or simpler functions can utilize a single-line docstring. Note the docstring must use 3 double-quotes, and be a complete sentence starting with a capital letter and ending with a period.
```python
def example_small_function(arg1: int, arg2: int = 4) -> bool:
"""Example function that demonstrates a single-line docstring."""
return arg1 == arg2
```
### GitHub Actions CI Tests ### GitHub Actions CI Tests

View File

@ -1,7 +1,7 @@
--- ---
comments: true comments: true
description: Access object detection capabilities of YOLOv8 via our RESTful API. Learn how to use the YOLO Inference API with Python or CLI for swift object detection. description: Access object detection capabilities of YOLOv8 via our RESTful API. Learn how to use the YOLO Inference API with Python or cURL for swift object detection.
keywords: Ultralytics, YOLOv8, Inference API, object detection, RESTful API, Python, CLI, Quickstart keywords: Ultralytics, YOLOv8, Inference API, object detection, RESTful API, Python, cURL, Quickstart
--- ---
# YOLO Inference API # YOLO Inference API
@ -44,9 +44,9 @@ print(response.json())
In this example, replace `API_KEY` with your actual API key, `MODEL_ID` with the desired model ID, and `path/to/image.jpg` with the path to the image you want to analyze. In this example, replace `API_KEY` with your actual API key, `MODEL_ID` with the desired model ID, and `path/to/image.jpg` with the path to the image you want to analyze.
## Example Usage with CLI ## Example Usage with cURL
You can use the YOLO Inference API with the command-line interface (CLI) by utilizing the `curl` command. Replace `API_KEY` with your actual API key, `MODEL_ID` with the desired model ID, and `image.jpg` with the path to the image you want to analyze: You can use the YOLO Inference API with client URL (cURL) by utilizing the `curl` command. Replace `API_KEY` with your actual API key, `MODEL_ID` with the desired model ID, and `image.jpg` with the path to the image you want to analyze:
```bash ```bash
curl -X POST "https://api.ultralytics.com/v1/predict/MODEL_ID" \ curl -X POST "https://api.ultralytics.com/v1/predict/MODEL_ID" \
@ -103,11 +103,11 @@ The JSON list contains information about the detected objects, their coordinates
### Detect Model Format ### Detect Model Format
YOLO detection models, such as `yolov8n.pt`, can return JSON responses from local inference, CLI inference, and Python inference. All of these methods produce the same JSON response format. YOLO detection models, such as `yolov8n.pt`, can return JSON responses from local inference, cURL inference, and Python inference. All of these methods produce the same JSON response format.
!!! Example "Detect Model JSON Response" !!! Example "Detect Model JSON Response"
=== "Local" === "`ultralytics`"
```python ```python
from ultralytics import YOLO from ultralytics import YOLO
@ -122,7 +122,7 @@ YOLO detection models, such as `yolov8n.pt`, can return JSON responses from loca
print(results[0].tojson()) print(results[0].tojson())
``` ```
=== "CLI" === "cURL"
```bash ```bash
curl -X POST "https://api.ultralytics.com/v1/predict/MODEL_ID" \ curl -X POST "https://api.ultralytics.com/v1/predict/MODEL_ID" \
@ -201,11 +201,11 @@ YOLO detection models, such as `yolov8n.pt`, can return JSON responses from loca
### Segment Model Format ### Segment Model Format
YOLO segmentation models, such as `yolov8n-seg.pt`, can return JSON responses from local inference, CLI inference, and Python inference. All of these methods produce the same JSON response format. YOLO segmentation models, such as `yolov8n-seg.pt`, can return JSON responses from local inference, cURL inference, and Python inference. All of these methods produce the same JSON response format.
!!! Example "Segment Model JSON Response" !!! Example "Segment Model JSON Response"
=== "Local" === "`ultralytics`"
```python ```python
from ultralytics import YOLO from ultralytics import YOLO
@ -220,7 +220,7 @@ YOLO segmentation models, such as `yolov8n-seg.pt`, can return JSON responses fr
print(results[0].tojson()) print(results[0].tojson())
``` ```
=== "CLI" === "cURL"
```bash ```bash
curl -X POST "https://api.ultralytics.com/v1/predict/MODEL_ID" \ curl -X POST "https://api.ultralytics.com/v1/predict/MODEL_ID" \
@ -342,11 +342,11 @@ YOLO segmentation models, such as `yolov8n-seg.pt`, can return JSON responses fr
### Pose Model Format ### Pose Model Format
YOLO pose models, such as `yolov8n-pose.pt`, can return JSON responses from local inference, CLI inference, and Python inference. All of these methods produce the same JSON response format. YOLO pose models, such as `yolov8n-pose.pt`, can return JSON responses from local inference, cURL inference, and Python inference. All of these methods produce the same JSON response format.
!!! Example "Pose Model JSON Response" !!! Example "Pose Model JSON Response"
=== "Local" === "`ultralytics`"
```python ```python
from ultralytics import YOLO from ultralytics import YOLO
@ -361,7 +361,7 @@ YOLO pose models, such as `yolov8n-pose.pt`, can return JSON responses from loca
print(results[0].tojson()) print(results[0].tojson())
``` ```
=== "CLI" === "cURL"
```bash ```bash
curl -X POST "https://api.ultralytics.com/v1/predict/MODEL_ID" \ curl -X POST "https://api.ultralytics.com/v1/predict/MODEL_ID" \

View File

@ -18,6 +18,19 @@ The output of an oriented object detector is a set of rotated bounding boxes tha
YOLOv8 OBB models use the `-obb` suffix, i.e. `yolov8n-obb.pt` and are pretrained on [DOTAv1](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/DOTAv1.yaml). YOLOv8 OBB models use the `-obb` suffix, i.e. `yolov8n-obb.pt` and are pretrained on [DOTAv1](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/DOTAv1.yaml).
<p align="center">
<br>
<iframe width="720" height="405" src="https://www.youtube.com/embed/Z7Z9pHF8wJc"
title="YouTube video player" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen>
</iframe>
<br>
<strong>Watch:</strong> Object Detection using Ultralytics YOLOv8 Oriented Bounding Boxes (YOLOv8-OBB)
</p>
## Visual Samples
| Ships Detection using OBB | Vehicle Detection using OBB | | Ships Detection using OBB | Vehicle Detection using OBB |
|:-------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------:| |:-------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------:|
| ![Ships Detection using OBB](https://github.com/RizwanMunawar/ultralytics/assets/62513924/5051d324-416f-4b58-ab62-f1bf9d7134b0) | ![Vehicle Detection using OBB](https://github.com/RizwanMunawar/ultralytics/assets/62513924/9a366262-910a-403b-a5e2-9c68b75700d3) | | ![Ships Detection using OBB](https://github.com/RizwanMunawar/ultralytics/assets/62513924/5051d324-416f-4b58-ab62-f1bf9d7134b0) | ![Vehicle Detection using OBB](https://github.com/RizwanMunawar/ultralytics/assets/62513924/9a366262-910a-403b-a5e2-9c68b75700d3) |

View File

@ -533,7 +533,7 @@ plugins:
add_desc: False add_desc: False
add_image: True add_image: True
add_share_buttons: True add_share_buttons: True
default_image: https://github.com/ultralytics/ultralytics/assets/26833433/6d09221c-c52a-4234-9a5d-b862e93c6529 default_image: https://github.com/ultralytics/assets/blob/main/yolov8/banner-yolov8.png
- mkdocs-jupyter - mkdocs-jupyter
- redirects: - redirects:
redirect_maps: redirect_maps:

View File

@ -93,7 +93,7 @@ dev = [
"mkdocstrings[python]", "mkdocstrings[python]",
"mkdocs-jupyter", # for notebooks "mkdocs-jupyter", # for notebooks
"mkdocs-redirects", # for 301 redirects "mkdocs-redirects", # for 301 redirects
"mkdocs-ultralytics-plugin>=0.0.38", # for meta descriptions and images, dates and authors "mkdocs-ultralytics-plugin>=0.0.40", # for meta descriptions and images, dates and authors
] ]
export = [ export = [
"onnx>=1.12.0", # ONNX export "onnx>=1.12.0", # ONNX export