Add application file
Browse files
app.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from utils import *
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
css = """
|
6 |
+
button {
|
7 |
+
background-color: #673AB7; /* 设置按钮背景为紫色 */
|
8 |
+
color: white; /* 设置按钮文字颜色为白色 */
|
9 |
+
border-radius: 8px; /* 设置按钮边角为圆角 */
|
10 |
+
padding: 10px 20px; /* 设置按钮内边距 */
|
11 |
+
border: none; /* 移除按钮边框 */
|
12 |
+
}
|
13 |
+
"""
|
14 |
+
|
15 |
+
ori_model = None
|
16 |
+
edit_model = None
|
17 |
+
|
18 |
+
with gr.Blocks(css=css) as demo:
|
19 |
+
gr.Markdown("# Model Output Editor")
|
20 |
+
gr.Markdown("This interface takes your input, shows the output of the source model, and then the edited model's output.")
|
21 |
+
with gr.Row():
|
22 |
+
with gr.Column():
|
23 |
+
with gr.Row():
|
24 |
+
prompt = gr.Textbox(label="Input Prompt",lines=4)
|
25 |
+
with gr.Row():
|
26 |
+
target_new = gr.Textbox(label="Input Target New")
|
27 |
+
with gr.Row():
|
28 |
+
button4clear = gr.Button("Clear")
|
29 |
+
button4edit = gr.Button("Edit")
|
30 |
+
with gr.Row():
|
31 |
+
input_text = gr.Label(label="Status Information",value="The editing process may take up to 30 seconds. Please be patient.")
|
32 |
+
with gr.Column():
|
33 |
+
with gr.Row():
|
34 |
+
input = gr.Textbox(label="Input Text")
|
35 |
+
with gr.Row():
|
36 |
+
button4gen = gr.Button("Generate")
|
37 |
+
with gr.Row():
|
38 |
+
button4gen_ori=gr.Label(label="origin output")
|
39 |
+
with gr.Row():
|
40 |
+
button4gen_edit=gr.Label(label="edited output")
|
41 |
+
|
42 |
+
button4clear.click(lambda: ("", ""), outputs=[prompt,target_new])
|
43 |
+
button4edit.click(fn=edit, inputs=[prompt,target_new], outputs=input_text)
|
44 |
+
button4gen.click(fn=generate, inputs=input, outputs=[button4gen_ori,button4gen_edit])
|
45 |
+
|
46 |
+
|
47 |
+
demo.launch()
|