The only absolute way is to wait until they spawn. Females have a thicker, stubbier breeding tube, males are thinner and pointier.
Some people say they can tell by body shape, or the way they carry their fins. This is only guessing, never seen anybody who can get much more than 50% accurate with this.