Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,11 +22,34 @@ cut off, low contrast, underexposed, overexposed, bad art, beginner, amateur, di
|
|
| 22 |
|
| 23 |
def enhance_prompt(prompt, style):
|
| 24 |
model = genai.GenerativeModel("gemini-2.0-flash-lite")
|
| 25 |
-
enhanced_prompt_request = f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
response = model.generate_content(enhanced_prompt_request)
|
| 28 |
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
def generate_image(stability_api_key, enhanced_prompt, style, negative_prompt):
|
| 32 |
url = "https://api.stability.ai/v2beta/stable-image/generate/sd3"
|
|
|
|
| 22 |
|
| 23 |
def enhance_prompt(prompt, style):
|
| 24 |
model = genai.GenerativeModel("gemini-2.0-flash-lite")
|
| 25 |
+
enhanced_prompt_request = f"""
|
| 26 |
+
Task: Enhance the following prompt for image generation.
|
| 27 |
+
Style: {style}
|
| 28 |
+
Original prompt: '{prompt}'
|
| 29 |
+
|
| 30 |
+
Instructions:
|
| 31 |
+
1. Expand the prompt to be more detailed and vivid.
|
| 32 |
+
2. Incorporate elements of the specified style.
|
| 33 |
+
3. Maintain the original intent of the prompt.
|
| 34 |
+
4. Provide ONLY the enhanced prompt, without any explanations or options.
|
| 35 |
+
5. Keep the enhanced prompt concise, ideally under 100 words.
|
| 36 |
+
|
| 37 |
+
Enhanced prompt:
|
| 38 |
+
"""
|
| 39 |
|
| 40 |
response = model.generate_content(enhanced_prompt_request)
|
| 41 |
|
| 42 |
+
# Extract only the enhanced prompt, removing any potential explanations or extra text
|
| 43 |
+
enhanced_prompt = response.text.strip()
|
| 44 |
+
|
| 45 |
+
# If the response starts with "Enhanced prompt:" or similar, remove it
|
| 46 |
+
prefixes_to_remove = ["Enhanced prompt:", "Here's the enhanced prompt:", "The enhanced prompt is:"]
|
| 47 |
+
for prefix in prefixes_to_remove:
|
| 48 |
+
if enhanced_prompt.lower().startswith(prefix.lower()):
|
| 49 |
+
enhanced_prompt = enhanced_prompt[len(prefix):].strip()
|
| 50 |
+
|
| 51 |
+
return enhanced_prompt
|
| 52 |
+
|
| 53 |
|
| 54 |
def generate_image(stability_api_key, enhanced_prompt, style, negative_prompt):
|
| 55 |
url = "https://api.stability.ai/v2beta/stable-image/generate/sd3"
|