Skip to content

Commit

Permalink
Revert "Experiment with mosaic aug only ultralytics#17.5"
Browse files Browse the repository at this point in the history
This reverts commit c0954d2.
  • Loading branch information
manole-alexandru committed Apr 19, 2023
1 parent 13280d4 commit 79a441c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
6 changes: 2 additions & 4 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,6 @@ def train(hyp, opt, device, callbacks): # hyp is path/to/hyp.yaml or hyp dictio
ema.update_attr(model, include=['yaml', 'nc', 'hyp', 'names', 'stride', 'class_weights'])
final_epoch = (epoch + 1 == epochs) or stopper.possible_stop
if not noval or final_epoch: # Calculate mAP
'''
# Right now this does not work with Mosaic aug
results_train, maps_train, _ = validate.run(data_dict,
batch_size=batch_size // WORLD_SIZE * 2,
imgsz=imgsz,
Expand All @@ -404,7 +402,7 @@ def train(hyp, opt, device, callbacks): # hyp is path/to/hyp.yaml or hyp dictio
plots=False,
callbacks=callbacks,
compute_loss=compute_loss)
'''

results, maps, _ = validate.run(data_dict,
batch_size=batch_size // WORLD_SIZE * 2,
imgsz=imgsz,
Expand Down Expand Up @@ -552,7 +550,7 @@ def parse_opt(known=False):


def main(opt, callbacks=Callbacks()):
print('\n---------- VERSION:', '#0017.5', '----------\n')
print('\n---------- VERSION:', '#0017', '----------\n')
# Checks
if RANK in {-1, 0}:
print_args(vars(opt))
Expand Down
5 changes: 0 additions & 5 deletions utils/dataloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,14 +696,12 @@ def __getitem__(self, index):
seg, _, _ = random_perspective(seg, labels, degrees=hyp['degrees'], translate=hyp['translate'], scale=hyp['scale'],
shear=hyp['shear'], perspective=hyp['perspective'], random_parameters=random_parameters,
border_value=(0, 0, 0))
'''
if index < 50:
cv2.imwrite('runs/image' + str(index) + '.jpg', img)
cv2.imwrite('runs/mask' + str(index) + '.png', seg)
h, w = seg.shape[0], seg.shape[1]
resized = cv2.resize(seg, (w * 2, h * 2), interpolation=cv2.INTER_AREA)
cv2.imwrite('runs/maskr' + str(index) + '.png', resized)
'''

nl = len(labels) # number of labels
if nl:
Expand Down Expand Up @@ -836,8 +834,6 @@ def load_mosaic(self, index):

# Augment
img4, labels4, segments4 = copy_paste(img4, labels4, segments4, p=self.hyp['copy_paste'])
'''
Mosaic only experiment
img4, labels4, random_parameters = random_perspective(img4,
labels4,
segments4,
Expand All @@ -850,7 +846,6 @@ def load_mosaic(self, index):
seg4, _, _ = random_perspective(seg4, labels4, segments4, degrees=self.hyp['degrees'], translate=self.hyp['translate'],
scale=self.hyp['scale'], shear=self.hyp['shear'], perspective=self.hyp['perspective'],
border=self.mosaic_border, random_parameters=random_parameters)
'''

return img4, labels4, seg4

Expand Down

0 comments on commit 79a441c

Please sign in to comment.