Stength and Practice
Strengthening the back muscles such as the rhomboids can help pull your shoulders back and straighten your posture.
Also, stretching exercises to the front of you body can loosen contracted muscle that keep you bent forward. Finally, keeping your neck and head in alignment keeps the rest of your body upright too. Most important in reversing poor posture is remembering to practice.