Spaces:
Runtime error
Runtime error
remove resolution
Browse files
app.py
CHANGED
@@ -8,7 +8,6 @@ language_translation_model = hub.Module(name='baidu_translate')
|
|
8 |
language_recognition_model = hub.Module(name='baidu_language_recognition')
|
9 |
|
10 |
style_list = ['古风', '油画', '水彩', '卡通', '二次元', '浮世绘', '蒸汽波艺术', 'low poly', '像素风格', '概念艺术', '未来主义', '赛博朋克', '写实风格', '洛丽塔风格', '巴洛克风格', '超现实主义', '探索无限']
|
11 |
-
resolution_list = ['1024*1024', '1024*1536', '1536*1024']
|
12 |
|
13 |
tips = {"en": "Tips: The input text will be translated into Chinese for generation",
|
14 |
"jp": "ヒント: 入力テキストは生成のために中国語に翻訳されます",
|
@@ -37,12 +36,11 @@ def translate_language(text_prompts):
|
|
37 |
return {language_tips_text:gr.update(visible=True, value=tips_text), translated_language:text_prompts, trigger_component: gr.update(value=count, visible=False)}
|
38 |
|
39 |
|
40 |
-
def inference(text_prompts, style_indx
|
41 |
try:
|
42 |
style = style_list[style_indx]
|
43 |
-
resolution = resolution_list[resolution_indx]
|
44 |
results = model.generate_image(
|
45 |
-
text_prompts=text_prompts, style=style,
|
46 |
except Exception as e:
|
47 |
error_text = str(e)
|
48 |
return {status_text:error_text, gallery:None}
|
@@ -279,7 +277,6 @@ with block:
|
|
279 |
'卡通(Cartoon)', '二次元(Anime)', '浮世绘(Ukiyoe)', '蒸汽波艺术(Vaporwave)', 'low poly',
|
280 |
'像素风格(Pixel Style)', '概念艺术(Conceptual Art)', '未来主义(Futurism)', '赛博朋克(Cyberpunk)', '写实风格(Realistic style)',
|
281 |
'洛丽塔风格(Lolita style)', '巴洛克风格(Baroque style)', '超现实主义(Surrealism)', '探索无限(Explore infinity)'], value='探索无限(Explore infinity)', type="index")
|
282 |
-
resolutions = gr.Dropdown(label="分辨率(resolution)", choices=resolution_list, value='1024*1024', type="index")
|
283 |
gallery = gr.Gallery(
|
284 |
label="Generated images", show_label=False, elem_id="gallery"
|
285 |
).style(grid=[2, 3], height="auto")
|
@@ -298,7 +295,7 @@ with block:
|
|
298 |
|
299 |
text.submit(translate_language, inputs=[text], outputs=[language_tips_text, status_text, trigger_component, translated_language])
|
300 |
btn.click(translate_language, inputs=[text], outputs=[language_tips_text, status_text, trigger_component, translated_language])
|
301 |
-
trigger_component.change(fn=inference, inputs=[translated_language, styles
|
302 |
gr.HTML(
|
303 |
"""
|
304 |
<div class="prompt">
|
|
|
8 |
language_recognition_model = hub.Module(name='baidu_language_recognition')
|
9 |
|
10 |
style_list = ['古风', '油画', '水彩', '卡通', '二次元', '浮世绘', '蒸汽波艺术', 'low poly', '像素风格', '概念艺术', '未来主义', '赛博朋克', '写实风格', '洛丽塔风格', '巴洛克风格', '超现实主义', '探索无限']
|
|
|
11 |
|
12 |
tips = {"en": "Tips: The input text will be translated into Chinese for generation",
|
13 |
"jp": "ヒント: 入力テキストは生成のために中国語に翻訳されます",
|
|
|
36 |
return {language_tips_text:gr.update(visible=True, value=tips_text), translated_language:text_prompts, trigger_component: gr.update(value=count, visible=False)}
|
37 |
|
38 |
|
39 |
+
def inference(text_prompts, style_indx):
|
40 |
try:
|
41 |
style = style_list[style_indx]
|
|
|
42 |
results = model.generate_image(
|
43 |
+
text_prompts=text_prompts, style=style, visualization=False)
|
44 |
except Exception as e:
|
45 |
error_text = str(e)
|
46 |
return {status_text:error_text, gallery:None}
|
|
|
277 |
'卡通(Cartoon)', '二次元(Anime)', '浮世绘(Ukiyoe)', '蒸汽波艺术(Vaporwave)', 'low poly',
|
278 |
'像素风格(Pixel Style)', '概念艺术(Conceptual Art)', '未来主义(Futurism)', '赛博朋克(Cyberpunk)', '写实风格(Realistic style)',
|
279 |
'洛丽塔风格(Lolita style)', '巴洛克风格(Baroque style)', '超现实主义(Surrealism)', '探索无限(Explore infinity)'], value='探索无限(Explore infinity)', type="index")
|
|
|
280 |
gallery = gr.Gallery(
|
281 |
label="Generated images", show_label=False, elem_id="gallery"
|
282 |
).style(grid=[2, 3], height="auto")
|
|
|
295 |
|
296 |
text.submit(translate_language, inputs=[text], outputs=[language_tips_text, status_text, trigger_component, translated_language])
|
297 |
btn.click(translate_language, inputs=[text], outputs=[language_tips_text, status_text, trigger_component, translated_language])
|
298 |
+
trigger_component.change(fn=inference, inputs=[translated_language, styles], outputs=[status_text, gallery])
|
299 |
gr.HTML(
|
300 |
"""
|
301 |
<div class="prompt">
|