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