Spaces:
Runtime error
Runtime error
kz209
commited on
Commit
·
63097e7
1
Parent(s):
fb403ed
update
Browse files
test.py
DELETED
|
@@ -1,57 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import numpy as np
|
| 3 |
-
|
| 4 |
-
def page1():
|
| 5 |
-
with gr.Group():
|
| 6 |
-
gr.Markdown("# Page 1 Content")
|
| 7 |
-
input_text = gr.Textbox(label="Enter some text")
|
| 8 |
-
output_text = gr.Textbox(label="Output")
|
| 9 |
-
button = gr.Button("Process")
|
| 10 |
-
|
| 11 |
-
def process_text(text):
|
| 12 |
-
return text.upper()
|
| 13 |
-
|
| 14 |
-
button.click(fn=process_text, inputs=input_text, outputs=output_text)
|
| 15 |
-
|
| 16 |
-
def page2():
|
| 17 |
-
with gr.Group():
|
| 18 |
-
gr.Markdown("# Page 2 Content")
|
| 19 |
-
num1 = gr.Number(label="Number 1")
|
| 20 |
-
num2 = gr.Number(label="Number 2")
|
| 21 |
-
result = gr.Number(label="Result")
|
| 22 |
-
add_btn = gr.Button("Add")
|
| 23 |
-
|
| 24 |
-
def add_numbers(a, b):
|
| 25 |
-
return a + b
|
| 26 |
-
|
| 27 |
-
add_btn.click(fn=add_numbers, inputs=[num1, num2], outputs=result)
|
| 28 |
-
|
| 29 |
-
def page3():
|
| 30 |
-
with gr.Group():
|
| 31 |
-
gr.Markdown("# Page 3 Content")
|
| 32 |
-
image_input = gr.Image()
|
| 33 |
-
image_output = gr.Image()
|
| 34 |
-
flip_btn = gr.Button("Flip Image")
|
| 35 |
-
|
| 36 |
-
def flip_image(img):
|
| 37 |
-
return np.fliplr(img) if img is not None else None
|
| 38 |
-
|
| 39 |
-
flip_btn.click(fn=flip_image, inputs=image_input, outputs=image_output)
|
| 40 |
-
|
| 41 |
-
with gr.Blocks() as demo:
|
| 42 |
-
with gr.Row():
|
| 43 |
-
with gr.Column(scale=1):
|
| 44 |
-
# Sidebar
|
| 45 |
-
gr.Markdown("### Navigation")
|
| 46 |
-
|
| 47 |
-
with gr.Column(scale=4):
|
| 48 |
-
# Main content area using Tabs
|
| 49 |
-
with gr.Tabs() as tabs:
|
| 50 |
-
with gr.TabItem("Page 1"):
|
| 51 |
-
page1()
|
| 52 |
-
with gr.TabItem("Page 2"):
|
| 53 |
-
page2()
|
| 54 |
-
with gr.TabItem("Page 3"):
|
| 55 |
-
page3()
|
| 56 |
-
|
| 57 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|