Skip to content

Commit

Permalink
Add avg image with labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Smfun12 committed May 26, 2022
1 parent 6c6eb2b commit 223f073
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions utils/dataloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,15 +690,16 @@ def load_mosaic(self, index):
indices = [index] + random.choices(self.indices, k=3) # 3 additional image indices
avg_indices = [index] + random.choices(self.indices, k=9)
random.shuffle(indices)

labels10 = []
for i, k in enumerate(avg_indices):
img, _, _ = self.load_image(k)
labels10.append(self.labels[k].copy())
if i == 0:
dst = img
dst = cv2.resize(dst, (640,640))
else:
img = cv2.resize(img, (640,640))
dst = cv2.addWeighted(img, 0.5, dst, 0.5, 0.0)
dst = cv2.addWeighted(img, 0.2, dst, 0.8, 0.0)

for i, index in enumerate(indices):
# Load image
Expand Down Expand Up @@ -730,6 +731,8 @@ def load_mosaic(self, index):

# Labels
labels, segments = self.labels[index].copy(), self.segments[index].copy()
if i == 3:
labels += labels10
if labels.size:
labels[:, 1:] = xywhn2xyxy(labels[:, 1:], w, h, padw, padh) # normalized xywh to pixel xyxy format
segments = [xyn2xy(x, w, h, padw, padh) for x in segments]
Expand Down

0 comments on commit 223f073

Please sign in to comment.