Spaces:
Running
Running
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() | |