You can have an outer loop that checks how many pixels are set in the avatar and keeps trying to generate a new avatar with a different seed until it's not (rejection sampling). As long as the probability of the avatar being too empty is small it should be fast.
I was thinking of ways to prevent that, but without adding a bunch of ifs it kind of kills the minimalistic approach of the original code.