Remove csv import

multisource-docs-fix
Lakshantha Dissanayake 5 months ago
parent dbb41eec14
commit 5d45ee1b05
  1. 11
      ultralytics/data/loaders.py

@ -1,6 +1,5 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license # Ultralytics YOLO 🚀, AGPL-3.0 license
import csv
import glob import glob
import math import math
import os import os
@ -275,15 +274,11 @@ class LoadImagesAndVideos:
def __init__(self, path, batch=1, vid_stride=1): def __init__(self, path, batch=1, vid_stride=1):
"""Initialize the Dataloader and raise FileNotFoundError if file not found.""" """Initialize the Dataloader and raise FileNotFoundError if file not found."""
parent = None parent = None
if isinstance(path, str) and Path(path).suffix in [ if isinstance(path, str) and Path(path).suffix in [".txt", ".csv"]: # *.txt or *.csv file with img/vid/dir on each line
".txt",
".csv",
]: # *.txt or *.csv file with img/vid/dir on each line
parent = Path(path).parent parent = Path(path).parent
if Path(path).suffix == ".csv": if Path(path).suffix == ".csv":
with open(path) as file: with open(path, 'r') as file:
reader = csv.reader(file) path = [line.split(",")[0] for line in file.read().strip().splitlines()] # .csv file list of sources
path = [row[0] for row in reader] # .csv file list of sources
else: else:
path = Path(path).read_text().splitlines() # .txt file list of sources path = Path(path).read_text().splitlines() # .txt file list of sources
files = [] files = []

Loading…
Cancel
Save