Spaces:
Runtime error
Runtime error
Duplicate from PaddlePaddle/ERNIE-ViLG
Browse filesCo-authored-by: chen Jian <[email protected]>
- .gitattributes +31 -0
- README.md +14 -0
- app.py +362 -0
- requirements.txt +3 -0
.gitattributes
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
23 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: ERNIE-ViLG
|
3 |
+
emoji: 🐼
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: pink
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.1.7
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: apache-2.0
|
11 |
+
duplicated_from: PaddlePaddle/ERNIE-ViLG
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,362 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import gradio as gr
|
3 |
+
import paddlehub as hub
|
4 |
+
|
5 |
+
|
6 |
+
model = hub.Module(name='ernie_vilg')
|
7 |
+
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 |
+
|
12 |
+
tips = {"en": "Tips: The input text will be translated into Chinese for generation",
|
13 |
+
"jp": "ヒント: 入力テキストは生成のために中国語に翻訳されます",
|
14 |
+
"kor": "힌트: 입력 텍스트는 생성을 위해 중국어로 번역됩니다"}
|
15 |
+
|
16 |
+
count = 0
|
17 |
+
|
18 |
+
def translate_language(text_prompts):
|
19 |
+
global count
|
20 |
+
try:
|
21 |
+
count += 1
|
22 |
+
tips_text = None
|
23 |
+
language_code = language_recognition_model.recognize(text_prompts)
|
24 |
+
if language_code != 'zh':
|
25 |
+
text_prompts = language_translation_model.translate(text_prompts, language_code, 'zh')
|
26 |
+
except Exception as e:
|
27 |
+
error_text = str(e)
|
28 |
+
return {status_text:error_text, language_tips_text:gr.update(visible=False)}
|
29 |
+
if language_code in tips:
|
30 |
+
tips_text = tips[language_code]
|
31 |
+
else:
|
32 |
+
tips_text = tips['en']
|
33 |
+
if language_code == 'zh':
|
34 |
+
return {language_tips_text:gr.update(visible=False), translated_language:text_prompts, trigger_component: gr.update(value=count, visible=False)}
|
35 |
+
else:
|
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 |
+
model.token = model._apply_token(model.ak, model.sk)
|
42 |
+
style = style_list[style_indx]
|
43 |
+
results = model.generate_image(
|
44 |
+
text_prompts=text_prompts, style=style, visualization=False)
|
45 |
+
except Exception as e:
|
46 |
+
error_text = str(e)
|
47 |
+
return {status_text:error_text, gallery:None}
|
48 |
+
return {status_text:'Success', gallery:results[:6]}
|
49 |
+
|
50 |
+
|
51 |
+
title="ERNIE-ViLG"
|
52 |
+
|
53 |
+
description="ERNIE-ViLG model, which supports text-to-image task."
|
54 |
+
|
55 |
+
css = """
|
56 |
+
.gradio-container {
|
57 |
+
font-family: 'IBM Plex Sans', sans-serif;
|
58 |
+
}
|
59 |
+
.gr-button {
|
60 |
+
color: white;
|
61 |
+
border-color: black;
|
62 |
+
background: black;
|
63 |
+
}
|
64 |
+
input[type='range'] {
|
65 |
+
accent-color: black;
|
66 |
+
}
|
67 |
+
.dark input[type='range'] {
|
68 |
+
accent-color: #dfdfdf;
|
69 |
+
}
|
70 |
+
.container {
|
71 |
+
max-width: 730px;
|
72 |
+
margin: auto;
|
73 |
+
padding-top: 1.5rem;
|
74 |
+
}
|
75 |
+
#gallery {
|
76 |
+
min-height: 22rem;
|
77 |
+
margin-bottom: 15px;
|
78 |
+
margin-left: auto;
|
79 |
+
margin-right: auto;
|
80 |
+
border-bottom-right-radius: .5rem !important;
|
81 |
+
border-bottom-left-radius: .5rem !important;
|
82 |
+
}
|
83 |
+
#gallery>div>.h-full {
|
84 |
+
min-height: 20rem;
|
85 |
+
}
|
86 |
+
.details:hover {
|
87 |
+
text-decoration: underline;
|
88 |
+
}
|
89 |
+
.gr-button {
|
90 |
+
white-space: nowrap;
|
91 |
+
}
|
92 |
+
.gr-button:focus {
|
93 |
+
border-color: rgb(147 197 253 / var(--tw-border-opacity));
|
94 |
+
outline: none;
|
95 |
+
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
96 |
+
--tw-border-opacity: 1;
|
97 |
+
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
98 |
+
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px var(--tw-ring-offset-width)) var(--tw-ring-color);
|
99 |
+
--tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));
|
100 |
+
--tw-ring-opacity: .5;
|
101 |
+
}
|
102 |
+
.footer {
|
103 |
+
margin-bottom: 45px;
|
104 |
+
margin-top: 35px;
|
105 |
+
text-align: center;
|
106 |
+
border-bottom: 1px solid #e5e5e5;
|
107 |
+
}
|
108 |
+
.footer>p {
|
109 |
+
font-size: .8rem;
|
110 |
+
display: inline-block;
|
111 |
+
padding: 0 10px;
|
112 |
+
transform: translateY(10px);
|
113 |
+
background: white;
|
114 |
+
}
|
115 |
+
.dark .footer {
|
116 |
+
border-color: #303030;
|
117 |
+
}
|
118 |
+
.dark .footer>p {
|
119 |
+
background: #0b0f19;
|
120 |
+
}
|
121 |
+
.prompt h4{
|
122 |
+
margin: 1.25em 0 .25em 0;
|
123 |
+
font-weight: bold;
|
124 |
+
font-size: 115%;
|
125 |
+
}
|
126 |
+
"""
|
127 |
+
|
128 |
+
block = gr.Blocks(css=css)
|
129 |
+
|
130 |
+
examples = [
|
131 |
+
[
|
132 |
+
'戴着眼镜的猫',
|
133 |
+
'油画(Oil painting)'
|
134 |
+
],
|
135 |
+
[
|
136 |
+
'A cat with glasses',
|
137 |
+
'油画(Oil painting)'
|
138 |
+
],
|
139 |
+
[
|
140 |
+
'眼鏡をかけた猫',
|
141 |
+
'油画(Oil painting)'
|
142 |
+
],
|
143 |
+
[
|
144 |
+
'안경을 쓴 고양이',
|
145 |
+
'油画(Oil painting)'
|
146 |
+
],
|
147 |
+
[
|
148 |
+
'日落时的城市天际线,史前遗迹风格',
|
149 |
+
'油画(Oil painting)'
|
150 |
+
],
|
151 |
+
[
|
152 |
+
'一只猫坐在椅子上��戴着一副墨镜, low poly 风格',
|
153 |
+
'卡通(Cartoon)'
|
154 |
+
],
|
155 |
+
[
|
156 |
+
'A cat sitting on a chair, wearing a pair of sunglasses, low poly style',
|
157 |
+
'油画(Oil painting)'
|
158 |
+
],
|
159 |
+
[
|
160 |
+
'猫が椅子に座ってサングラスをかけている、low polyスタイル',
|
161 |
+
'油画(Oil painting)'
|
162 |
+
],
|
163 |
+
[
|
164 |
+
'고양이 한 마리가 의자에 앉아 선글라스를 끼고 low poly 스타일을 하고 있다',
|
165 |
+
'油画(Oil painting)'
|
166 |
+
],
|
167 |
+
[
|
168 |
+
'一只猫坐在椅子上,戴着一副墨镜,秋天风格',
|
169 |
+
'探索无限(Explore infinity)'
|
170 |
+
],
|
171 |
+
[
|
172 |
+
'蒙娜丽莎,赛博朋克,宝丽来,33毫米,蒸汽波艺术',
|
173 |
+
'探索无限(Explore infinity)'
|
174 |
+
],
|
175 |
+
[
|
176 |
+
'一只猫坐在椅子上,戴着一副墨镜,海盗风格',
|
177 |
+
'探索无限(Explore infinity)'
|
178 |
+
],
|
179 |
+
[
|
180 |
+
'一条由闪电制成的令人敬畏的龙,概念艺术',
|
181 |
+
'探索无限(Explore infinity)'
|
182 |
+
],
|
183 |
+
[
|
184 |
+
'An awesome dragon made of lightning, conceptual art',
|
185 |
+
'油画(Oil painting)'
|
186 |
+
],
|
187 |
+
[
|
188 |
+
'稲妻で作られた畏敬の念を抱かせる竜、コンセプトアート',
|
189 |
+
'油画(Oil painting)'
|
190 |
+
],
|
191 |
+
[
|
192 |
+
'번개로 만든 경외스러운 용, 개념 예술',
|
193 |
+
'油画(Oil painting)'
|
194 |
+
],
|
195 |
+
[
|
196 |
+
'梵高猫头鹰,蒸汽波艺术',
|
197 |
+
'探索无限(Explore infinity)'
|
198 |
+
],
|
199 |
+
[
|
200 |
+
'萨尔瓦多·达利描绘古代文明的超现实主义梦幻油画,写实风格',
|
201 |
+
'探索无限(Explore infinity)'
|
202 |
+
],
|
203 |
+
[
|
204 |
+
'夕阳日落时,阳光落在云层上,海面波涛汹涌,风景,胶片感',
|
205 |
+
'探索无限(Explore infinity)'
|
206 |
+
],
|
207 |
+
[
|
208 |
+
'Sunset, the sun falls on the clouds, the sea is rough, the scenery is filmy',
|
209 |
+
'油画(Oil painting)'
|
210 |
+
],
|
211 |
+
[
|
212 |
+
'夕日が沈むと、雲の上に太陽の光が落ち、海面は波が荒く、風景、フィルム感',
|
213 |
+
'油画(Oil painting)'
|
214 |
+
],
|
215 |
+
[
|
216 |
+
'석양이 질 때 햇빛이 구름 위에 떨어지고, 해수면의 파도가 용솟음치며, 풍경, 필름감',
|
217 |
+
'油画(Oil painting)'
|
218 |
+
],
|
219 |
+
]
|
220 |
+
|
221 |
+
with block:
|
222 |
+
gr.HTML(
|
223 |
+
"""
|
224 |
+
<div style="text-align: center; max-width: 650px; margin: 0 auto;">
|
225 |
+
<div
|
226 |
+
style="
|
227 |
+
display: inline-flex;
|
228 |
+
gap: 0.8rem;
|
229 |
+
font-size: 1.75rem;
|
230 |
+
margin-bottom: 10px;
|
231 |
+
margin-left: 220px;
|
232 |
+
justify-content: center;
|
233 |
+
"
|
234 |
+
>
|
235 |
+
<a href="https://github.com/PaddlePaddle/PaddleHub"><img src="https://user-images.githubusercontent.com/22424850/187387422-f6c9ccab-7fda-416e-a24d-7d6084c46f67.jpg" alt="Paddlehub" width="40%"></a>
|
236 |
+
</div>
|
237 |
+
<div
|
238 |
+
style="
|
239 |
+
display: inline-flex;
|
240 |
+
align-items: center;
|
241 |
+
gap: 0.8rem;
|
242 |
+
font-size: 1.75rem;
|
243 |
+
margin-bottom: 10px;
|
244 |
+
justify-content: center;
|
245 |
+
">
|
246 |
+
<a href="https://github.com/PaddlePaddle/PaddleHub"><h1 style="font-weight: 900; margin-bottom: 7px;">
|
247 |
+
ERNIE-ViLG Demo
|
248 |
+
</h1></a>
|
249 |
+
</div>
|
250 |
+
<p style="margin-bottom: 10px; font-size: 94%">
|
251 |
+
ERNIE-ViLG 2.0 is a state-of-the-art text-to-image model that generates
|
252 |
+
images from Chinese text.
|
253 |
+
</p>
|
254 |
+
<a href="https://github.com/PaddlePaddle/PaddleHub"><img src="https://user-images.githubusercontent.com/22424850/188184795-98605a22-9af2-4106-827b-e58548f8892f.png" alt="star Paddlehub" width="100%"></a>
|
255 |
+
</div>
|
256 |
+
"""
|
257 |
+
)
|
258 |
+
with gr.Group():
|
259 |
+
with gr.Box():
|
260 |
+
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
261 |
+
text = gr.Textbox(
|
262 |
+
label="Prompt",
|
263 |
+
show_label=False,
|
264 |
+
max_lines=1,
|
265 |
+
placeholder="Enter your prompt, multiple languages are supported now.",
|
266 |
+
).style(
|
267 |
+
border=(True, False, True, True),
|
268 |
+
rounded=(True, False, False, True),
|
269 |
+
container=False,
|
270 |
+
)
|
271 |
+
|
272 |
+
btn = gr.Button("Generate image").style(
|
273 |
+
margin=False,
|
274 |
+
rounded=(False, True, True, False),
|
275 |
+
)
|
276 |
+
language_tips_text = gr.Textbox(label="language tips", show_label=False, visible=False, max_lines=1)
|
277 |
+
styles = gr.Dropdown(label="风格(style)", choices=['古风(Ancient Style)', '油画(Oil painting)', '水彩(Watercolor)',
|
278 |
+
'卡通(Cartoon)', '二次元(Anime)', '浮世绘(Ukiyoe)', '蒸汽波艺术(Vaporwave)', 'low poly',
|
279 |
+
'像素风格(Pixel Style)', '概念艺术(Conceptual Art)', '未来主义(Futurism)', '赛博朋克(Cyberpunk)', '写实风格(Realistic style)',
|
280 |
+
'洛丽塔风格(Lolita style)', '巴洛克风格(Baroque style)', '超现实主义(Surrealism)', '探索无限(Explore infinity)'], value='探索无限(Explore infinity)', type="index")
|
281 |
+
gallery = gr.Gallery(
|
282 |
+
label="Generated images", show_label=False, elem_id="gallery"
|
283 |
+
).style(grid=[2, 3], height="auto")
|
284 |
+
status_text = gr.Textbox(
|
285 |
+
label="处理状态(Process status)",
|
286 |
+
show_label=True,
|
287 |
+
max_lines=1,
|
288 |
+
interactive=False
|
289 |
+
)
|
290 |
+
trigger_component = gr.Textbox(vaule="", visible=False) # This component is used for triggering inference funtion.
|
291 |
+
translated_language = gr.Textbox(vaule="", visible=False)
|
292 |
+
|
293 |
+
ex = gr.Examples(examples=examples, fn=translate_language, inputs=[text], outputs=[language_tips_text, status_text, trigger_component, translated_language], cache_examples=False)
|
294 |
+
ex.dataset.headers = [""]
|
295 |
+
|
296 |
+
|
297 |
+
text.submit(translate_language, inputs=[text], outputs=[language_tips_text, status_text, trigger_component, translated_language])
|
298 |
+
btn.click(translate_language, inputs=[text], outputs=[language_tips_text, status_text, trigger_component, translated_language])
|
299 |
+
trigger_component.change(fn=inference, inputs=[translated_language, styles], outputs=[status_text, gallery])
|
300 |
+
gr.HTML(
|
301 |
+
"""
|
302 |
+
<div class="prompt">
|
303 |
+
<p><h4>Prompt公式</h4>
|
304 |
+
<span> Prompt = 图片主体,细节词,修饰词 </span>
|
305 |
+
关于各部分的构造方式和效果,可以参考<a href="https://github.com/PaddlePaddle/PaddleHub/blob/develop/modules/image/text_to_image/ernie_vilg/README.md#四-prompt-指南" style="text-decoration: underline;" target="_blank">YouPromptMe指南</a>。
|
306 |
+
更多的模型,请关注<a href="https://github.com/PaddlePaddle/PaddleHub" style="text-decoration: underline;" target="_blank"> PaddleHub 官方Repo </a>, 如果你觉得不错,请star收藏吧。
|
307 |
+
<p><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="90" height="20"><style>a:hover #llink{fill:url(#b);stroke:#ccc}a:hover #rlink{fill:#4183c4}</style><linearGradient id="a" x2="0" y2="100%"><stop offset="0" stop-color="#fcfcfc" stop-opacity="0"/><stop offset="1" stop-opacity=".1"/></linearGradient><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#ccc" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><g stroke="#d5d5d5"><rect stroke="none" fill="#fcfcfc" x="0.5" y="0.5" width="54" height="19" rx="2"/><rect x="60.5" y="0.5" width="29" height="19" rx="2" fill="#fafafa"/><rect x="60" y="7.5" width="0.5" height="5" stroke="#fafafa"/><path d="M60.5 6.5 l-3 3v1 l3 3" stroke="d5d5d5" fill="#fafafa"/></g><image x="5" y="3" width="14" height="14" xlink:href="data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjMTgxNzE3IiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+R2l0SHViPC90aXRsZT48cGF0aCBkPSJNMTIgLjI5N2MtNi42MyAwLTEyIDUuMzczLTEyIDEyIDAgNS4zMDMgMy40MzggOS44IDguMjA1IDExLjM4NS42LjExMy44Mi0uMjU4LjgyLS41NzcgMC0uMjg1LS4wMS0xLjA0LS4wMTUtMi4wNC0zLjMzOC43MjQtNC4wNDItMS42MS00LjA0Mi0xLjYxQzQuNDIyIDE4LjA3IDMuNjMzIDE3LjcgMy42MzMgMTcuN2MtMS4wODctLjc0NC4wODQtLjcyOS4wODQtLjcyOSAxLjIwNS4wODQgMS44MzggMS4yMzYgMS44MzggMS4yMzYgMS4wNyAxLjgzNSAyLjgwOSAxLjMwNSAzLjQ5NS45OTguMTA4LS43NzYuNDE3LTEuMzA1Ljc2LTEuNjA1LTIuNjY1LS4zLTUuNDY2LTEuMzMyLTUuNDY2LTUuOTMgMC0xLjMxLjQ2NS0yLjM4IDEuMjM1LTMuMjItLjEzNS0uMzAzLS41NC0xLjUyMy4xMDUtMy4xNzYgMCAwIDEuMDA1LS4zMjIgMy4zIDEuMjMuOTYtLjI2NyAxLjk4LS4zOTkgMy0uNDA1IDEuMDIuMDA2IDIuMDQuMTM4IDMgLjQwNSAyLjI4LTEuNTUyIDMuMjg1LTEuMjMgMy4yODUtMS4yMy42NDUgMS42NTMuMjQgMi44NzMuMTIgMy4xNzYuNzY1Ljg0IDEuMjMgMS45MSAxLjIzIDMuMjIgMCA0LjYxLTIuODA1IDUuNjI1LTUuNDc1IDUuOTIuNDIuMzYuODEgMS4wOTYuODEgMi4yMiAwIDEuNjA2LS4wMTUgMi44OTYtLjAxNSAzLjI4NiAwIC4zMTUuMjEuNjkuODI1LjU3QzIwLjU2NSAyMi4wOTIgMjQgMTcuNTkyIDI0IDEyLjI5N2MwLTYuNjI3LTUuMzczLTEyLTEyLTEyIi8+PC9zdmc+"/><g aria-hidden="false" fill="#333" text-anchor="middle" font-family="Helvetica Neue,Helvetica,Arial,sans-serif" text-rendering="geometricPrecision" font-weight="700" font-size="110px" line-height="14px"><a target="_blank" xlink:href="https://github.com/PaddlePaddle/PaddleHub"><text aria-hidden="true" x="355" y="150" fill="#fff" transform="scale(.1)" textLength="270">Stars</text><text x="355" y="140" transform="scale(.1)" textLength="270">Stars</text><rect id="llink" stroke="#d5d5d5" fill="url(#a)" x=".5" y=".5" width="54" height="19" rx="2"/></a><a target="_blank" xlink:href="https://github.com/PaddlePaddle/PaddleHub/stargazers"><rect width="30" x="60" height="20" fill="rgba(0,0,0,0)"/><text aria-hidden="true" x="745" y="150" fill="#fff" transform="scale(.1)" textLength="210">8.4k</text><text id="rlink" x="745" y="140" transform="scale(.1)" textLength="210">8.4k</text></a></g></svg></p>
|
308 |
+
同时,可以在 <a href="https://aistudio.baidu.com/aistudio/projectdetail/4462918", style="text-decoration: underline;" target="_blank"> aistudio </a> 上使用免费的GPU体验更多案例。
|
309 |
+
</p>
|
310 |
+
</div>
|
311 |
+
<div class="prompt">
|
312 |
+
<p><h4>Prompt format</h4>
|
313 |
+
<span> Prompt = object, details, description </span>
|
314 |
+
For more details, please refer to <a href="https://github.com/PaddlePaddle/PaddleHub/blob/develop/modules/image/text_to_image/ernie_vilg/README.md#四-prompt-指南" style="text-decoration: underline;" target="_blank">YouPromptMe Guide</a>.
|
315 |
+
There are more interesting models in PaddleHub, if you think it's great, welcome to star <a href="https://github.com/PaddlePaddle/PaddleHub" style="text-decoration: underline;" target="_blank"> PaddleHub</a>.
|
316 |
+
<p><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="90" height="20"><style>a:hover #llink{fill:url(#b);stroke:#ccc}a:hover #rlink{fill:#4183c4}</style><linearGradient id="a" x2="0" y2="100%"><stop offset="0" stop-color="#fcfcfc" stop-opacity="0"/><stop offset="1" stop-opacity=".1"/></linearGradient><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#ccc" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><g stroke="#d5d5d5"><rect stroke="none" fill="#fcfcfc" x="0.5" y="0.5" width="54" height="19" rx="2"/><rect x="60.5" y="0.5" width="29" height="19" rx="2" fill="#fafafa"/><rect x="60" y="7.5" width="0.5" height="5" stroke="#fafafa"/><path d="M60.5 6.5 l-3 3v1 l3 3" stroke="d5d5d5" fill="#fafafa"/></g><image x="5" y="3" width="14" height="14" xlink:href="data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjMTgxNzE3IiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+R2l0SHViPC90aXRsZT48cGF0aCBkPSJNMTIgLjI5N2MtNi42MyAwLTEyIDUuMzczLTEyIDEyIDAgNS4zMDMgMy40MzggOS44IDguMjA1IDExLjM4NS42LjExMy44Mi0uMjU4LjgyLS41NzcgMC0uMjg1LS4wMS0xLjA0LS4wMTUtMi4wNC0zLjMzOC43MjQtNC4wNDItMS42MS00LjA0Mi0xLjYxQzQuNDIyIDE4LjA3IDMuNjMzIDE3LjcgMy42MzMgMTcuN2MtMS4wODctLjc0NC4wODQtLjcyOS4wODQtLjcyOSAxLjIwNS4wODQgMS44MzggMS4yMzYgMS44MzggMS4yMzYgMS4wNyAxLjgzNSAyLjgwOSAxLjMwNSAzLjQ5NS45OTguMTA4LS43NzYuNDE3LTEuMzA1Ljc2LTEuNjA1LTIuNjY1LS4zLTUuNDY2LTEuMzMyLTUuNDY2LTUuOTMgMC0xLjMxLjQ2NS0yLjM4IDEuMjM1LTMuMjItLjEzNS0uMzAzLS41NC0xLjUyMy4xMDUtMy4xNzYgMCAwIDEuMDA1LS4zMjIgMy4zIDEuMjMuOTYtLjI2NyAxLjk4LS4zOTkgMy0uNDA1IDEuMDIuMDA2IDIuMDQuMTM4IDMgLjQwNSAyLjI4LTEuNTUyIDMuMjg1LTEuMjMgMy4yODUtMS4yMy42NDUgMS42NTMuMjQgMi44NzMuMTIgMy4xNzYuNzY1Ljg0IDEuMjMgMS45MSAxLjIzIDMuMjIgMCA0LjYxLTIuODA1IDUuNjI1LTUuNDc1IDUuOTIuNDIuMzYuODEgMS4wOTYuODEgMi4yMiAwIDEuNjA2LS4wMTUgMi44OTYtLjAxNSAzLjI4NiAwIC4zMTUuMjEuNjkuODI1LjU3QzIwLjU2NSAyMi4wOTIgMjQgMTcuNTkyIDI0IDEyLjI5N2MwLTYuNjI3LTUuMzczLTEyLTEyLTEyIi8+PC9zdmc+"/><g aria-hidden="false" fill="#333" text-anchor="middle" font-family="Helvetica Neue,Helvetica,Arial,sans-serif" text-rendering="geometricPrecision" font-weight="700" font-size="110px" line-height="14px"><a target="_blank" xlink:href="https://github.com/PaddlePaddle/PaddleHub"><text aria-hidden="true" x="355" y="150" fill="#fff" transform="scale(.1)" textLength="270">Stars</text><text x="355" y="140" transform="scale(.1)" textLength="270">Stars</text><rect id="llink" stroke="#d5d5d5" fill="url(#a)" x=".5" y=".5" width="54" height="19" rx="2"/></a><a target="_blank" xlink:href="https://github.com/PaddlePaddle/PaddleHub/stargazers"><rect width="30" x="60" height="20" fill="rgba(0,0,0,0)"/><text aria-hidden="true" x="745" y="150" fill="#fff" transform="scale(.1)" textLength="210">8.4k</text><text id="rlink" x="745" y="140" transform="scale(.1)" textLength="210">8.4k</text></a></g></svg></p>
|
317 |
+
Besides, you can use free GPU resourses in <a href="https://aistudio.baidu.com/aistudio/projectdetail/4462918", style="text-decoration: underline;" target="_blank"> aistudio </a> to enjoy more cases, have fun.
|
318 |
+
</p>
|
319 |
+
</div>
|
320 |
+
|
321 |
+
"""
|
322 |
+
)
|
323 |
+
gr.Markdown(
|
324 |
+
"""
|
325 |
+
在"探索无限"的风格模式下,画作的真实风格完全可以由你的prompt来决定。下面是一些参考案例:
|
326 |
+
|
327 |
+
In "Explore infinity" style mode, how the image looks like is totally up to your prompt. Below are some cases:
|
328 |
+
|
329 |
+
|<img src="https://bce.bdstatic.com/doc/AIDP/wenxin/174_蒙娜丽莎,赛博朋克,宝丽来,33毫米,蒸汽波艺术_000-1_7b4a78a.png" alt="drawing" width="300"/>|
|
330 |
+
| --- |
|
331 |
+
| prompt:蒙娜丽莎,赛博朋克,宝丽来,33毫米,</br>蒸汽波艺术 |
|
332 |
+
|
333 |
+
|
334 |
+
|<img src="https://bce.bdstatic.com/doc/AIDP/wenxin/3_72d9343.png" alt="drawing" width="300"/>|
|
335 |
+
| --- |
|
336 |
+
| prompt:火焰,凤凰,少女,未来感,高清,3d,</br>精致面容,cg感,古风,唯美,毛发细致,上半身立绘 |
|
337 |
+
|
338 |
+
|
339 |
+
|<img src="https://bce.bdstatic.com/doc/AIDP/wenxin/4_e1f5cbb.png" alt="drawing" width="300"/>|
|
340 |
+
| --- |
|
341 |
+
| prompt:巨狼,飘雪,蓝色大片烟雾,毛发细致,</br>烟雾缭绕,高清,3d,cg感,侧面照 |
|
342 |
+
|
343 |
+
|
344 |
+
| <img src="https://bce.bdstatic.com/doc/AIDP/wenxin/5_d380451.png" alt="drawing" width="400"/> |
|
345 |
+
| --- |
|
346 |
+
| prompt:浮世绘日本科幻哑光绘画,概念艺术,</br>动漫风格神道寺禅园英雄动作序列,包豪斯|
|
347 |
+
|
348 |
+
<img src="https://bce.bdstatic.com/doc/AIDP/wenxin/1_3612449.jpg" alt="drawing" width="600"/>
|
349 |
+
|
350 |
+
### <u>[更多内容...](https://github.com/PaddlePaddle/PaddleHub/blob/develop/modules/image/text_to_image/ernie_vilg/README.md#四-prompt-指南)([Explore more...](https://github.com/PaddlePaddle/PaddleHub/blob/develop/modules/image/text_to_image/ernie_vilg/README.md#四-prompt-指南))</u>
|
351 |
+
|
352 |
+
|
353 |
+
"""
|
354 |
+
)
|
355 |
+
gr.HTML('''
|
356 |
+
<div class="footer">
|
357 |
+
<p>Model by <a href="https://github.com/PaddlePaddle/PaddleHub" style="text-decoration: underline;" target="_blank">PaddleHub</a> and <a href="https://wenxin.baidu.com/ernie-vilg" style="text-decoration: underline;" target="_blank">文心大模型</a> - Gradio Demo by 🤗 Hugging Face
|
358 |
+
</p>
|
359 |
+
</div>
|
360 |
+
''')
|
361 |
+
|
362 |
+
block.queue(concurrency_count=128).launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
paddlepaddle
|
2 |
+
paddlehub
|
3 |
+
requests
|