arjunanand13 commited on
Commit
806a148
β€’
1 Parent(s): 8c1ff5e

Rename gradio_main.py to app.py

Browse files
Files changed (1) hide show
  1. gradio_main.py β†’ app.py +20 -9
gradio_main.py β†’ app.py RENAMED
@@ -60,20 +60,31 @@ def model_inference(image, text):
60
 
61
  return generated_text[0]
62
 
63
- with gr.Blocks() as demo:
 
 
 
 
 
 
 
64
  gr.Markdown("## Enhanced IDEFICS2 Demo")
65
- image_input = gr.Image(label="Upload Image", type="pil",height=480,width=640)
66
- query_input = gr.Textbox(label="Enter Prompt")
 
 
 
 
 
67
  submit_btn = gr.Button("Generate")
68
- output = gr.Textbox(label="Model Output")
69
  submit_btn.click(model_inference, inputs=[image_input, query_input], outputs=output)
70
 
71
  examples = [
72
- ["example_images/american_football.png", "Explain in detail what is depicted in the picture"],
73
- ["example_images/bike.png", "Explore the image closely and describe in detail what you discover."],
74
- ["example_images/finance.png", "Provide a detailed description of everything you see in the image."],
75
- ["example_images/science.png", "Please perform optical character recognition (OCR) on the uploaded image. Extract all text visible in the image accurately. Ensure to capture the text in its entirety and maintain the formatting as closely as possible to how it appears in the image. After extracting the text, display it in a clear and readable format, making sure that any special characters or symbols are also accurately represented. Provide the extracted text as output."],
76
- ["example_images/spirituality.png", "Please perform optical character recognition (OCR) on the uploaded image. Extract all text visible in the image accurately. Ensure to capture the text in its entirety and maintain the formatting as closely as possible to how it appears in the image. After extracting the text, display it in a clear and readable format, making sure that any special characters or symbols are also accurately represented. Provide the extracted text as output."]
77
  ]
78
  gr.Examples(examples=examples, inputs=[image_input, query_input], outputs=output)
79
 
 
60
 
61
  return generated_text[0]
62
 
63
+ # with gr.Blocks() as demo:
64
+ # gr.Markdown("## Enhanced IDEFICS2 Demo")
65
+ # image_input = gr.Image(label="Upload Image", type="pil",height=480,width=640)
66
+ # query_input = gr.Textbox(label="Enter Prompt")
67
+ # submit_btn = gr.Button("Generate")
68
+ # output = gr.Textbox(label="Model Output")
69
+
70
+ with gr.Blocks(css=".input_image {max-width: 100%; border: 1px solid #ccc; box-shadow: 0 0 10px #ccc; margin-bottom: 10px;} .output_textbox {min-height: 100px;}") as demo:
71
  gr.Markdown("## Enhanced IDEFICS2 Demo")
72
+ with gr.Row():
73
+ with gr.Column(scale=1):
74
+ image_input = gr.Image(label="Upload Image", type="pil", tool="editor", height=480, width=640)
75
+ query_input = gr.Textbox(label="Enter Prompt", placeholder="Type your prompt here...")
76
+ with gr.Column(scale=1):
77
+ output = gr.Textbox(label="Model Output", interactive=True, placeholder="Output will be displayed here...")
78
+
79
  submit_btn = gr.Button("Generate")
 
80
  submit_btn.click(model_inference, inputs=[image_input, query_input], outputs=output)
81
 
82
  examples = [
83
+ ["american_football.png", "Explain in detail what is depicted in the picture"],
84
+ ["bike.png", "Explore the image closely and describe in detail what you discover."],
85
+ ["finance.png", "Provide a detailed description of everything you see in the image."],
86
+ ["science.png", "Please perform optical character recognition (OCR) on the uploaded image. Extract all text visible in the image accurately. Ensure to capture the text in its entirety and maintain the formatting as closely as possible to how it appears in the image. After extracting the text, display it in a clear and readable format, making sure that any special characters or symbols are also accurately represented. Provide the extracted text as output."],
87
+ ["spirituality.png", "Please perform optical character recognition (OCR) on the uploaded image. Extract all text visible in the image accurately. Ensure to capture the text in its entirety and maintain the formatting as closely as possible to how it appears in the image. After extracting the text, display it in a clear and readable format, making sure that any special characters or symbols are also accurately represented. Provide the extracted text as output."]
88
  ]
89
  gr.Examples(examples=examples, inputs=[image_input, query_input], outputs=output)
90