Dynamic Prompt Optimizing for Text-to-Image Generation