Spaces:
Sleeping
Sleeping
Move Gradio app creation into main block
Browse files
app.py
CHANGED
|
@@ -34,22 +34,22 @@ def answer_question(_img, _prompt):
|
|
| 34 |
yield buffer.strip()
|
| 35 |
|
| 36 |
|
| 37 |
-
with gr.Blocks() as app:
|
| 38 |
-
gr.Markdown(
|
| 39 |
-
"""
|
| 40 |
-
# Food Identifier
|
| 41 |
-
|
| 42 |
-
Final project for IAT 481 at Simon Fraser University, Spring 2024.
|
| 43 |
-
"""
|
| 44 |
-
)
|
| 45 |
-
with gr.Row():
|
| 46 |
-
prompt = gr.Textbox(label="Input", value="Describe this image.")
|
| 47 |
-
submit = gr.Button("Submit")
|
| 48 |
-
with gr.Row():
|
| 49 |
-
img = gr.Image(label="Image", type="pil")
|
| 50 |
-
output = gr.TextArea(label="Output")
|
| 51 |
-
|
| 52 |
-
submit.click(answer_question, [img, prompt], output)
|
| 53 |
-
|
| 54 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
app.queue().launch()
|
|
|
|
| 34 |
yield buffer.strip()
|
| 35 |
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
if __name__ == "__main__":
|
| 38 |
+
with gr.Blocks() as app:
|
| 39 |
+
gr.Markdown(
|
| 40 |
+
"""
|
| 41 |
+
# Food Identifier
|
| 42 |
+
|
| 43 |
+
Final project for IAT 481 at Simon Fraser University, Spring 2024.
|
| 44 |
+
"""
|
| 45 |
+
)
|
| 46 |
+
with gr.Row():
|
| 47 |
+
prompt = gr.Textbox(label="Input", value="Describe this image.")
|
| 48 |
+
submit = gr.Button("Submit")
|
| 49 |
+
with gr.Row():
|
| 50 |
+
img = gr.Image(label="Image", type="pil")
|
| 51 |
+
output = gr.TextArea(label="Output")
|
| 52 |
+
|
| 53 |
+
submit.click(answer_question, [img, prompt], output)
|
| 54 |
+
|
| 55 |
app.queue().launch()
|