Spaces:
Running
Running
Change how we ask the model questions
Browse filesBrings it closer to the moondream2 example space. I really wish I could test locally.
app.py
CHANGED
@@ -9,6 +9,12 @@ moondream_model = AutoModelForCausalLM.from_pretrained(
|
|
9 |
moondream_id, trust_remote_code=True, code_revision=moondream_revision
|
10 |
)
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
with gr.Blocks() as app:
|
13 |
gr.Markdown(
|
14 |
"""
|
@@ -24,8 +30,8 @@ with gr.Blocks() as app:
|
|
24 |
img = gr.Image(label="Image")
|
25 |
output = gr.TextArea(label="Output")
|
26 |
|
27 |
-
submit.click(
|
28 |
-
prompt.submit(
|
29 |
|
30 |
if __name__ == "__main__":
|
31 |
app.launch()
|
|
|
9 |
moondream_id, trust_remote_code=True, code_revision=moondream_revision
|
10 |
)
|
11 |
|
12 |
+
|
13 |
+
def answer_question(_img, _prompt):
|
14 |
+
image_embeds = moondream_model.encode_image(_img)
|
15 |
+
return moondream_model.answer_question(image_embeds, _prompt, moondream_tokenizer)
|
16 |
+
|
17 |
+
|
18 |
with gr.Blocks() as app:
|
19 |
gr.Markdown(
|
20 |
"""
|
|
|
30 |
img = gr.Image(label="Image")
|
31 |
output = gr.TextArea(label="Output")
|
32 |
|
33 |
+
submit.click(answer_question, [img, prompt], output)
|
34 |
+
prompt.submit(answer_question, [img, prompt], output)
|
35 |
|
36 |
if __name__ == "__main__":
|
37 |
app.launch()
|