jm12138 commited on
Commit
f2a7319
1 Parent(s): 6e553d4
Files changed (1) hide show
  1. app.py +85 -13
app.py CHANGED
@@ -18,11 +18,75 @@ def inference(task: str,
18
  except Exception as error:
19
  return str(error)
20
 
 
21
  title = "ERNIE-Zeus"
22
 
23
  description = "ERNIE-Zeus model, which supports Chinese text generates task."
24
 
25
- block = gr.Blocks()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  examples = [
28
  [
@@ -98,11 +162,12 @@ with block:
98
  """
99
  )
100
  with gr.Group():
101
- text = gr.Textbox(
102
- label="input_text",
103
- placeholder="Please enter Chinese text.",
104
- )
105
- btn = gr.Button(value="Generate text")
 
106
  task = gr.Dropdown(label="task",
107
  choices=[
108
  'text_summarization',
@@ -115,17 +180,24 @@ with block:
115
  ],
116
  value='text_summarization')
117
 
118
- min_dec_len = gr.Slider(minimum=1, maximum=511, value=1, label="min_dec_len", step=1, interactive=True)
119
- seq_len = gr.Slider(minimum=2, maximum=512, value=128, label="seq_len", step=1, interactive=True)
120
- topp = gr.Slider(minimum=0.0, maximum=1.0, value=1.0, label="topp", step=0.01, interactive=True)
121
- penalty_score = gr.Slider(minimum=1.0, maximum=2.0, value=1.0, label="penalty_score", step=0.01, interactive=True)
 
 
 
 
122
 
123
  text_gen = gr.Textbox(label="generated_text")
124
 
125
- ex = gr.Examples(examples=examples, fn=inference, inputs=[task, text, min_dec_len, seq_len, topp, penalty_score], outputs=text_gen, cache_examples=False)
 
126
 
127
- text.submit(inference, inputs=[task, text, min_dec_len, seq_len, topp, penalty_score], outputs=text_gen)
128
- btn.click(inference, inputs=[task, text, min_dec_len, seq_len, topp, penalty_score], outputs=text_gen)
 
 
129
  gr.HTML(
130
  """
131
  <div class="footer">
 
18
  except Exception as error:
19
  return str(error)
20
 
21
+
22
  title = "ERNIE-Zeus"
23
 
24
  description = "ERNIE-Zeus model, which supports Chinese text generates task."
25
 
26
+ css = """
27
+ .gradio-container {
28
+ font-family: 'IBM Plex Sans', sans-serif;
29
+ }
30
+ .gr-button {
31
+ color: white;
32
+ border-color: black;
33
+ background: black;
34
+ }
35
+ input[type='range'] {
36
+ accent-color: black;
37
+ }
38
+ .dark input[type='range'] {
39
+ accent-color: #dfdfdf;
40
+ }
41
+ .container {
42
+ max-width: 730px;
43
+ margin: auto;
44
+ padding-top: 1.5rem;
45
+ }
46
+
47
+ .details:hover {
48
+ text-decoration: underline;
49
+ }
50
+ .gr-button {
51
+ white-space: nowrap;
52
+ }
53
+ .gr-button:focus {
54
+ border-color: rgb(147 197 253 / var(--tw-border-opacity));
55
+ outline: none;
56
+ box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
57
+ --tw-border-opacity: 1;
58
+ --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
59
+ --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px var(--tw-ring-offset-width)) var(--tw-ring-color);
60
+ --tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));
61
+ --tw-ring-opacity: .5;
62
+ }
63
+ .footer {
64
+ margin-bottom: 45px;
65
+ margin-top: 35px;
66
+ text-align: center;
67
+ border-bottom: 1px solid #e5e5e5;
68
+ }
69
+ .footer>p {
70
+ font-size: .8rem;
71
+ display: inline-block;
72
+ padding: 0 10px;
73
+ transform: translateY(10px);
74
+ background: white;
75
+ }
76
+ .dark .footer {
77
+ border-color: #303030;
78
+ }
79
+ .dark .footer>p {
80
+ background: #0b0f19;
81
+ }
82
+ .prompt h4{
83
+ margin: 1.25em 0 .25em 0;
84
+ font-weight: bold;
85
+ font-size: 115%;
86
+ }
87
+ """
88
+
89
+ block = gr.Blocks(css=css)
90
 
91
  examples = [
92
  [
 
162
  """
163
  )
164
  with gr.Group():
165
+ with gr.Group():
166
+ text = gr.Textbox(
167
+ label="input_text",
168
+ placeholder="Please enter Chinese text.",
169
+ )
170
+ btn = gr.Button(value="Generate text")
171
  task = gr.Dropdown(label="task",
172
  choices=[
173
  'text_summarization',
 
180
  ],
181
  value='text_summarization')
182
 
183
+ min_dec_len = gr.Slider(
184
+ minimum=1, maximum=511, value=1, label="min_dec_len", step=1, interactive=True)
185
+ seq_len = gr.Slider(minimum=2, maximum=512, value=128,
186
+ label="seq_len", step=1, interactive=True)
187
+ topp = gr.Slider(minimum=0.0, maximum=1.0, value=1.0,
188
+ label="topp", step=0.01, interactive=True)
189
+ penalty_score = gr.Slider(
190
+ minimum=1.0, maximum=2.0, value=1.0, label="penalty_score", step=0.01, interactive=True)
191
 
192
  text_gen = gr.Textbox(label="generated_text")
193
 
194
+ ex = gr.Examples(examples=examples, fn=inference, inputs=[
195
+ task, text, min_dec_len, seq_len, topp, penalty_score], outputs=text_gen, cache_examples=False)
196
 
197
+ text.submit(inference, inputs=[
198
+ task, text, min_dec_len, seq_len, topp, penalty_score], outputs=text_gen)
199
+ btn.click(inference, inputs=[
200
+ task, text, min_dec_len, seq_len, topp, penalty_score], outputs=text_gen)
201
  gr.HTML(
202
  """
203
  <div class="footer">