Spaces:
Running
Running
update prompt
Browse files
app.py
CHANGED
|
@@ -378,21 +378,26 @@ def detect_objects(image, dino_proc, dino_mod, threshold=0.3) -> tuple:
|
|
| 378 |
return "Object detection unavailable", []
|
| 379 |
|
| 380 |
# ============================================================================
|
| 381 |
-
# fuse_captions —
|
| 382 |
-
#
|
| 383 |
-
#
|
| 384 |
-
# max_new_tokens
|
|
|
|
| 385 |
# ============================================================================
|
| 386 |
def fuse_captions(cap1: str, cap2: str, objects: str, qwen_tok, qwen_mod) -> str:
|
| 387 |
|
| 388 |
system_prompt = (
|
| 389 |
"You write image captions. "
|
| 390 |
-
"
|
| 391 |
-
"
|
| 392 |
-
"
|
| 393 |
-
"
|
| 394 |
-
"
|
| 395 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 396 |
"Return ONLY the caption, nothing else."
|
| 397 |
)
|
| 398 |
|
|
@@ -400,7 +405,8 @@ def fuse_captions(cap1: str, cap2: str, objects: str, qwen_tok, qwen_mod) -> str
|
|
| 400 |
f"Caption A: {cap1}\n"
|
| 401 |
f"Caption B: {cap2}\n"
|
| 402 |
f"{objects}\n\n"
|
| 403 |
-
"Write a
|
|
|
|
| 404 |
)
|
| 405 |
|
| 406 |
try:
|
|
@@ -418,8 +424,8 @@ def fuse_captions(cap1: str, cap2: str, objects: str, qwen_tok, qwen_mod) -> str
|
|
| 418 |
with torch.no_grad():
|
| 419 |
generated_ids = qwen_mod.generate(
|
| 420 |
**model_inputs,
|
| 421 |
-
max_new_tokens=
|
| 422 |
-
temperature=0.
|
| 423 |
do_sample=True,
|
| 424 |
top_p=0.9
|
| 425 |
)
|
|
|
|
| 378 |
return "Object detection unavailable", []
|
| 379 |
|
| 380 |
# ============================================================================
|
| 381 |
+
# fuse_captions — CHANGED
|
| 382 |
+
# system_prompt: explicitly covers clothing, colors, people, objects, setting
|
| 383 |
+
# user_prompt: asks for all specific details including clothing and background
|
| 384 |
+
# max_new_tokens: 100 → 180 (room for 3-4 full sentences)
|
| 385 |
+
# temperature: 0.2 → 0.4 (more expressive while staying factual)
|
| 386 |
# ============================================================================
|
| 387 |
def fuse_captions(cap1: str, cap2: str, objects: str, qwen_tok, qwen_mod) -> str:
|
| 388 |
|
| 389 |
system_prompt = (
|
| 390 |
"You write image captions. "
|
| 391 |
+
"You will receive two captions and a list of detected objects. "
|
| 392 |
+
"Your job is to combine them into one detailed caption. "
|
| 393 |
+
"Include ALL specific details you find: "
|
| 394 |
+
"the clothing colors and style of each person, "
|
| 395 |
+
"what each person looks like and what they are doing, "
|
| 396 |
+
"the objects and plants visible around them, "
|
| 397 |
+
"and the setting or background of the scene. "
|
| 398 |
+
"Write 3 to 4 sentences. Use simple, clear, everyday words. "
|
| 399 |
+
"Do NOT summarize or shorten — keep every specific detail. "
|
| 400 |
+
"Only include what is clearly visible. "
|
| 401 |
"Return ONLY the caption, nothing else."
|
| 402 |
)
|
| 403 |
|
|
|
|
| 405 |
f"Caption A: {cap1}\n"
|
| 406 |
f"Caption B: {cap2}\n"
|
| 407 |
f"{objects}\n\n"
|
| 408 |
+
"Write a detailed caption that includes all the clothing, "
|
| 409 |
+
"people, objects and background details:"
|
| 410 |
)
|
| 411 |
|
| 412 |
try:
|
|
|
|
| 424 |
with torch.no_grad():
|
| 425 |
generated_ids = qwen_mod.generate(
|
| 426 |
**model_inputs,
|
| 427 |
+
max_new_tokens=180,
|
| 428 |
+
temperature=0.4,
|
| 429 |
do_sample=True,
|
| 430 |
top_p=0.9
|
| 431 |
)
|