Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updates
  • Loading branch information
glenn-jocher committed Mar 6, 2022
commit c3906c316b5473eda323f90a9c00c77dd3721a74
6 changes: 3 additions & 3 deletions utils/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def __init__(self, path, img_size=640, batch_size=16, augment=False, hyp=None, r
if cache_images:
gb = 0 # Gigabytes of cached images
self.im_hw0, self.im_hw = [None] * n, [None] * n
results = ThreadPool(NUM_THREADS).imap(self.load_image, zip(range(n), repeat(True)))
results = ThreadPool(NUM_THREADS).imap(self.load_image, range(n))
pbar = tqdm(enumerate(results), total=n)
for i, x in pbar:
if cache_images == 'disk':
Expand Down Expand Up @@ -622,7 +622,7 @@ def __getitem__(self, index):

return torch.from_numpy(img), labels_out, self.im_files[index], shapes

def load_image(self, i, resize=True):
def load_image(self, i):
# loads 1 image from dataset index 'i', returns (im, original hw, resized hw)
im, f, fn = self.ims[i], self.im_files[i], self.npy_files[i],
if im is None: # not cached in RAM
Expand All @@ -633,7 +633,7 @@ def load_image(self, i, resize=True):
assert im is not None, f'Image Not Found {f}'
h0, w0 = im.shape[:2] # orig hw
r = self.img_size / max(h0, w0) # ratio
if (r != 1) and resize: # if sizes are not equal
if r != 1: # if sizes are not equal
im = cv2.resize(im,
(int(w0 * r), int(h0 * r)),
interpolation=cv2.INTER_LINEAR if (self.augment or r > 1) else cv2.INTER_AREA)
Expand Down