Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -20,16 +20,28 @@ moondream.eval()
|
|
20 |
|
21 |
@spaces.GPU(duration=10)
|
22 |
def answer_questions(image_tuples, prompt_text):
|
|
|
|
|
|
|
23 |
prompts = [p.strip() for p in prompt_text.split(',')] # Splitting and cleaning prompts
|
24 |
-
print(f"split prompts:\n{prompts}\n")
|
25 |
image_embeds = [img[0] for img in image_tuples if img[0] is not None] # Extracting images from tuples, ignoring None
|
|
|
26 |
print(f"image_embeds:\n{image_embeds}\n")
|
|
|
|
|
27 |
#image_embeds = [moondream.encode_image(img) for img in images]
|
|
|
28 |
answers = moondream.batch_answer(
|
29 |
images=image_embeds,
|
30 |
prompts=prompts,
|
31 |
tokenizer=tokenizer,
|
32 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
return ["\n".join(ans) for ans in answers]
|
34 |
|
35 |
with gr.Blocks() as demo:
|
|
|
20 |
|
21 |
@spaces.GPU(duration=10)
|
22 |
def answer_questions(image_tuples, prompt_text):
|
23 |
+
print(f"prompt_text:\n{prompt_text}\n")
|
24 |
+
print(f"image_tuples:\n{image_tuples}\n")
|
25 |
+
|
26 |
prompts = [p.strip() for p in prompt_text.split(',')] # Splitting and cleaning prompts
|
|
|
27 |
image_embeds = [img[0] for img in image_tuples if img[0] is not None] # Extracting images from tuples, ignoring None
|
28 |
+
|
29 |
print(f"image_embeds:\n{image_embeds}\n")
|
30 |
+
print(f"split prompts:\n{prompts}\n")
|
31 |
+
|
32 |
#image_embeds = [moondream.encode_image(img) for img in images]
|
33 |
+
|
34 |
answers = moondream.batch_answer(
|
35 |
images=image_embeds,
|
36 |
prompts=prompts,
|
37 |
tokenizer=tokenizer,
|
38 |
)
|
39 |
+
|
40 |
+
for question, answer in zip(prompts, answers):
|
41 |
+
print(f"Q: {question}")
|
42 |
+
print(f"A: {answer}")
|
43 |
+
print()
|
44 |
+
|
45 |
return ["\n".join(ans) for ans in answers]
|
46 |
|
47 |
with gr.Blocks() as demo:
|