Spaces:
Running
Running
liuyizhang
commited on
Commit
Β·
eb3ba9e
1
Parent(s):
dc3f3fe
app.py
Browse files
app.py
CHANGED
@@ -18,13 +18,21 @@ def extend_prompt(prompt):
|
|
18 |
prompt_en = getTextTrans(prompt, source='zh', target='en')
|
19 |
extend_prompt_en = extend_prompt_pipe(prompt_en+',', num_return_sequences=1)[0]["generated_text"]
|
20 |
if (prompt != prompt_en):
|
|
|
21 |
extend_prompt_zh = getTextTrans(extend_prompt_en, source='en', target='zh')
|
22 |
extend_prompt_out = f'{extend_prompt_zh} γ{extend_prompt_en}γ'
|
23 |
else:
|
|
|
24 |
extend_prompt_out = extend_prompt_en
|
25 |
|
26 |
return prompt_en, extend_prompt_en, extend_prompt_out
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
examples = [
|
29 |
['elon musk as thor'],
|
30 |
["giant dragon flying in the sky"],
|
@@ -211,10 +219,12 @@ with gr.Blocks(title='prompt-extend/') as demo:
|
|
211 |
margin=True,
|
212 |
rounded=(True, True, True, True),
|
213 |
)
|
214 |
-
submit_btn.click(fn=extend_prompt, inputs=[prompt_input0], outputs=[prompt_input0_en, prompt_input1, prompt_input2])
|
215 |
with gr.Row(elem_id='tab_demo', visible=True).style(height=200):
|
216 |
tab_demo = gr.TabbedInterface(tab_actions, tab_titles)
|
217 |
with gr.Row():
|
218 |
gr.HTML(f"<p>{thanks_info}</p>")
|
219 |
|
|
|
|
|
|
|
220 |
demo.launch()
|
|
|
18 |
prompt_en = getTextTrans(prompt, source='zh', target='en')
|
19 |
extend_prompt_en = extend_prompt_pipe(prompt_en+',', num_return_sequences=1)[0]["generated_text"]
|
20 |
if (prompt != prompt_en):
|
21 |
+
logger.info(f"extend_prompt__1__")
|
22 |
extend_prompt_zh = getTextTrans(extend_prompt_en, source='en', target='zh')
|
23 |
extend_prompt_out = f'{extend_prompt_zh} γ{extend_prompt_en}γ'
|
24 |
else:
|
25 |
+
logger.info(f"extend_prompt__2__")
|
26 |
extend_prompt_out = extend_prompt_en
|
27 |
|
28 |
return prompt_en, extend_prompt_en, extend_prompt_out
|
29 |
|
30 |
+
def change_prompt_radio(choice):
|
31 |
+
if choice == "Original prompt":
|
32 |
+
return gr.update(visible=False)
|
33 |
+
else:
|
34 |
+
return gr.update(visible=True)
|
35 |
+
|
36 |
examples = [
|
37 |
['elon musk as thor'],
|
38 |
["giant dragon flying in the sky"],
|
|
|
219 |
margin=True,
|
220 |
rounded=(True, True, True, True),
|
221 |
)
|
|
|
222 |
with gr.Row(elem_id='tab_demo', visible=True).style(height=200):
|
223 |
tab_demo = gr.TabbedInterface(tab_actions, tab_titles)
|
224 |
with gr.Row():
|
225 |
gr.HTML(f"<p>{thanks_info}</p>")
|
226 |
|
227 |
+
# prompt_radio.change(fn=change_prompt_radio, inputs=[prompt_radio], outputs=[prompt_input2])
|
228 |
+
submit_btn.click(fn=extend_prompt, inputs=[prompt_input0], outputs=[prompt_input0_en, prompt_input1, prompt_input2])
|
229 |
+
|
230 |
demo.launch()
|