Spaces:
Runtime error
Runtime error
Commit
·
b5a783b
1
Parent(s):
d61c308
added more context to the LLM from the BLIP/CLIP analys
Browse files
app.py
CHANGED
|
@@ -166,9 +166,16 @@ with gr.Blocks() as demo:
|
|
| 166 |
# analysis_output = gr.Textbox(label="AI Analysis")
|
| 167 |
advice_output = gr.Textbox(label="AI Advice")
|
| 168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
def tryon_workflow(cloth, avatar):
|
| 170 |
img = tryon_api(cloth, avatar)
|
| 171 |
analysis = analyze_fashion_image(img)
|
|
|
|
|
|
|
|
|
|
| 172 |
sys_prompt = 'You are a professional fashion stylist. Provide constructive, specific, and friendly advice about fit, colors, style, and accessories.'
|
| 173 |
user_msg = f"Analyze and advise based on: {json.dumps(analysis)}"
|
| 174 |
advice = llm_advise(sys_prompt, user_msg)
|
|
@@ -210,7 +217,11 @@ with gr.Blocks() as demo:
|
|
| 210 |
# --- Chatbot ---
|
| 211 |
def chatbot(message, history=None):
|
| 212 |
sys_prompt = 'You are a helpful, up-to-date fashion stylist assistant.'
|
| 213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
# --- Gradio UI: Tabs for all features ---
|
| 216 |
with gr.Tab("Chatbot"):
|
|
|
|
| 166 |
# analysis_output = gr.Textbox(label="AI Analysis")
|
| 167 |
advice_output = gr.Textbox(label="AI Advice")
|
| 168 |
|
| 169 |
+
|
| 170 |
+
# Store the latest analysis for chatbot context
|
| 171 |
+
latest_analysis = {"caption": "", "fashion_analysis": {}}
|
| 172 |
+
|
| 173 |
def tryon_workflow(cloth, avatar):
|
| 174 |
img = tryon_api(cloth, avatar)
|
| 175 |
analysis = analyze_fashion_image(img)
|
| 176 |
+
# Save for chatbot context
|
| 177 |
+
latest_analysis["caption"] = analysis["caption"]
|
| 178 |
+
latest_analysis["fashion_analysis"] = analysis["fashion_analysis"]
|
| 179 |
sys_prompt = 'You are a professional fashion stylist. Provide constructive, specific, and friendly advice about fit, colors, style, and accessories.'
|
| 180 |
user_msg = f"Analyze and advise based on: {json.dumps(analysis)}"
|
| 181 |
advice = llm_advise(sys_prompt, user_msg)
|
|
|
|
| 217 |
# --- Chatbot ---
|
| 218 |
def chatbot(message, history=None):
|
| 219 |
sys_prompt = 'You are a helpful, up-to-date fashion stylist assistant.'
|
| 220 |
+
# Add latest analysis as context if available
|
| 221 |
+
context = ""
|
| 222 |
+
if latest_analysis["caption"] or latest_analysis["fashion_analysis"]:
|
| 223 |
+
context = f"\n\nCurrent try-on analysis: {json.dumps(latest_analysis)}"
|
| 224 |
+
return llm_advise(sys_prompt, message + context)
|
| 225 |
|
| 226 |
# --- Gradio UI: Tabs for all features ---
|
| 227 |
with gr.Tab("Chatbot"):
|