Update app.py
Browse files
app.py
CHANGED
|
@@ -1,37 +1,43 @@
|
|
| 1 |
import numpy as np
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
|
| 5 |
def flip_text(x):
|
| 6 |
return x[::-1]
|
| 7 |
|
| 8 |
-
|
| 9 |
def flip_image(x):
|
| 10 |
return np.fliplr(x)
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
gr.Title("TSAI-ERAV1 Capstone - Multimodal GPT")
|
| 15 |
-
gr.Markdown("Choose text mode/image mode/audio mode for generation")
|
| 16 |
-
with gr.Tab("Text mode"):
|
| 17 |
-
text_input = gr.Textbox(placeholder="Enter a prompt", label="Input")
|
| 18 |
-
text_input_count = gr.Textbox(placeholder="Enter number of characters you want to generate", label="Count")
|
| 19 |
-
text_button = gr.Button("Generate Text")
|
| 20 |
-
text_output = gr.Textbox(label="Chat GPT like text")
|
| 21 |
-
with gr.Tab("Image mode"):
|
| 22 |
-
with gr.Row():
|
| 23 |
-
image_input = gr.Image()
|
| 24 |
-
image_text_input = gr.Textbox(placeholder="Enter a question/prompt around the image", label="Question/Prompt")
|
| 25 |
-
image_button = gr.Button("Generate Text")
|
| 26 |
-
image_text_output = gr.Textbox(label="Answer")
|
| 27 |
-
|
| 28 |
-
with gr.Tab("Audio mode"):
|
| 29 |
-
audio_text_input = gr.Textbox()
|
| 30 |
-
audio_text_output = gr.Textbox()
|
| 31 |
-
audio_button = gr.Button("Generate Text")
|
| 32 |
-
|
| 33 |
-
text_button.click(flip_text, inputs=text_input, outputs=text_output)
|
| 34 |
-
image_button.click(flip_text, inputs=image_input, outputs=image_text_output)
|
| 35 |
-
audio_button.click(flip_text, inputs=audio_text_input, outputs=audio_text_output)
|
| 36 |
-
|
| 37 |
-
demo.launch()
|
|
|
|
| 1 |
import numpy as np
|
| 2 |
import gradio as gr
|
| 3 |
|
|
|
|
| 4 |
def flip_text(x):
|
| 5 |
return x[::-1]
|
| 6 |
|
|
|
|
| 7 |
def flip_image(x):
|
| 8 |
return np.fliplr(x)
|
| 9 |
|
| 10 |
+
interface_title = "TSAI-ERAV1 Capstone - Multimodal GPT"
|
| 11 |
+
|
| 12 |
+
with gr.Interface(
|
| 13 |
+
fn=None,
|
| 14 |
+
live=True,
|
| 15 |
+
title=interface_title,
|
| 16 |
+
layout="vertical",
|
| 17 |
+
description="Choose text mode/image mode/audio mode for generation",
|
| 18 |
+
) as demo:
|
| 19 |
+
|
| 20 |
+
with demo.Tab("Text mode"):
|
| 21 |
+
text_input = demo.Textbox(placeholder="Enter a prompt", label="Input")
|
| 22 |
+
text_input_count = demo.Textbox(placeholder="Enter number of characters you want to generate", label="Count")
|
| 23 |
+
text_button = demo.Button("Generate Text")
|
| 24 |
+
text_output = demo.Textbox(label="Chat GPT like text")
|
| 25 |
+
|
| 26 |
+
text_button.click(flip_text, inputs=text_input, outputs=text_output)
|
| 27 |
+
|
| 28 |
+
with demo.Tab("Image mode"):
|
| 29 |
+
image_input = demo.Image()
|
| 30 |
+
image_text_input = demo.Textbox(placeholder="Enter a question/prompt around the image", label="Question/Prompt")
|
| 31 |
+
image_button = demo.Button("Generate Text")
|
| 32 |
+
image_text_output = demo.Textbox(label="Answer")
|
| 33 |
+
|
| 34 |
+
image_button.click(flip_text, inputs=image_text_input, outputs=image_text_output)
|
| 35 |
+
|
| 36 |
+
with demo.Tab("Audio mode"):
|
| 37 |
+
audio_text_input = demo.Textbox()
|
| 38 |
+
audio_text_output = demo.Textbox()
|
| 39 |
+
audio_button = demo.Button("Generate Text")
|
| 40 |
+
|
| 41 |
+
audio_button.click(flip_text, inputs=audio_text_input, outputs=audio_text_output)
|
| 42 |
|
| 43 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|