Spaces:
Sleeping
Sleeping
File size: 1,115 Bytes
992501a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import gradio as gr
from gradio_client import Client
client = Client("vikhyatk/moondream1")
result = client.predict(
"https://hips.hearstapps.com/hmg-prod/images/dog-puppy-on-garden-royalty-free-image-1586966191.jpg",
"What is this image? Describe this image to someone who is visually impaired.",
api_name="/answer_question",
)
def get_caption(image, additional_context):
question_with_context = "What is this image? Describe this image to someone who is visually impaired. " + additional_context
result = client.predict(image, question_with_context, api_name="/answer_question")
return result
with gr.Blocks() as demo:
with gr.Row():
image = gr.Image(sources=["upload", "clipboard"], type="filepath", height=300)
additional_context = gr.Textbox(interactive=True, label="Add additional context here (optional)")
with gr.Row():
response = gr.Textbox(label="Answer")
submit_btn = gr.Button("Submit", variant="primary")
submit_btn.click(get_caption, [image, additional_context], outputs=response)
if __name__ == "__main__":
demo.launch()
|