style_conversion.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright (C) 2025 AIDC-AI
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. # See the License for the specific language governing permissions and
  11. # limitations under the License.
  12. """
  13. Style conversion prompt
  14. For converting user's custom style description to image generation prompt.
  15. """
  16. STYLE_CONVERSION_PROMPT = """Convert this style description into a detailed image generation prompt for Stable Diffusion/FLUX:
  17. Style Description: {description}
  18. Requirements:
  19. - Focus on visual elements, colors, lighting, mood, atmosphere
  20. - Be specific and detailed
  21. - Use professional photography/art terminology
  22. - Output ONLY the prompt in English (no explanations)
  23. - Keep it under 100 words
  24. - Use comma-separated descriptive phrases
  25. Image Prompt:"""
  26. def build_style_conversion_prompt(description: str) -> str:
  27. """
  28. Build style conversion prompt
  29. Converts user's custom style description (in any language) to an English
  30. image generation prompt suitable for Stable Diffusion/FLUX models.
  31. Args:
  32. description: User's style description in any language
  33. Returns:
  34. Formatted prompt
  35. Example:
  36. >>> build_style_conversion_prompt("赛博朋克风格,霓虹灯,未来感")
  37. # Returns prompt that will convert to: "cyberpunk style, neon lights, futuristic..."
  38. """
  39. return STYLE_CONVERSION_PROMPT.format(description=description)