It is difficult to tell the difference just by looking. Both have similar body shapes, fur types, and color patterns.
General guidelines: Males tend to be larger and have a greater distance between the anus and genitals. Females have a small, round, raised vulva just in front of the anus. Males have a penis that may be hidden by fur.
The best way to determine sex is to have a veterinarian or experienced breeder examine them. Baby guinea pigs under 3 weeks are very difficult to sex.
Even with these tips, seek professional help for a definitive answer.