From e8676593caf52736d5c7800a4ccaea3b343c1d19 Mon Sep 17 00:00:00 2001 From: UltralyticsAssistant Date: Thu, 12 Sep 2024 18:14:13 +0000 Subject: [PATCH] Auto-format by https://ultralytics.com/actions --- ultralytics/data/loaders.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ultralytics/data/loaders.py b/ultralytics/data/loaders.py index 1d64046f2..be2b79af9 100644 --- a/ultralytics/data/loaders.py +++ b/ultralytics/data/loaders.py @@ -1,5 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license +import csv import glob import math import os @@ -14,7 +15,6 @@ import numpy as np import requests import torch from PIL import Image -import csv from ultralytics.data.utils import FORMATS_HELP_MSG, IMG_FORMATS, VID_FORMATS from ultralytics.utils import IS_COLAB, IS_KAGGLE, LOGGER, ops @@ -275,12 +275,15 @@ class LoadImagesAndVideos: def __init__(self, path, batch=1, vid_stride=1): """Initialize the Dataloader and raise FileNotFoundError if file not found.""" parent = None - if isinstance(path, str) and Path(path).suffix in [".txt", ".csv"]: # *.txt or *.csv file with img/vid/dir on each line + if isinstance(path, str) and Path(path).suffix in [ + ".txt", + ".csv", + ]: # *.txt or *.csv file with img/vid/dir on each line parent = Path(path).parent if Path(path).suffix == ".csv": - with open(path, 'r') as file: + with open(path) as file: reader = csv.reader(file) - path = [row[0] for row in reader] # .csv file list of sources + path = [row[0] for row in reader] # .csv file list of sources else: path = Path(path).read_text().splitlines() # .txt file list of sources files = []