Standardize license headers in Python files (#13490)
* Refactor code for speed and clarity * Auto-format by https://ultralytics.com/actions --------- Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
52 files changed
+67
-64
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""
|
"""
|
||||||
Run YOLOv5 benchmarks on all supported export formats.
|
Run YOLOv5 benchmarks on all supported export formats.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""
|
"""
|
||||||
Run YOLOv5 classification inference on images, videos, directories, globs, YouTube, webcam, streams, etc.
|
Run YOLOv5 classification inference on images, videos, directories, globs, YouTube, webcam, streams, etc.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""
|
"""
|
||||||
Train a YOLOv5 classifier model on a classification dataset.
|
Train a YOLOv5 classifier model on a classification dataset.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""
|
"""
|
||||||
Validate a trained YOLOv5 classification model on a classification dataset.
|
Validate a trained YOLOv5 classification model on a classification dataset.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""
|
"""
|
||||||
Run YOLOv5 detection inference on images, videos, directories, globs, YouTube, webcam, streams, etc.
|
Run YOLOv5 detection inference on images, videos, directories, globs, YouTube, webcam, streams, etc.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""
|
"""
|
||||||
Export a YOLOv5 PyTorch model to other formats. TensorFlow exports authored by https://github.com/zldrobit.
|
Export a YOLOv5 PyTorch model to other formats. TensorFlow exports authored by https://github.com/zldrobit.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""
|
"""
|
||||||
PyTorch Hub models https://pytorch.org/hub/ultralytics_yolov5.
|
PyTorch Hub models https://pytorch.org/hub/ultralytics_yolov5.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
+3
-4
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Common modules."""
|
"""Common modules."""
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
@@ -750,9 +750,8 @@ class DetectMultiBackend(nn.Module):
|
|||||||
scale, zero_point = output["quantization"]
|
scale, zero_point = output["quantization"]
|
||||||
x = (x.astype(np.float32) - zero_point) * scale # re-scale
|
x = (x.astype(np.float32) - zero_point) * scale # re-scale
|
||||||
y.append(x)
|
y.append(x)
|
||||||
if len(y) == 2: # segment with (det, proto) output order reversed
|
if len(y) == 2 and len(y[1].shape) != 4:
|
||||||
if len(y[1].shape) != 4:
|
y = list(reversed(y))
|
||||||
y = list(reversed(y)) # should be y = (1, 116, 8400), (1, 160, 160, 32)
|
|
||||||
y = [x if isinstance(x, np.ndarray) else x.numpy() for x in y]
|
y = [x if isinstance(x, np.ndarray) else x.numpy() for x in y]
|
||||||
y[0][..., :4] *= [w, h, w, h] # xywh normalized to pixels
|
y[0][..., :4] *= [w, h, w, h] # xywh normalized to pixels
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Experimental modules."""
|
"""Experimental modules."""
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""
|
"""
|
||||||
TensorFlow, Keras and TFLite versions of YOLOv5
|
TensorFlow, Keras and TFLite versions of YOLOv5
|
||||||
Authored by https://github.com/zldrobit in PR https://github.com/ultralytics/yolov5/pull/1127.
|
Authored by https://github.com/zldrobit in PR https://github.com/ultralytics/yolov5/pull/1127.
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""
|
"""
|
||||||
YOLO-specific modules.
|
YOLO-specific modules.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""
|
"""
|
||||||
Run YOLOv5 segmentation inference on images, videos, directories, streams, etc.
|
Run YOLOv5 segmentation inference on images, videos, directories, streams, etc.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""
|
"""
|
||||||
Train a YOLOv5 segment model on a segment dataset Models and datasets download automatically from the latest YOLOv5
|
Train a YOLOv5 segment model on a segment dataset Models and datasets download automatically from the latest YOLOv5
|
||||||
release.
|
release.
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""
|
"""
|
||||||
Validate a trained YOLOv5 segment model on a segment dataset.
|
Validate a trained YOLOv5 segment model on a segment dataset.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""
|
"""
|
||||||
Train a YOLOv5 model on a custom dataset. Models and datasets download automatically from the latest YOLOv5 release.
|
Train a YOLOv5 model on a custom dataset. Models and datasets download automatically from the latest YOLOv5 release.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""utils/initialization."""
|
"""utils/initialization."""
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Activation functions."""
|
"""Activation functions."""
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Image augmentation functions."""
|
"""Image augmentation functions."""
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""AutoAnchor utils."""
|
"""AutoAnchor utils."""
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Auto-batch utils."""
|
"""Auto-batch utils."""
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
|
|
||||||
# Resume all interrupted trainings in yolov5/ dir including DDP trainings
|
# Resume all interrupted trainings in yolov5/ dir including DDP trainings
|
||||||
# Usage: $ python utils/aws/resume.py
|
# Usage: $ python utils/aws/resume.py
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Callback utils."""
|
"""Callback utils."""
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Dataloaders and dataset utils."""
|
"""Dataloaders and dataset utils."""
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
@@ -355,9 +355,9 @@ class LoadImages:
|
|||||||
self._new_video(videos[0]) # new video
|
self._new_video(videos[0]) # new video
|
||||||
else:
|
else:
|
||||||
self.cap = None
|
self.cap = None
|
||||||
assert (
|
assert self.nf > 0, (
|
||||||
self.nf > 0
|
f"No images or videos found in {p}. Supported formats are:\nimages: {IMG_FORMATS}\nvideos: {VID_FORMATS}"
|
||||||
), f"No images or videos found in {p}. Supported formats are:\nimages: {IMG_FORMATS}\nvideos: {VID_FORMATS}"
|
)
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
"""Initializes iterator by resetting count and returns the iterator object itself."""
|
"""Initializes iterator by resetting count and returns the iterator object itself."""
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Download utils."""
|
"""Download utils."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Perform test request."""
|
"""Perform test request."""
|
||||||
|
|
||||||
import pprint
|
import pprint
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Run a Flask REST API exposing one or more YOLOv5s models."""
|
"""Run a Flask REST API exposing one or more YOLOv5s models."""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""General utils."""
|
"""General utils."""
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
@@ -495,9 +495,9 @@ def check_file(file, suffix=""):
|
|||||||
assert Path(file).exists() and Path(file).stat().st_size > 0, f"File download failed: {url}" # check
|
assert Path(file).exists() and Path(file).stat().st_size > 0, f"File download failed: {url}" # check
|
||||||
return file
|
return file
|
||||||
elif file.startswith("clearml://"): # ClearML Dataset ID
|
elif file.startswith("clearml://"): # ClearML Dataset ID
|
||||||
assert (
|
assert "clearml" in sys.modules, (
|
||||||
"clearml" in sys.modules
|
"ClearML is not installed, so cannot use ClearML dataset. Try running 'pip install clearml'."
|
||||||
), "ClearML is not installed, so cannot use ClearML dataset. Try running 'pip install clearml'."
|
)
|
||||||
return file
|
return file
|
||||||
else: # search
|
else: # search
|
||||||
files = []
|
files = []
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Logging utils."""
|
"""Logging utils."""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
## About ClearML
|
## About ClearML
|
||||||
|
|
||||||
[ClearML](https://clear.ml/) is an [open-source](https://github.com/allegroai/clearml) toolbox designed to save you time ⏱️.
|
[ClearML](https://clear.ml/) is an [open-source](https://github.com/clearml/clearml) toolbox designed to save you time ⏱️.
|
||||||
|
|
||||||
🔨 Track every YOLOv5 training run in the <b>experiment manager</b>
|
🔨 Track every YOLOv5 training run in the <b>experiment manager</b>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Main Logger class for ClearML experiment tracking."""
|
"""Main Logger class for ClearML experiment tracking."""
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
@@ -41,11 +41,9 @@ def construct_dataset(clearml_info_string):
|
|||||||
with open(yaml_filenames[0]) as f:
|
with open(yaml_filenames[0]) as f:
|
||||||
dataset_definition = yaml.safe_load(f)
|
dataset_definition = yaml.safe_load(f)
|
||||||
|
|
||||||
assert set(
|
assert set(dataset_definition.keys()).issuperset({"train", "test", "val", "nc", "names"}), (
|
||||||
dataset_definition.keys()
|
"The right keys were not found in the yaml file, make sure it at least has the following keys: ('train', 'test', 'val', 'nc', 'names')"
|
||||||
).issuperset(
|
)
|
||||||
{"train", "test", "val", "nc", "names"}
|
|
||||||
), "The right keys were not found in the yaml file, make sure it at least has the following keys: ('train', 'test', 'val', 'nc', 'names')"
|
|
||||||
|
|
||||||
data_dict = {
|
data_dict = {
|
||||||
"train": (
|
"train": (
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
|
|
||||||
from clearml import Task
|
from clearml import Task
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
import json
|
import json
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
|
|
||||||
# WARNING ⚠️ wandb is deprecated and will be removed in future release.
|
# WARNING ⚠️ wandb is deprecated and will be removed in future release.
|
||||||
# See supported integrations at https://github.com/ultralytics/yolov5#integrations
|
# See supported integrations at https://github.com/ultralytics/yolov5#integrations
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Loss functions."""
|
"""Loss functions."""
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Model validation metrics."""
|
"""Model validation metrics."""
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Plotting utils."""
|
"""Plotting utils."""
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Image augmentation functions."""
|
"""Image augmentation functions."""
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Dataloaders."""
|
"""Dataloaders."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Model validation metrics."""
|
"""Model validation metrics."""
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import math
|
import math
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""PyTorch utils."""
|
"""PyTorch utils."""
|
||||||
|
|
||||||
import math
|
import math
|
||||||
@@ -121,9 +121,9 @@ def select_device(device="", batch_size=0, newline=True):
|
|||||||
os.environ["CUDA_VISIBLE_DEVICES"] = "-1" # force torch.cuda.is_available() = False
|
os.environ["CUDA_VISIBLE_DEVICES"] = "-1" # force torch.cuda.is_available() = False
|
||||||
elif device: # non-cpu device requested
|
elif device: # non-cpu device requested
|
||||||
os.environ["CUDA_VISIBLE_DEVICES"] = device # set environment variable - must be before assert is_available()
|
os.environ["CUDA_VISIBLE_DEVICES"] = device # set environment variable - must be before assert is_available()
|
||||||
assert torch.cuda.is_available() and torch.cuda.device_count() >= len(
|
assert torch.cuda.is_available() and torch.cuda.device_count() >= len(device.replace(",", "")), (
|
||||||
device.replace(",", "")
|
f"Invalid CUDA '--device {device}' requested, use '--device cpu' or pass valid CUDA device(s)"
|
||||||
), f"Invalid CUDA '--device {device}' requested, use '--device cpu' or pass valid CUDA device(s)"
|
)
|
||||||
|
|
||||||
if not cpu and not mps and torch.cuda.is_available(): # prefer GPU if available
|
if not cpu and not mps and torch.cuda.is_available(): # prefer GPU if available
|
||||||
devices = device.split(",") if device else "0" # range(torch.cuda.device_count()) # i.e. 0,1,6,7
|
devices = device.split(",") if device else "0" # range(torch.cuda.device_count()) # i.e. 0,1,6,7
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
"""Utils to interact with the Triton Inference Server."""
|
"""Utils to interact with the Triton Inference Server."""
|
||||||
|
|
||||||
import typing
|
import typing
|
||||||
|
|||||||
Reference in new issue
Block a user