mirror of
https://github.com/THU-MIG/yolov10.git
synced 2025-05-23 21:44:22 +08:00
Add torch.Tensor
checks and pip badges (#3368)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
682c9ef70f
commit
15c027a9fc
@ -59,11 +59,13 @@ See below for a quickstart installation and usage example, and see the [YOLOv8 D
|
|||||||
|
|
||||||
Pip install the ultralytics package including all [requirements](https://github.com/ultralytics/ultralytics/blob/main/requirements.txt) in a [**Python>=3.8**](https://www.python.org/) environment with [**PyTorch>=1.7**](https://pytorch.org/get-started/locally/).
|
Pip install the ultralytics package including all [requirements](https://github.com/ultralytics/ultralytics/blob/main/requirements.txt) in a [**Python>=3.8**](https://www.python.org/) environment with [**PyTorch>=1.7**](https://pytorch.org/get-started/locally/).
|
||||||
|
|
||||||
|
[](https://badge.fury.io/py/ultralytics) [](https://pepy.tech/project/ultralytics)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install ultralytics
|
pip install ultralytics
|
||||||
```
|
```
|
||||||
|
|
||||||
For alternative installation methods including Conda, Docker, and Git, please refer to the [Ultralytics Quickstart Guide](https://docs.ultralytics.com/quickstart).
|
For alternative installation methods including Conda, Docker, and Git, please refer to the [Quickstart Guide](https://docs.ultralytics.com/quickstart).
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
@ -59,11 +59,13 @@
|
|||||||
|
|
||||||
使用Pip在一个[**Python>=3.8**](https://www.python.org/)环境中安装`ultralytics`包,此环境还需包含[**PyTorch>=1.7**](https://pytorch.org/get-started/locally/)。这也会安装所有必要的[依赖项](https://github.com/ultralytics/ultralytics/blob/main/requirements.txt)。
|
使用Pip在一个[**Python>=3.8**](https://www.python.org/)环境中安装`ultralytics`包,此环境还需包含[**PyTorch>=1.7**](https://pytorch.org/get-started/locally/)。这也会安装所有必要的[依赖项](https://github.com/ultralytics/ultralytics/blob/main/requirements.txt)。
|
||||||
|
|
||||||
|
[](https://badge.fury.io/py/ultralytics) [](https://pepy.tech/project/ultralytics)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install ultralytics
|
pip install ultralytics
|
||||||
```
|
```
|
||||||
|
|
||||||
如需使用包括Conda、Docker和Git在内的其他安装方法,请参考[Ultralytics快速入门指南](https://docs.ultralytics.com/quickstart)。
|
如需使用包括Conda、Docker和Git在内的其他安装方法,请参考[快速入门指南](https://docs.ultralytics.com/quickstart)。
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
@ -12,6 +12,9 @@ Ultralytics provides various installation methods including pip, conda, and Dock
|
|||||||
|
|
||||||
=== "Pip install (recommended)"
|
=== "Pip install (recommended)"
|
||||||
Install the `ultralytics` package using pip, or update an existing installation by running `pip install -U ultralytics`. Visit the Python Package Index (PyPI) for more details on the `ultralytics` package: [https://pypi.org/project/ultralytics/](https://pypi.org/project/ultralytics/).
|
Install the `ultralytics` package using pip, or update an existing installation by running `pip install -U ultralytics`. Visit the Python Package Index (PyPI) for more details on the `ultralytics` package: [https://pypi.org/project/ultralytics/](https://pypi.org/project/ultralytics/).
|
||||||
|
|
||||||
|
[](https://badge.fury.io/py/ultralytics) [](https://pepy.tech/project/ultralytics)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Install the ultralytics package using pip
|
# Install the ultralytics package using pip
|
||||||
pip install ultralytics
|
pip install ultralytics
|
||||||
@ -19,6 +22,10 @@ Ultralytics provides various installation methods including pip, conda, and Dock
|
|||||||
|
|
||||||
=== "Conda install"
|
=== "Conda install"
|
||||||
Conda is an alternative package manager to pip which may also be used for installation. Visit Anaconda for more details at [https://anaconda.org/conda-forge/ultralytics](https://anaconda.org/conda-forge/ultralytics). Ultralytics feedstock repository for updating the conda package is at [https://github.com/conda-forge/ultralytics-feedstock/](https://github.com/conda-forge/ultralytics-feedstock/).
|
Conda is an alternative package manager to pip which may also be used for installation. Visit Anaconda for more details at [https://anaconda.org/conda-forge/ultralytics](https://anaconda.org/conda-forge/ultralytics). Ultralytics feedstock repository for updating the conda package is at [https://github.com/conda-forge/ultralytics-feedstock/](https://github.com/conda-forge/ultralytics-feedstock/).
|
||||||
|
|
||||||
|
|
||||||
|
[](https://anaconda.org/conda-forge/ultralytics) [](https://anaconda.org/conda-forge/ultralytics) [](https://anaconda.org/conda-forge/ultralytics) [](https://anaconda.org/conda-forge/ultralytics)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Install the ultralytics package using conda
|
# Install the ultralytics package using conda
|
||||||
conda install ultralytics
|
conda install ultralytics
|
||||||
@ -39,6 +46,8 @@ Ultralytics provides various installation methods including pip, conda, and Dock
|
|||||||
|
|
||||||
=== "Docker"
|
=== "Docker"
|
||||||
Utilize Docker to execute the `ultralytics` package in an isolated container. By employing the official `ultralytics` image from [Docker Hub](https://hub.docker.com/r/ultralytics/ultralytics), you can avoid local installation. Below are the commands to get the latest image and execute it:
|
Utilize Docker to execute the `ultralytics` package in an isolated container. By employing the official `ultralytics` image from [Docker Hub](https://hub.docker.com/r/ultralytics/ultralytics), you can avoid local installation. Below are the commands to get the latest image and execute it:
|
||||||
|
|
||||||
|
<a href="https://hub.docker.com/r/ultralytics/ultralytics"><img src="https://img.shields.io/docker/pulls/ultralytics/ultralytics?logo=docker" alt="Docker Pulls"></a>
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Set image name as a variable
|
# Set image name as a variable
|
||||||
|
@ -301,11 +301,23 @@ class LoadTensor:
|
|||||||
self.paths = [getattr(im, 'filename', f'image{i}.jpg') for i, im in enumerate(im0)]
|
self.paths = [getattr(im, 'filename', f'image{i}.jpg') for i, im in enumerate(im0)]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _single_check(im):
|
def _single_check(im, stride=32):
|
||||||
"""Validate and format an image to numpy array."""
|
"""Validate and format an image to torch.Tensor."""
|
||||||
if len(im.shape) < 4:
|
s = f'WARNING ⚠️ torch.Tensor inputs should be BCHW i.e. shape(1, 3, 640, 640) ' \
|
||||||
LOGGER.warning('WARNING ⚠️ torch.Tensor inputs should be BCHW format, i.e. shape(1,3,640,640).')
|
f'divisible by stride {stride}. Input shape{tuple(im.shape)} is incompatible.'
|
||||||
im = im.unsqueeze(0)
|
if len(im.shape) != 4:
|
||||||
|
if len(im.shape) == 3:
|
||||||
|
LOGGER.warning(s)
|
||||||
|
im = im.unsqueeze(0)
|
||||||
|
else:
|
||||||
|
raise ValueError(s)
|
||||||
|
if im.shape[2] % stride or im.shape[3] % stride:
|
||||||
|
raise ValueError(s)
|
||||||
|
if im.max() > 1.0:
|
||||||
|
LOGGER.warning(f'WARNING ⚠️ torch.Tensor inputs should be normalized 0.0-1.0 but max value is {im.max()}. '
|
||||||
|
f'Dividing input by 255.')
|
||||||
|
im = im.float() / 255.0
|
||||||
|
|
||||||
return im
|
return im
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user