Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -93,19 +93,15 @@ def unified_chat(image, message, chat_history, seed, top_p, temperature, cfg_wei
|
|
93 |
if chat_history and len(chat_history) > 0:
|
94 |
# Get the last few turns of conversation for context (limit to last 3 turns)
|
95 |
recent_context = chat_history[-3:] if len(chat_history) > 3 else chat_history
|
96 |
-
context_text = " ".join([f"
|
|
|
97 |
|
98 |
# Only use context if it's not too long
|
99 |
if len(context_text) < 200: # Arbitrary length limit
|
100 |
context_prompt = f"{context_text}. {extracted_prompt}"
|
101 |
|
102 |
# Generate images
|
103 |
-
generated_images = generate_image(
|
104 |
-
prompt=context_prompt,
|
105 |
-
seed=seed,
|
106 |
-
guidance=cfg_weight,
|
107 |
-
t2i_temperature=t2i_temperature
|
108 |
-
)
|
109 |
|
110 |
# Create a response that includes the generated images
|
111 |
response = f"I've generated the following images based on: '{extracted_prompt}'"
|
@@ -247,7 +243,7 @@ def generate_image(prompt, seed=None, guidance=5, t2i_temperature=1.0, progress=
|
|
247 |
np.random.seed(seed)
|
248 |
width = 384
|
249 |
height = 384
|
250 |
-
parallel_size =
|
251 |
|
252 |
with torch.no_grad():
|
253 |
messages = [{'role': '<|User|>', 'content': prompt},
|
|
|
93 |
if chat_history and len(chat_history) > 0:
|
94 |
# Get the last few turns of conversation for context (limit to last 3 turns)
|
95 |
recent_context = chat_history[-3:] if len(chat_history) > 3 else chat_history
|
96 |
+
context_text = " ".join([f"User: {user_msg}" for user_msg, _ in recent_context])
|
97 |
+
#context_text = " ".join([f"{user}: {user_msg}" for user_msg, _ in recent_context])
|
98 |
|
99 |
# Only use context if it's not too long
|
100 |
if len(context_text) < 200: # Arbitrary length limit
|
101 |
context_prompt = f"{context_text}. {extracted_prompt}"
|
102 |
|
103 |
# Generate images
|
104 |
+
generated_images = generate_image(prompt=context_prompt, seed=seed, guidance=cfg_weight, t2i_temperature=t2i_temperature)
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
# Create a response that includes the generated images
|
107 |
response = f"I've generated the following images based on: '{extracted_prompt}'"
|
|
|
243 |
np.random.seed(seed)
|
244 |
width = 384
|
245 |
height = 384
|
246 |
+
parallel_size = 1
|
247 |
|
248 |
with torch.no_grad():
|
249 |
messages = [{'role': '<|User|>', 'content': prompt},
|