Csplk commited on
Commit
680cfd1
β€’
1 Parent(s): f2ab852

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -36,11 +36,11 @@ def answer_questions(image_tuples, prompt_text):
36
  answers.append(image_answers)
37
 
38
  for i, prompt in enumerate(prompts):
39
- Q_and_A += f"###Q: {prompt}\n"
40
  for j, image_tuple in enumerate(image_tuples):
41
  image_name = f"image{j+1}"
42
  answer_text = answers[i][j] # Retrieve the answer for the i-th prompt for the j-th image
43
- Q_and_A += f"**{image_name} A:**\n{answer_text}\n\n"
44
 
45
  result = {'headers': prompts, 'data': answers} # Updated result handling
46
  print(f"result\n{result}\n\nQ_and_A\n{Q_and_A}\n\n")
@@ -53,13 +53,13 @@ with gr.Blocks() as demo:
53
  gr.Markdown("*Running on free CPU space tier currently so results may take a bit to process compared to duplicating space and using GPU space hardware*")
54
  gr.Markdown("## πŸŒ” moondream2\nA tiny vision language model. [GitHub](https://github.com/vikhyatk/moondream)")
55
  with gr.Row():
56
- img = gr.Gallery(label="Upload Images", type="pil")
57
  with gr.Row():
58
  prompt = gr.Textbox(label="Input Prompts", placeholder="Enter prompts (one prompt for each image provided) separated by commas. Ex: Describe this image, What is in this image?", lines=8)
59
  with gr.Row():
60
  submit = gr.Button("Submit")
61
- output = gr.Markdown(label="Questions and Answers")
62
- output2 = gr.Dataframe(label="Structured Dataframe", type="array",wrap=True)
63
  submit.click(answer_questions, [img, prompt], [output, output2])
64
 
65
  demo.queue().launch()
 
36
  answers.append(image_answers)
37
 
38
  for i, prompt in enumerate(prompts):
39
+ Q_and_A += f"### Q: {prompt}\n"
40
  for j, image_tuple in enumerate(image_tuples):
41
  image_name = f"image{j+1}"
42
  answer_text = answers[i][j] # Retrieve the answer for the i-th prompt for the j-th image
43
+ Q_and_A += f"**{image_name} A:** \n *{answer_text}* \n\n"
44
 
45
  result = {'headers': prompts, 'data': answers} # Updated result handling
46
  print(f"result\n{result}\n\nQ_and_A\n{Q_and_A}\n\n")
 
53
  gr.Markdown("*Running on free CPU space tier currently so results may take a bit to process compared to duplicating space and using GPU space hardware*")
54
  gr.Markdown("## πŸŒ” moondream2\nA tiny vision language model. [GitHub](https://github.com/vikhyatk/moondream)")
55
  with gr.Row():
56
+ img = gr.Gallery(label="Upload Images", type="pil", preview=True, object_fit="scale-down")
57
  with gr.Row():
58
  prompt = gr.Textbox(label="Input Prompts", placeholder="Enter prompts (one prompt for each image provided) separated by commas. Ex: Describe this image, What is in this image?", lines=8)
59
  with gr.Row():
60
  submit = gr.Button("Submit")
61
+ output = gr.Markdown(label="Questions and Answers", line_breaks=True)
62
+ output2 = gr.Dataframe(label="Structured Dataframe", type="array", wrap=True)
63
  submit.click(answer_questions, [img, prompt], [output, output2])
64
 
65
  demo.queue().launch()