mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-06 10:25:17 +08:00
9b42ba8f10
* changes * changes * revert changes * changes * add changeset * notebooks script * changes * changes --------- Co-authored-by: Ali Abid <aliabid94@gmail.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
37 lines
972 B
Python
37 lines
972 B
Python
import numpy as np
|
|
import gradio as gr
|
|
|
|
def flip_text(x):
|
|
return x[::-1]
|
|
|
|
def flip_image(x):
|
|
return np.fliplr(x)
|
|
|
|
with gr.Blocks() as demo:
|
|
gr.Markdown("Flip text or image files using this demo.")
|
|
with gr.Tab("Flip Text"):
|
|
text_input = gr.Textbox()
|
|
text_output = gr.Textbox()
|
|
text_button = gr.Button("Flip")
|
|
with gr.Tab("Flip Image"):
|
|
with gr.Row():
|
|
image_input = gr.Image()
|
|
image_output = gr.Image()
|
|
image_button = gr.Button("Flip")
|
|
|
|
with gr.Accordion("Open for More!", open=False):
|
|
gr.Markdown("Look at me...")
|
|
temp_slider = gr.Slider(
|
|
0, 1,
|
|
value=0.1,
|
|
step=0.1,
|
|
interactive=True,
|
|
label="Slide me",
|
|
)
|
|
|
|
text_button.click(flip_text, inputs=text_input, outputs=text_output)
|
|
image_button.click(flip_image, inputs=image_input, outputs=image_output)
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch()
|