Someone has to manually label the ground truth. That might occur by using some kind of program to do the "obvious" parts of it, followed by a human touching it up.
Ground truth labeling is, by definition, only applied to labeling that is absolutely completely correct in every location, known to be correct because of some external information. For example, a picture of a boundary might have been labeled after electron microscope examination of the surface in order to determine atom by atom where one substance stopped and another started. For a picture of a forest, you might have had a team of scientists go tree by tree extracting DNA samples and then having specialists in each genus determining exactly which species (or varietal) occurred.
If there is any chance of error in a groundtruth labeling then the labeling is not groundtruth -- but it might be Gold Standard (determined by an experienced expert) instead. Groundtruth is "we know for certain that this is right".