forked from ultralytics/ultralytics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New YOLOv8
Results()
class for prediction outputs (ultralytics#314)
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher <[email protected]> Co-authored-by: Laughing-q <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Laughing <[email protected]> Co-authored-by: Viet Nhat Thai <[email protected]> Co-authored-by: Paula Derrenger <[email protected]>
- Loading branch information
1 parent
0cb87f7
commit c6985da
Showing
32 changed files
with
816 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ jobs: | |
steps: | ||
- name: "CLA Assistant" | ||
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I sign the CLA') || github.event_name == 'pull_request_target' | ||
uses: contributor-assistant/[email protected].0 | ||
uses: contributor-assistant/[email protected].1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# must be repository secret token | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
Inference or prediction of a task returns a list of `Results` objects. Alternatively, in the streaming mode, it returns a generator of `Results` objects which is memory efficient. Streaming mode can be enabled by passing `stream=True` in predictor's call method. | ||
|
||
!!! example "Predict" | ||
=== "Getting a List" | ||
```python | ||
inputs = [img, img] # list of np arrays | ||
results = model(inputs) # List of Results objects | ||
for result in results: | ||
boxes = results.boxes # Boxes object for bbox outputs | ||
masks = results.masks # Masks object for segmenation masks outputs | ||
probs = results.probs # Class probabilities for classification outputs | ||
... | ||
``` | ||
=== "Getting a Generator" | ||
```python | ||
inputs = [img, img] # list of np arrays | ||
results = model(inputs, stream="True") # Generator of Results objects | ||
for result in results: | ||
boxes = results.boxes # Boxes object for bbox outputs | ||
masks = results.masks # Masks object for segmenation masks outputs | ||
probs = results.probs # Class probabilities for classification outputs | ||
... | ||
``` | ||
|
||
## Working with Results | ||
|
||
Results object consists of these component objects: | ||
|
||
- `results.boxes` : It is an object of class `Boxes`. It has properties and methods for manipulating bboxes | ||
- `results.masks` : It is an object of class `Masks`. It can be used to index masks or to get segment coordinates. | ||
- `results.prob` : It is a `Tensor` object. It contains the class probabilities/logits. | ||
|
||
Each result is composed of torch.Tensor by default, in which you can easily use following functionality: | ||
```python | ||
results = results.cuda() | ||
results = results.cpu() | ||
results = results.to("cpu") | ||
results = results.numpy() | ||
``` | ||
### Boxes | ||
`Boxes` object can be used index, manipulate and convert bboxes to different formats. The box format conversion operations are cached, which means they're only calculated once per object and those values are reused for future calls. | ||
|
||
- Indexing a `Boxes` objects returns a `Boxes` object | ||
```python | ||
boxes = results.boxes | ||
box = boxes[0] # returns one box | ||
box.xyxy | ||
``` | ||
- Properties and conversions | ||
``` | ||
results.boxes.xyxy # box with xyxy format, (N, 4) | ||
results.boxes.xywh # box with xywh format, (N, 4) | ||
results.boxes.xyxyn # box with xyxy format but normalized, (N, 4) | ||
results.boxes.xywhn # box with xywh format but normalized, (N, 4) | ||
results.boxes.conf # confidence score, (N, 1) | ||
results.boxes.cls # cls, (N, 1) | ||
``` | ||
### Masks | ||
`Masks` object can be used index, manipulate and convert masks to segments. The segment conversion operation is cached. | ||
|
||
```python | ||
results.masks.masks # masks, (N, H, W) | ||
results.masks.segments # bounding coordinates of masks, List[segment] * N | ||
``` | ||
|
||
### probs | ||
`probs` attribute of `Results` class is a `Tensor` containing class probabilities of a classification operation. | ||
```python | ||
results.probs # cls prob, (num_class, ) | ||
``` | ||
|
||
Class reference documentation for `Results` module and its components can be found [here](reference/results.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
### Results API Reference | ||
|
||
:::ultralytics.yolo.engine.results.Results | ||
|
||
### Boxes API Reference | ||
|
||
:::ultralytics.yolo.engine.results.Boxes | ||
|
||
### Masks API Reference | ||
|
||
:::ultralytics.yolo.engine.results.Masks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,30 +15,30 @@ | |
|
||
def get_version(): | ||
file = PARENT / 'ultralytics/__init__.py' | ||
return re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]', file.read_text(), re.M)[1] | ||
return re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]', file.read_text(encoding="utf-8"), re.M)[1] | ||
|
||
|
||
setup( | ||
name="ultralytics", # name of pypi package | ||
version=get_version(), # version of pypi package | ||
python_requires=">=3.7.0", | ||
python_requires=">=3.7,<=3.11", | ||
license='GPL-3.0', | ||
description='Ultralytics YOLOv8 and HUB', | ||
description='Ultralytics YOLOv8', | ||
long_description=README, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/ultralytics/ultralytics", | ||
project_urls={ | ||
'Bug Reports': 'https://github.com/ultralytics/ultralytics/issues', | ||
'Funding': 'https://ultralytics.com', | ||
'Source': 'https://github.com/ultralytics/ultralytics',}, | ||
'Source': 'https://github.com/ultralytics/ultralytics'}, | ||
author="Ultralytics", | ||
author_email='[email protected]', | ||
packages=find_packages(), # required | ||
include_package_data=True, | ||
install_requires=REQUIREMENTS, | ||
extras_require={ | ||
'dev': | ||
['check-manifest', 'pytest', 'pytest-cov', 'coverage', 'mkdocs', 'mkdocstrings[python]', 'mkdocs-material'],}, | ||
['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", | ||
|
@@ -49,5 +49,4 @@ def get_version(): | |
"Topic :: Scientific/Engineering :: Image Recognition", "Operating System :: POSIX :: Linux", | ||
"Operating System :: MacOS", "Operating System :: Microsoft :: Windows"], | ||
keywords="machine-learning, deep-learning, vision, ML, DL, AI, YOLO, YOLOv3, YOLOv5, YOLOv8, HUB, Ultralytics", | ||
entry_points={ | ||
'console_scripts': ['yolo = ultralytics.yolo.cli:cli', 'ultralytics = ultralytics.yolo.cli:cli'],}) | ||
entry_points={'console_scripts': ['yolo = ultralytics.yolo.cli:cli', 'ultralytics = ultralytics.yolo.cli:cli']}) |
Oops, something went wrong.