RealGen: Photorealistic Text-to-Image Generation via Detector-Guided Rewards