| 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", |
| |
| |
| ).set( |
| |
| |
| 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...") |
|
|
| |
| |
|
|
| demo.launch() |
|
|