Update app.py
Browse files
app.py
CHANGED
|
@@ -21,14 +21,10 @@ moondream.eval()
|
|
| 21 |
@spaces.GPU
|
| 22 |
def answer_questions(image_tuples, prompt_text):
|
| 23 |
result = ""
|
| 24 |
-
|
| 25 |
prompts = [p.strip() for p in prompt_text.split(',')] # Splitting and cleaning prompts
|
| 26 |
-
print(f"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 |
-
# Check if the lengths of image_embeds and prompts are equal
|
| 30 |
-
#if len(image_embeds) != len(prompts):
|
| 31 |
-
#return ("Error: The number of images input and prompts input (seperate by commas in input text field) must be the same.")
|
| 32 |
|
| 33 |
answers = []
|
| 34 |
for prompt in prompts:
|
|
@@ -51,19 +47,7 @@ def answer_questions(image_tuples, prompt_text):
|
|
| 51 |
print(f"\n\n{Q_and_A}\n\n")
|
| 52 |
|
| 53 |
result = {'headers': prompts, 'data': data}
|
| 54 |
-
return result
|
| 55 |
-
'''
|
| 56 |
-
answers = moondream.batch_answer(
|
| 57 |
-
images=image_embeds,
|
| 58 |
-
prompts=prompts,
|
| 59 |
-
tokenizer=tokenizer,
|
| 60 |
-
)
|
| 61 |
-
|
| 62 |
-
for question, answer in zip(prompts, answers):
|
| 63 |
-
result += (f"Q: {question}\nA: {answer}\n\n")
|
| 64 |
-
|
| 65 |
-
return result
|
| 66 |
-
'''
|
| 67 |
|
| 68 |
with gr.Blocks() as demo:
|
| 69 |
gr.Markdown("# moondream2 unofficial batch processing demo")
|
|
|
|
| 21 |
@spaces.GPU
|
| 22 |
def answer_questions(image_tuples, prompt_text):
|
| 23 |
result = ""
|
| 24 |
+
Q_and_A = ""
|
| 25 |
prompts = [p.strip() for p in prompt_text.split(',')] # Splitting and cleaning prompts
|
| 26 |
+
print(f"prompts: {prompts}\n")
|
| 27 |
image_embeds = [img[0] for img in image_tuples if img[0] is not None] # Extracting images from tuples, ignoring None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
answers = []
|
| 30 |
for prompt in prompts:
|
|
|
|
| 47 |
print(f"\n\n{Q_and_A}\n\n")
|
| 48 |
|
| 49 |
result = {'headers': prompts, 'data': data}
|
| 50 |
+
return Q_and_A, result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
with gr.Blocks() as demo:
|
| 53 |
gr.Markdown("# moondream2 unofficial batch processing demo")
|