Spaces:
Runtime error
Runtime error
drizzlezyk
commited on
Commit
•
a3616ed
1
Parent(s):
7a6c4ed
update app and header
Browse files- app.py +27 -22
- header.html +2 -2
app.py
CHANGED
@@ -4,7 +4,7 @@ import gradio as gr
|
|
4 |
from PIL import Image
|
5 |
from io import BytesIO
|
6 |
|
7 |
-
from
|
8 |
|
9 |
|
10 |
def generate_figure(style, desc):
|
@@ -45,13 +45,8 @@ def read_content(file_path: str) -> str:
|
|
45 |
|
46 |
token = get_token()
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
["宫崎骏", "城市夜景"],
|
51 |
-
["新海诚", "海滩 美景"],
|
52 |
-
["赛博朋克", "一只猫"],
|
53 |
-
|
54 |
-
]
|
55 |
|
56 |
css = """
|
57 |
.gradio-container {background-image: url('file=./background.jpg'); background-size:cover; background-repeat: no-repeat;}
|
@@ -60,7 +55,7 @@ css = """
|
|
60 |
background: linear-gradient(#D8C5EB, #C5E8EB,#90CCF6);
|
61 |
border: 1px solid #C5E8EB;
|
62 |
border-radius: 8px;
|
63 |
-
color: #
|
64 |
}
|
65 |
|
66 |
"""
|
@@ -68,23 +63,30 @@ css = """
|
|
68 |
with gr.Blocks(css=css) as demo:
|
69 |
gr.HTML(read_content("./header.html"))
|
70 |
|
71 |
-
gr.Markdown("# MindSpore Wukong
|
72 |
-
"
|
73 |
-
" the
|
74 |
-
" Wukong
|
75 |
-
|
|
|
76 |
|
77 |
-
with gr.Tab("Figure Generation"):
|
78 |
style_input = gr.Textbox(lines=1,
|
79 |
-
placeholder="
|
80 |
-
label="
|
81 |
elem_id="style-input")
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
desc_input = gr.Textbox(lines=1,
|
83 |
-
placeholder="
|
84 |
-
label=""
|
|
|
85 |
gr.Examples(
|
86 |
-
examples=
|
87 |
-
inputs=
|
88 |
)
|
89 |
generate_button = gr.Button("Generate", elem_id="generate")
|
90 |
with gr.Row():
|
@@ -94,7 +96,10 @@ with gr.Blocks(css=css) as demo:
|
|
94 |
img_output4 = gr.Image(type="pil")
|
95 |
|
96 |
with gr.Accordion("Open for More!"):
|
97 |
-
gr.Markdown("-
|
|
|
|
|
|
|
98 |
|
99 |
generate_button.click(generate_figure,
|
100 |
inputs=[style_input, desc_input],
|
|
|
4 |
from PIL import Image
|
5 |
from io import BytesIO
|
6 |
|
7 |
+
from utils_local import get_token
|
8 |
|
9 |
|
10 |
def generate_figure(style, desc):
|
|
|
45 |
|
46 |
token = get_token()
|
47 |
|
48 |
+
examples_style = ["宫崎骏", "新海诚", "梵高", "赛博朋克", "水彩", "莫奈"]
|
49 |
+
examples_desc = ["城市夜景", "海滩 美景", "一只猫", "摩天大楼", "鸢尾花", "秋水共长天一色"]
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
css = """
|
52 |
.gradio-container {background-image: url('file=./background.jpg'); background-size:cover; background-repeat: no-repeat;}
|
|
|
55 |
background: linear-gradient(#D8C5EB, #C5E8EB,#90CCF6);
|
56 |
border: 1px solid #C5E8EB;
|
57 |
border-radius: 8px;
|
58 |
+
color: #26498B
|
59 |
}
|
60 |
|
61 |
"""
|
|
|
63 |
with gr.Blocks(css=css) as demo:
|
64 |
gr.HTML(read_content("./header.html"))
|
65 |
|
66 |
+
gr.Markdown("# MindSpore Wukong-Huahua "
|
67 |
+
"\nWukong-Huahua is a diffusion-based model that perfoms text-to-image task in Chinese, "
|
68 |
+
"which was developed by the Huawei Noah's Ark Lab in cooperation with the Distributed & Parallel Software Lab and Ascend Product Develop Unit. "
|
69 |
+
"It was trained on Wukong dataset and used MindSpore + Ascend, a software and hardware solution to implement. Welcome to try Wukong-Huahua by Our Online Platform.")
|
70 |
+
|
71 |
+
with gr.Tab("图片生成 (Figure Generation)"):
|
72 |
|
|
|
73 |
style_input = gr.Textbox(lines=1,
|
74 |
+
placeholder="输入中文风格描述",
|
75 |
+
label="Input the style of figure you want to generate. (use Chinese better)",
|
76 |
elem_id="style-input")
|
77 |
+
gr.Examples(
|
78 |
+
examples=examples_style,
|
79 |
+
inputs=style_input,
|
80 |
+
)
|
81 |
+
with gr.Row():
|
82 |
+
gr.Markdown(" *** ")
|
83 |
desc_input = gr.Textbox(lines=1,
|
84 |
+
placeholder="输入中文图片描述",
|
85 |
+
label="Input a sentence to describe the figure you want to generate. "
|
86 |
+
"(use Chinese better)")
|
87 |
gr.Examples(
|
88 |
+
examples=examples_desc,
|
89 |
+
inputs=desc_input,
|
90 |
)
|
91 |
generate_button = gr.Button("Generate", elem_id="generate")
|
92 |
with gr.Row():
|
|
|
96 |
img_output4 = gr.Image(type="pil")
|
97 |
|
98 |
with gr.Accordion("Open for More!"):
|
99 |
+
gr.Markdown("- If you want to know more about the foundation models of MindSpore, please visit "
|
100 |
+
"[The Foundation Models Platform for Mindspore](https://xihe.mindspore.cn/)")
|
101 |
+
gr.Markdown("- Try [Wukong-Huahua model on the Foundation Models Platform for Mindspore]"
|
102 |
+
"(https://xihe.mindspore.cn/modelzoo/wukong)")
|
103 |
|
104 |
generate_button.click(generate_figure,
|
105 |
inputs=[style_input, desc_input],
|
header.html
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<div style="text-align: center; max-width:
|
2 |
<div
|
3 |
style="
|
4 |
display: inline-flex;
|
@@ -22,6 +22,6 @@
|
|
22 |
<a href="https://github.com/mindspore-ai/mindspore"><h1 style="font-weight: 900; align-items: center; margin-bottom: 7px;">
|
23 |
</h1></a>
|
24 |
</div>
|
25 |
-
<a href="https://github.com/mindspore-ai/mindspore"><img src="https://obs-xihe-beijing4-test.obs.cn-north-4.myhuaweicloud.com/xihe-img/huggingface/
|
26 |
|
27 |
</div>
|
|
|
1 |
+
<div style="text-align: center; max-width: 1920px; margin: 0 auto;">
|
2 |
<div
|
3 |
style="
|
4 |
display: inline-flex;
|
|
|
22 |
<a href="https://github.com/mindspore-ai/mindspore"><h1 style="font-weight: 900; align-items: center; margin-bottom: 7px;">
|
23 |
</h1></a>
|
24 |
</div>
|
25 |
+
<a href="https://github.com/mindspore-ai/mindspore"><img src="https://obs-xihe-beijing4-test.obs.cn-north-4.myhuaweicloud.com/xihe-img/huggingface/wukong-banner-english.png" width="100%"></a>
|
26 |
|
27 |
</div>
|