ultralytics 8.2.25 latest TensorFlow 2.16 support (#13176)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: lakshanthad <lakshanthad@yahoo.com>
This commit is contained in:
parent
d80bd840d1
commit
dd819fc420
9 changed files with 79 additions and 49 deletions
10
.github/workflows/ci.yaml
vendored
10
.github/workflows/ci.yaml
vendored
|
|
@ -206,11 +206,16 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
# CoreML must be installed before export due to protobuf error from AutoInstall
|
# CoreML must be installed before export due to protobuf error from AutoInstall
|
||||||
python -m pip install --upgrade pip wheel
|
python -m pip install --upgrade pip wheel
|
||||||
|
slow=""
|
||||||
torch=""
|
torch=""
|
||||||
if [ "${{ matrix.torch }}" == "1.8.0" ]; then
|
if [ "${{ matrix.torch }}" == "1.8.0" ]; then
|
||||||
torch="torch==1.8.0 torchvision==0.9.0"
|
torch="torch==1.8.0 torchvision==0.9.0"
|
||||||
fi
|
fi
|
||||||
pip install -e . $torch pytest-cov "coremltools>=7.0; platform_system != 'Windows' and python_version <= '3.11'" --extra-index-url https://download.pytorch.org/whl/cpu
|
if [[ "${{ github.event_name }}" =~ ^(schedule|workflow_dispatch)$ ]]; then
|
||||||
|
slow="pycocotools mlflow ray[tune]"
|
||||||
|
fi
|
||||||
|
slow="pycocotools mlflow ray[tune]"
|
||||||
|
pip install -e ".[export]" $torch $slow pytest-cov --extra-index-url https://download.pytorch.org/whl/cpu
|
||||||
- name: Check environment
|
- name: Check environment
|
||||||
run: |
|
run: |
|
||||||
yolo checks
|
yolo checks
|
||||||
|
|
@ -220,7 +225,6 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
slow=""
|
slow=""
|
||||||
if [[ "${{ github.event_name }}" =~ ^(schedule|workflow_dispatch)$ ]]; then
|
if [[ "${{ github.event_name }}" =~ ^(schedule|workflow_dispatch)$ ]]; then
|
||||||
pip install pycocotools mlflow "ray[tune]"
|
|
||||||
slow="--slow"
|
slow="--slow"
|
||||||
fi
|
fi
|
||||||
pytest $slow --cov=ultralytics/ --cov-report xml tests/
|
pytest $slow --cov=ultralytics/ --cov-report xml tests/
|
||||||
|
|
@ -272,7 +276,7 @@ jobs:
|
||||||
- name: Install requirements
|
- name: Install requirements
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip wheel
|
python -m pip install --upgrade pip wheel
|
||||||
pip install --no-cache-dir -e ".[export]" pytest mlflow pycocotools "ray[tune]"
|
pip install -e ".[export]" pytest mlflow pycocotools "ray[tune]"
|
||||||
- name: Check environment
|
- name: Check environment
|
||||||
run: |
|
run: |
|
||||||
yolo checks
|
yolo checks
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ This guide provides a comprehensive overview of three fundamental types of data
|
||||||
|:------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------:|
|
|:------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------:|
|
||||||
|  |  |  |
|
|  |  |  |
|
||||||
|
|
||||||
### Why Graphs are Important
|
### Why Graphs are Important
|
||||||
|
|
||||||
- Line graphs are ideal for tracking changes over short and long periods and for comparing changes for multiple groups over the same period.
|
- Line graphs are ideal for tracking changes over short and long periods and for comparing changes for multiple groups over the same period.
|
||||||
- Bar plots, on the other hand, are suitable for comparing quantities across different categories and showing relationships between a category and its numerical value.
|
- Bar plots, on the other hand, are suitable for comparing quantities across different categories and showing relationships between a category and its numerical value.
|
||||||
|
|
@ -174,21 +174,21 @@ This guide provides a comprehensive overview of three fundamental types of data
|
||||||
|
|
||||||
Here's a table with the `Analytics` arguments:
|
Here's a table with the `Analytics` arguments:
|
||||||
|
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|--------------|-------------------|---------------|---------------------------------------------|
|
|--------------|-------------------|---------------|-------------------------------------|
|
||||||
| `type` | `str` | `None` | Type of data or object. |
|
| `type` | `str` | `None` | Type of data or object. |
|
||||||
| `im0_shape` | `tuple` | `None` | Shape of the initial image. |
|
| `im0_shape` | `tuple` | `None` | Shape of the initial image. |
|
||||||
| `writer` | `cv2.VideoWriter` | `None` | Object for writing video files. |
|
| `writer` | `cv2.VideoWriter` | `None` | Object for writing video files. |
|
||||||
| `title` | `str` | `ultralytics` | Title for the visualization. |
|
| `title` | `str` | `ultralytics` | Title for the visualization. |
|
||||||
| `x_label` | `str` | `x` | Label for the x-axis. |
|
| `x_label` | `str` | `x` | Label for the x-axis. |
|
||||||
| `y_label` | `str` | `y` | Label for the y-axis. |
|
| `y_label` | `str` | `y` | Label for the y-axis. |
|
||||||
| `bg_color` | `str` | `white` | Background color. |
|
| `bg_color` | `str` | `white` | Background color. |
|
||||||
| `fg_color` | `str` | `black` | Foreground color. |
|
| `fg_color` | `str` | `black` | Foreground color. |
|
||||||
| `line_color` | `str` | `yellow` | Color of the lines. |
|
| `line_color` | `str` | `yellow` | Color of the lines. |
|
||||||
| `line_width` | `int` | `2` | Width of the lines. |
|
| `line_width` | `int` | `2` | Width of the lines. |
|
||||||
| `fontsize` | `int` | `13` | Font size for text. |
|
| `fontsize` | `int` | `13` | Font size for text. |
|
||||||
| `view_img` | `bool` | `False` | Flag to display the image or video. |
|
| `view_img` | `bool` | `False` | Flag to display the image or video. |
|
||||||
| `save_img` | `bool` | `True` | Flag to save the image or video. |
|
| `save_img` | `bool` | `True` | Flag to save the image or video. |
|
||||||
|
|
||||||
### Arguments `model.track`
|
### Arguments `model.track`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ Setting measurable objectives is key to the success of a computer vision project
|
||||||
|
|
||||||
For example, if you are developing a system to estimate vehicle speeds on a highway. You could consider the following measurable objectives:
|
For example, if you are developing a system to estimate vehicle speeds on a highway. You could consider the following measurable objectives:
|
||||||
|
|
||||||
- To achieve at least 95% accuracy in speed detection within six months, using a dataset of 10,000 vehicle images.
|
- To achieve at least 95% accuracy in speed detection within six months, using a dataset of 10,000 vehicle images.
|
||||||
- The system should be able to process real-time video feeds at 30 frames per second with minimal delay.
|
- The system should be able to process real-time video feeds at 30 frames per second with minimal delay.
|
||||||
|
|
||||||
By setting specific and quantifiable goals, you can effectively track progress, identify areas for improvement, and ensure the project stays on course.
|
By setting specific and quantifiable goals, you can effectively track progress, identify areas for improvement, and ensure the project stays on course.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ Computer vision techniques like [object detection](../tasks/detect.md), [image c
|
||||||
<img width="100%" src="https://media.licdn.com/dms/image/D4D12AQGf61lmNOm3xA/article-cover_image-shrink_720_1280/0/1656513646049?e=1722470400&v=beta&t=23Rqohhxfie38U5syPeL2XepV2QZe6_HSSC-4rAAvt4" alt="Overview of computer vision techniques">
|
<img width="100%" src="https://media.licdn.com/dms/image/D4D12AQGf61lmNOm3xA/article-cover_image-shrink_720_1280/0/1656513646049?e=1722470400&v=beta&t=23Rqohhxfie38U5syPeL2XepV2QZe6_HSSC-4rAAvt4" alt="Overview of computer vision techniques">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
Working on your own computer vision projects is a great way to understand and learn more about computer vision. However, a computer vision project can consist of many steps, and it might seem confusing at first. By the end of this guide, you’ll be familiar with the steps involved in a computer vision project. We’ll walk through everything from the beginning to the end of a project, explaining why each part is important. Let’s get started and make your computer vision project a success!
|
Working on your own computer vision projects is a great way to understand and learn more about computer vision. However, a computer vision project can consist of many steps, and it might seem confusing at first. By the end of this guide, you’ll be familiar with the steps involved in a computer vision project. We’ll walk through everything from the beginning to the end of a project, explaining why each part is important. Let’s get started and make your computer vision project a success!
|
||||||
|
|
||||||
## An Overview of a Computer Vision Project
|
## An Overview of a Computer Vision Project
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,9 @@ export = [
|
||||||
"onnx>=1.12.0", # ONNX export
|
"onnx>=1.12.0", # ONNX export
|
||||||
"coremltools>=7.0; platform_system != 'Windows' and python_version <= '3.11'", # CoreML supported on macOS and Linux
|
"coremltools>=7.0; platform_system != 'Windows' and python_version <= '3.11'", # CoreML supported on macOS and Linux
|
||||||
"openvino>=2024.0.0", # OpenVINO export
|
"openvino>=2024.0.0", # OpenVINO export
|
||||||
"tensorflow<=2.13.1; python_version <= '3.11'", # TF bug https://github.com/ultralytics/ultralytics/issues/5161
|
"tensorflow>=2.0.0", # TF bug https://github.com/ultralytics/ultralytics/issues/5161
|
||||||
"tensorflowjs>=3.9.0; python_version <= '3.11'", # TF.js export, automatically installs tensorflow
|
"tensorflowjs>=3.9.0", # TF.js export, automatically installs tensorflow
|
||||||
|
"keras", # not installed auotomatically by tensorflow>=2.16
|
||||||
"flatbuffers>=23.5.26,<100; platform_machine == 'aarch64'", # update old 'flatbuffers' included inside tensorflow package
|
"flatbuffers>=23.5.26,<100; platform_machine == 'aarch64'", # update old 'flatbuffers' included inside tensorflow package
|
||||||
"numpy==1.23.5; platform_machine == 'aarch64'", # fix error: `np.bool` was a deprecated alias for the builtin `bool` when using TensorRT models on NVIDIA Jetson
|
"numpy==1.23.5; platform_machine == 'aarch64'", # fix error: `np.bool` was a deprecated alias for the builtin `bool` when using TensorRT models on NVIDIA Jetson
|
||||||
"h5py!=3.11.0; platform_machine == 'aarch64'", # fix h5py build issues due to missing aarch64 wheels in 3.11 release
|
"h5py!=3.11.0; platform_machine == 'aarch64'", # fix h5py build issues due to missing aarch64 wheels in 3.11 release
|
||||||
|
|
@ -111,7 +112,6 @@ explorer = [
|
||||||
"duckdb<=0.9.2", # SQL queries, duckdb==0.10.0 bug https://github.com/ultralytics/ultralytics/pull/8181
|
"duckdb<=0.9.2", # SQL queries, duckdb==0.10.0 bug https://github.com/ultralytics/ultralytics/pull/8181
|
||||||
"streamlit", # visualizing with GUI
|
"streamlit", # visualizing with GUI
|
||||||
]
|
]
|
||||||
# tensorflow>=2.4.1,<=2.13.1 # TF exports (-cpu, -aarch64, -macos)
|
|
||||||
# tflite-support # for TFLite model metadata
|
# tflite-support # for TFLite model metadata
|
||||||
# nvidia-pyindex # TensorRT export
|
# nvidia-pyindex # TensorRT export
|
||||||
# nvidia-tensorrt # TensorRT export
|
# nvidia-tensorrt # TensorRT export
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,31 @@ def test_export_coreml_matrix(task, dynamic, int8, half, batch):
|
||||||
shutil.rmtree(file) # cleanup
|
shutil.rmtree(file) # cleanup
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.slow
|
||||||
|
@pytest.mark.skipif(not checks.IS_PYTHON_MINIMUM_3_10, reason="TFLite export requires Python>=3.10")
|
||||||
|
@pytest.mark.skipif(not LINUX, reason="Test disabled as TF suffers from install conflicts on Windows and macOS")
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"task, dynamic, int8, half, batch",
|
||||||
|
[ # generate all combinations but exclude those where both int8 and half are True
|
||||||
|
(task, dynamic, int8, half, batch)
|
||||||
|
for task, dynamic, int8, half, batch in product(TASKS, [False], [True, False], [True, False], [1])
|
||||||
|
if not (int8 and half) # exclude cases where both int8 and half are True
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_export_tflite_matrix(task, dynamic, int8, half, batch):
|
||||||
|
"""Test YOLO exports to TFLite format."""
|
||||||
|
file = YOLO(TASK2MODEL[task]).export(
|
||||||
|
format="tflite",
|
||||||
|
imgsz=32,
|
||||||
|
dynamic=dynamic,
|
||||||
|
int8=int8,
|
||||||
|
half=half,
|
||||||
|
batch=batch,
|
||||||
|
)
|
||||||
|
YOLO(file)([SOURCE] * batch, imgsz=32) # exported model inference at batch=3
|
||||||
|
Path(file).unlink() # cleanup
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(not TORCH_1_9, reason="CoreML>=7.2 not supported with PyTorch<=1.8")
|
@pytest.mark.skipif(not TORCH_1_9, reason="CoreML>=7.2 not supported with PyTorch<=1.8")
|
||||||
@pytest.mark.skipif(WINDOWS, reason="CoreML not supported on Windows") # RuntimeError: BlobWriter not loaded
|
@pytest.mark.skipif(WINDOWS, reason="CoreML not supported on Windows") # RuntimeError: BlobWriter not loaded
|
||||||
@pytest.mark.skipif(IS_RASPBERRYPI, reason="CoreML not supported on Raspberry Pi")
|
@pytest.mark.skipif(IS_RASPBERRYPI, reason="CoreML not supported on Raspberry Pi")
|
||||||
|
|
@ -142,6 +167,7 @@ def test_export_coreml():
|
||||||
YOLO(MODEL).export(format="coreml", nms=True, imgsz=32)
|
YOLO(MODEL).export(format="coreml", nms=True, imgsz=32)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(not checks.IS_PYTHON_MINIMUM_3_10, reason="TFLite export requires Python>=3.10")
|
||||||
@pytest.mark.skipif(not LINUX, reason="Test disabled as TF suffers from install conflicts on Windows and macOS")
|
@pytest.mark.skipif(not LINUX, reason="Test disabled as TF suffers from install conflicts on Windows and macOS")
|
||||||
def test_export_tflite():
|
def test_export_tflite():
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||||
|
|
||||||
__version__ = "8.2.24"
|
__version__ = "8.2.25"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,6 @@ from ultralytics.utils import (
|
||||||
WINDOWS,
|
WINDOWS,
|
||||||
__version__,
|
__version__,
|
||||||
callbacks,
|
callbacks,
|
||||||
checks,
|
|
||||||
colorstr,
|
colorstr,
|
||||||
get_default_args,
|
get_default_args,
|
||||||
yaml_save,
|
yaml_save,
|
||||||
|
|
@ -813,15 +812,16 @@ class Exporter:
|
||||||
import tensorflow as tf # noqa
|
import tensorflow as tf # noqa
|
||||||
except ImportError:
|
except ImportError:
|
||||||
suffix = "-macos" if MACOS else "-aarch64" if ARM64 else "" if cuda else "-cpu"
|
suffix = "-macos" if MACOS else "-aarch64" if ARM64 else "" if cuda else "-cpu"
|
||||||
version = "" if ARM64 else "<=2.13.1"
|
version = ">=2.0.0"
|
||||||
check_requirements((f"tensorflow{suffix}{version}", "keras"))
|
check_requirements(f"tensorflow{suffix}{version}")
|
||||||
import tensorflow as tf # noqa
|
import tensorflow as tf # noqa
|
||||||
if ARM64:
|
if ARM64:
|
||||||
check_requirements("cmake") # 'cmake' is needed to build onnxsim on aarch64
|
check_requirements("cmake") # 'cmake' is needed to build onnxsim on aarch64
|
||||||
check_requirements(
|
check_requirements(
|
||||||
(
|
(
|
||||||
|
"keras",
|
||||||
"onnx>=1.12.0",
|
"onnx>=1.12.0",
|
||||||
"onnx2tf>=1.15.4,<=1.17.5",
|
"onnx2tf>1.17.5,<=1.22.3",
|
||||||
"sng4onnx>=1.0.1",
|
"sng4onnx>=1.0.1",
|
||||||
"onnxsim>=0.4.33",
|
"onnxsim>=0.4.33",
|
||||||
"onnx_graphsurgeon>=0.3.26",
|
"onnx_graphsurgeon>=0.3.26",
|
||||||
|
|
@ -835,7 +835,7 @@ class Exporter:
|
||||||
LOGGER.info(f"\n{prefix} starting export with tensorflow {tf.__version__}...")
|
LOGGER.info(f"\n{prefix} starting export with tensorflow {tf.__version__}...")
|
||||||
check_version(
|
check_version(
|
||||||
tf.__version__,
|
tf.__version__,
|
||||||
"<=2.13.1",
|
">=2.0.0",
|
||||||
name="tensorflow",
|
name="tensorflow",
|
||||||
verbose=True,
|
verbose=True,
|
||||||
msg="https://github.com/ultralytics/ultralytics/issues/5161",
|
msg="https://github.com/ultralytics/ultralytics/issues/5161",
|
||||||
|
|
|
||||||
|
|
@ -88,14 +88,14 @@ def benchmark(
|
||||||
emoji, filename = "❌", None # export defaults
|
emoji, filename = "❌", None # export defaults
|
||||||
try:
|
try:
|
||||||
# Checks
|
# Checks
|
||||||
if i == 5: # CoreML
|
if i == 7: # TF GraphDef
|
||||||
assert not (IS_RASPBERRYPI or IS_JETSON), "CoreML export not supported on Raspberry Pi or NVIDIA Jetson"
|
|
||||||
if i == 9: # Edge TPU
|
|
||||||
assert LINUX and not ARM64, "Edge TPU export only supported on non-aarch64 Linux"
|
|
||||||
elif i == 7: # TF GraphDef
|
|
||||||
assert model.task != "obb", "TensorFlow GraphDef not supported for OBB task"
|
assert model.task != "obb", "TensorFlow GraphDef not supported for OBB task"
|
||||||
|
elif i == 9: # Edge TPU
|
||||||
|
assert LINUX and not ARM64, "Edge TPU export only supported on non-aarch64 Linux"
|
||||||
elif i in {5, 10}: # CoreML and TF.js
|
elif i in {5, 10}: # CoreML and TF.js
|
||||||
assert MACOS or LINUX, "export only supported on macOS and Linux"
|
assert MACOS or LINUX, "CoreML and TF.js export only supported on macOS and Linux"
|
||||||
|
assert not IS_RASPBERRYPI, "CoreML and TF.js export not supported on Raspberry Pi"
|
||||||
|
assert not IS_JETSON, "CoreML and TF.js export not supported on NVIDIA Jetson"
|
||||||
if i in {3, 5}: # CoreML and OpenVINO
|
if i in {3, 5}: # CoreML and OpenVINO
|
||||||
assert not IS_PYTHON_3_12, "CoreML and OpenVINO not supported on Python 3.12"
|
assert not IS_PYTHON_3_12, "CoreML and OpenVINO not supported on Python 3.12"
|
||||||
if i in {6, 7, 8, 9, 10}: # All TF formats
|
if i in {6, 7, 8, 9, 10}: # All TF formats
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue