masa729406 commited on
Commit
f3a531f
·
1 Parent(s): 26fbd64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -29
app.py CHANGED
@@ -1,31 +1,32 @@
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
- with gr.Blocks() as demo:
14
- gr.Markdown("Flip text or image files using this demo.")
15
- with gr.Tab("Flip Text"):
16
- text_input = gr.Textbox()
17
- text_output = gr.Textbox()
18
- text_button = gr.Button("Flip")
19
- with gr.Tab("Flip Image"):
20
- with gr.Row():
21
- image_input = gr.Image()
22
- image_output = gr.Image()
23
- image_button = gr.Button("Flip")
24
-
25
- with gr.Accordion("Open for More!"):
26
- gr.Markdown("Look at me...")
27
-
28
- text_button.click(flip_text, inputs=text_input, outputs=text_output)
29
- image_button.click(flip_image, inputs=image_input, outputs=image_output)
30
-
31
- demo.launch()
 
 
 
 
1
  import gradio as gr
2
 
3
+ def calculator(イワシの値段, operation, num2):
4
+ if operation == "add":
5
+ return イワシの値段 + num2
6
+ elif operation == "subtract":
7
+ return イワシの値段 - num2
8
+ elif operation == "multiply":
9
+ return イワシの値段 * num2
10
+ elif operation == "divide":
11
+ if num2 == 0:
12
+ raise gr.Error("Cannot divide by zero!")
13
+ return イワシの値段 / num2
14
+
15
+ demo = gr.Interface(
16
+ calculator,
17
+ [
18
+ "number",
19
+ gr.Radio(["add", "subtract", "multiply", "divide"]),
20
+ "number"
21
+ ],
22
+ "number",
23
+ examples=[
24
+ [5, "add", 3],
25
+ [4, "divide", 2],
26
+ [-4, "multiply", 2.5],
27
+ [0, "subtract", 1.2],
28
+ ],
29
+ title="イワシの値段による「サンガスタジアム by KYOCERA」の観客動員予測",
30
+ description="「サンガスタジアム by KYOCERA」で行われる京都サンガFCのJ1リーグの直近の試合の観客動員数をイワシの値段から予測する。",
31
+ )
32
+ demo.launch()