You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
prompt=f"""Analyze this paint color swatch image for "{product_name}" and provide a detailed visual description that could be used to recreate this exact color and presentation in an AI image generator like DALL-E.
224
+
225
+
Product Context: {product_description}
226
+
227
+
Your description should be approximately 2000 characters and include:
228
+
229
+
1. **Exact Color Analysis**: Describe the precise hue, saturation, and brightness. Include RGB-style descriptions (e.g., "a soft blue-gray with hints of lavender"). Note any gradients, variations, or undertones visible in the swatch.
230
+
231
+
2. **Visual Texture & Finish**: Describe the paint's apparent finish (matte, satin, eggshell, glossy). Note any visible texture, brush strokes, or surface quality.
232
+
233
+
3. **Lighting & Shadows**: Describe how light interacts with the color - any highlights, shadows, or reflective qualities visible in the swatch.
234
+
235
+
4. **Color Relationships**: Describe what colors this would complement. Note warm vs cool tones, and how it might appear in different lighting conditions (daylight, incandescent, etc.).
236
+
237
+
5. **Mood & Atmosphere**: Describe the emotional quality and atmosphere this color evokes - is it calming, energizing, sophisticated, cozy?
238
+
239
+
6. **Room Application Suggestions**: Describe how this color might look on walls, in different room types, and what design styles it suits.
240
+
241
+
7. **Technical Color Details**: If possible, estimate the color in terms that could guide image generation - dominant wavelength, approximate hex range, comparison to well-known colors.
242
+
243
+
Write in a descriptive, visual style that would help an AI image generator accurately reproduce this paint color in marketing images. Be specific and evocative."""
244
+
245
+
try:
246
+
response=awaitclient.chat.completions.create(
247
+
model=app_settings.azure_openai.gpt_model,
248
+
messages=[
249
+
{
250
+
"role": "user",
251
+
"content": [
252
+
{
253
+
"type": "text",
254
+
"text": prompt
255
+
},
256
+
{
257
+
"type": "image_url",
258
+
"image_url": {
259
+
"url": f"data:image/png;base64,{image_base64}",
260
+
"detail": "high"
261
+
}
262
+
}
263
+
]
264
+
}
265
+
],
266
+
max_completion_tokens=1000,
267
+
temperature=0.7
268
+
)
269
+
270
+
description=response.choices[0].message.content
271
+
272
+
# Ensure description is around 2000 characters (truncate if too long)
273
+
iflen(description) >2200:
274
+
# Find a good break point near 2000 chars
275
+
description=description[:2000]
276
+
last_period=description.rfind('.')
277
+
iflast_period>1500:
278
+
description=description[:last_period+1]
279
+
280
+
returndescription
281
+
282
+
exceptExceptionase:
283
+
print(f" Warning: Failed to generate image description: {e}")
0 commit comments