Spaces:
Sleeping
Sleeping
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 app: | |
gr.Markdown("# 翻转文本或图像") | |
with gr.Tabs(): | |
with gr.TabItem("翻转文本"): | |
text_input = gr.Textbox(label="输入") | |
text_output = gr.Textbox(label="结果") | |
text_button = gr.Button("翻转") | |
with gr.TabItem("翻转图像"): | |
with gr.Row(): | |
image_input = gr.Image(label="输入") | |
image_output = gr.Image(label="结果") | |
image_button = gr.Button("翻转") | |
text_button.click(flip_text, inputs=text_input, outputs=text_output) | |
image_button.click(flip_image, inputs=image_input, outputs=image_output) | |
app.launch() | |