I am guessing you are trying to segment small objects? In that case, you should consider computing your dice loss on both the background and foreground as:
loss = 1 - (dice_score(mask_pred, true_masks) + dice_score(1 - mask_pred, 1 - true_masks)) / 2

You could also consider the GDL or even the Boundary Loss if you are indeed segmenting small objects.