SugarAddict commited on
Commit
df182ba
ยท
1 Parent(s): ac5ec03

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +92 -0
app.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import gradio as gr
3
+ import random
4
+ import time
5
+ from updated_predict import working_func
6
+
7
+ theme = gr.themes.Soft(
8
+ primary_hue="emerald",
9
+ secondary_hue="teal",
10
+ neutral_hue="indigo",
11
+ # text_size="text_lg",
12
+ # radius_size="radius_lg",
13
+ ).set(
14
+ #body_background_fill='*checkbox_label_background_fill',
15
+ #body_background_fill='*block_title_background_fill',
16
+ body_background_fill='*background_fill_secondary',
17
+ background_fill_primary='*neutral_200',
18
+ block_background_fill='*table_even_background_fill',
19
+ button_border_width='*block_title_border_width',
20
+ button_shadow='*button_shadow_hover'
21
+ )
22
+
23
+
24
+ def flip_text(x):
25
+ return x[::-1]
26
+
27
+
28
+ def flip_image(x):
29
+ return np.fliplr(x)
30
+
31
+ def diagnosed_huxi():
32
+ return "ๅ‘ผๅธ็ง‘"
33
+
34
+ def diagnosed_shennei():
35
+ return "็ฅž็ปๅ†…็ง‘"
36
+
37
+ def diagnosed_xiaohua():
38
+ return "ๅ†…็ง‘ ๆถˆๅŒ–็ง‘/่ƒƒ่‚ ็ง‘"
39
+
40
+ def diagnosed_xinnei():
41
+ return "ๅ†…็ง‘ ๅฟƒ่„ๅ†…็ง‘"
42
+ text_output = gr.Textbox(label="็ง‘ๅฎค")
43
+
44
+ with gr.Blocks(theme=theme) as demo:
45
+ gr.Markdown("ๅŒป็–—ๅˆ†่ฏŠๅŠฉๆ‰‹")
46
+ gr.Image("bar.png")
47
+ with gr.Tab("ๅธธ่ง็–‘้—ฎ"):
48
+ with gr.Row():
49
+ btn1 = gr.Button(value="็™ซ็—ซ")
50
+ btn1.click(diagnosed_shennei, inputs=[], outputs=[text_output])
51
+
52
+ btn2 = gr.Button(value="ๅ’ณๅ—ฝ")
53
+ btn2.click(diagnosed_huxi, inputs=[], outputs=[text_output])
54
+
55
+ btn3 = gr.Button(value="ๆ„Ÿๅ†’")
56
+ btn3.click(diagnosed_huxi, inputs=[], outputs=[text_output])
57
+
58
+
59
+ with gr.Row():
60
+ btn4 = gr.Button(value="้ซ˜่ก€ๅŽ‹")
61
+ btn4.click(diagnosed_xinnei, inputs=[], outputs=[text_output])
62
+
63
+ btn5 = gr.Button(value="ๅ‘็ƒง")
64
+ btn5.click(diagnosed_huxi, inputs=[], outputs=[text_output])
65
+
66
+ btn6 = gr.Button(value="่ƒƒ็‚Ž")
67
+ btn6.click(diagnosed_xiaohua, inputs=[], outputs=[text_output])
68
+
69
+ with gr.Row():
70
+ text_output.render()
71
+
72
+ with gr.Tab("ๆ‰‹ๅŠจ้”ฎๅ…ฅ"):
73
+ chatbot = gr.Chatbot()
74
+ msg = gr.Textbox()
75
+ clear = gr.ClearButton([msg, chatbot])
76
+ def respond(message, chat_history):
77
+ result = working_func(message)
78
+ bot_message = "็ง‘ๅฎค๏ผš" + result[0] + ',' + result[1] + '\n' + "ๅ›ž็ญ”๏ผš" + result[2]
79
+ chat_history.append((message, bot_message))
80
+ time.sleep(2)
81
+ return "", chat_history
82
+
83
+
84
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
85
+
86
+ with gr.Accordion("Open for More!"):
87
+ gr.Markdown("Look at me...")
88
+
89
+ #text_button.click(flip_text, inputs=text_input, outputs=text_output)
90
+ #image_button.click(flip_image, inputs=image_input, outputs=image_output)
91
+
92
+ demo.launch()