ultralytics 8.0.21
Windows, segments, YAML fixes (#655)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: corey-nm <109536191+corey-nm@users.noreply.github.com>
This commit is contained in:
@ -44,7 +44,8 @@ class LoadStreams:
|
||||
assert not is_colab(), '--source 0 webcam unsupported on Colab. Rerun command in a local environment.'
|
||||
assert not is_kaggle(), '--source 0 webcam unsupported on Kaggle. Rerun command in a local environment.'
|
||||
cap = cv2.VideoCapture(s)
|
||||
assert cap.isOpened(), f'{st}Failed to open {s}'
|
||||
if not cap.isOpened():
|
||||
raise ConnectionError(f'{st}Failed to open {s}')
|
||||
w = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
||||
h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
||||
fps = cap.get(cv2.CAP_PROP_FPS) # warning: may return 0 or nan
|
||||
@ -188,8 +189,9 @@ class LoadImages:
|
||||
self._new_video(videos[0]) # new video
|
||||
else:
|
||||
self.cap = None
|
||||
assert self.nf > 0, f'No images or videos found in {p}. ' \
|
||||
f'Supported formats are:\nimages: {IMG_FORMATS}\nvideos: {VID_FORMATS}'
|
||||
if self.nf == 0:
|
||||
raise FileNotFoundError(f'No images or videos found in {p}. '
|
||||
f'Supported formats are:\nimages: {IMG_FORMATS}\nvideos: {VID_FORMATS}')
|
||||
|
||||
def __iter__(self):
|
||||
self.count = 0
|
||||
@ -223,7 +225,8 @@ class LoadImages:
|
||||
# Read image
|
||||
self.count += 1
|
||||
im0 = cv2.imread(path) # BGR
|
||||
assert im0 is not None, f'Image Not Found {path}'
|
||||
if im0 is None:
|
||||
raise FileNotFoundError(f'Image Not Found {path}')
|
||||
s = f'image {self.count}/{self.nf} {path}: '
|
||||
|
||||
if self.transforms:
|
||||
|
@ -23,14 +23,13 @@ import numpy as np
|
||||
import psutil
|
||||
import torch
|
||||
import torchvision
|
||||
import yaml
|
||||
from PIL import ExifTags, Image, ImageOps
|
||||
from torch.utils.data import DataLoader, Dataset, dataloader, distributed
|
||||
from tqdm import tqdm
|
||||
|
||||
from ultralytics.yolo.data.utils import check_det_dataset, unzip_file
|
||||
from ultralytics.yolo.utils import (DATASETS_DIR, LOGGER, NUM_THREADS, TQDM_BAR_FORMAT, is_colab, is_dir_writeable,
|
||||
is_kaggle)
|
||||
is_kaggle, yaml_load)
|
||||
from ultralytics.yolo.utils.checks import check_requirements, check_yaml
|
||||
from ultralytics.yolo.utils.ops import clean_str, segments2boxes, xyn2xy, xywh2xyxy, xywhn2xyxy, xyxy2xywhn
|
||||
from ultralytics.yolo.utils.torch_utils import torch_distributed_zero_first
|
||||
@ -1056,10 +1055,9 @@ class HUBDatasetStats():
|
||||
# Initialize class
|
||||
zipped, data_dir, yaml_path = self._unzip(Path(path))
|
||||
try:
|
||||
with open(check_yaml(yaml_path), errors='ignore') as f:
|
||||
data = yaml.safe_load(f) # data dict
|
||||
if zipped:
|
||||
data['path'] = data_dir
|
||||
data = yaml_load(check_yaml(yaml_path)) # data dict
|
||||
if zipped:
|
||||
data['path'] = data_dir
|
||||
except Exception as e:
|
||||
raise Exception("error/HUB/dataset_stats/yaml_load") from e
|
||||
|
||||
|
Reference in New Issue
Block a user