Spaces:
Runtime error
Runtime error
Commit
·
c3ab558
1
Parent(s):
ffcc541
format page
Browse files- app.py +26 -5
- pyproject.toml +0 -2
- requirements.txt +1 -0
app.py
CHANGED
@@ -3,6 +3,7 @@ import requests
|
|
3 |
|
4 |
import gradio as gr
|
5 |
|
|
|
6 |
def get_images(text):
|
7 |
headers = {
|
8 |
"Content-Type": "application/json",
|
@@ -22,10 +23,11 @@ def get_images(text):
|
|
22 |
image_data = response.json()["image"]
|
23 |
for image in image_data:
|
24 |
# got this from https://huggingface.co/spaces/stabilityai/stable-diffusion/blob/main/app.py
|
25 |
-
image_b64 =
|
26 |
images.append(image_b64)
|
27 |
return images
|
28 |
-
|
|
|
29 |
css = """
|
30 |
.gradio-container {
|
31 |
font-family: 'IBM Plex Sans', sans-serif;
|
@@ -149,6 +151,15 @@ css = """
|
|
149 |
#component-16{border-top-width: 1px!important;margin-top: 1em}
|
150 |
.image_duplication{position: absolute; width: 100px; left: 50px}
|
151 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
|
153 |
block = gr.Blocks(css=css)
|
154 |
|
@@ -170,14 +181,17 @@ with block:
|
|
170 |
</h1>
|
171 |
</div>
|
172 |
<p style="margin-bottom: 10px; font-size: 94%; line-height: 23px;">
|
173 |
-
|
|
|
174 |
</p>
|
175 |
</div>
|
176 |
"""
|
177 |
)
|
178 |
with gr.Group():
|
179 |
with gr.Box():
|
180 |
-
with gr.Row(elem_id="prompt-container").style(
|
|
|
|
|
181 |
with gr.Column():
|
182 |
text = gr.Textbox(
|
183 |
label="Describe A Scene.",
|
@@ -200,7 +214,14 @@ with block:
|
|
200 |
label="Art Pieces", show_label=False, elem_id="gallery"
|
201 |
).style(grid=[2], height="auto")
|
202 |
btn.click(get_images, inputs=text, outputs=gallery, postprocess=False)
|
203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
gr.HTML(
|
205 |
"""
|
206 |
<div class="footer">
|
|
|
3 |
|
4 |
import gradio as gr
|
5 |
|
6 |
+
|
7 |
def get_images(text):
|
8 |
headers = {
|
9 |
"Content-Type": "application/json",
|
|
|
23 |
image_data = response.json()["image"]
|
24 |
for image in image_data:
|
25 |
# got this from https://huggingface.co/spaces/stabilityai/stable-diffusion/blob/main/app.py
|
26 |
+
image_b64 = f"data:image/jpeg;base64,{image}"
|
27 |
images.append(image_b64)
|
28 |
return images
|
29 |
+
|
30 |
+
|
31 |
css = """
|
32 |
.gradio-container {
|
33 |
font-family: 'IBM Plex Sans', sans-serif;
|
|
|
151 |
#component-16{border-top-width: 1px!important;margin-top: 1em}
|
152 |
.image_duplication{position: absolute; width: 100px; left: 50px}
|
153 |
"""
|
154 |
+
examples = [
|
155 |
+
"people around a dead person",
|
156 |
+
"a guard in armor",
|
157 |
+
"a father mourning for his child",
|
158 |
+
"a mother breastfeeding his son",
|
159 |
+
"pineapple",
|
160 |
+
"van eyck",
|
161 |
+
"cubism",
|
162 |
+
]
|
163 |
|
164 |
block = gr.Blocks(css=css)
|
165 |
|
|
|
181 |
</h1>
|
182 |
</div>
|
183 |
<p style="margin-bottom: 10px; font-size: 94%; line-height: 23px;">
|
184 |
+
Search the <a style="text-decoration: underline;" href="https://archive.org/details/wikiart-dataset">WikiArt dataset</a> containing 81 444 paintings.
|
185 |
+
</br>Read the article <a style="text-decoration: underline;" href="https://medium.com/@vincentclaes_43752/a110a2f5bf8e?source=friends_link&sk=cabf93a94d582ebbc53d3672cbb76a98">Searching Art through Deep Learning</a>
|
186 |
</p>
|
187 |
</div>
|
188 |
"""
|
189 |
)
|
190 |
with gr.Group():
|
191 |
with gr.Box():
|
192 |
+
with gr.Row(elem_id="prompt-container").style(
|
193 |
+
mobile_collapse=False, equal_height=True
|
194 |
+
):
|
195 |
with gr.Column():
|
196 |
text = gr.Textbox(
|
197 |
label="Describe A Scene.",
|
|
|
214 |
label="Art Pieces", show_label=False, elem_id="gallery"
|
215 |
).style(grid=[2], height="auto")
|
216 |
btn.click(get_images, inputs=text, outputs=gallery, postprocess=False)
|
217 |
+
ex = gr.Examples(
|
218 |
+
examples=examples,
|
219 |
+
fn=get_images,
|
220 |
+
inputs=text,
|
221 |
+
outputs=gallery,
|
222 |
+
cache_examples=False,
|
223 |
+
)
|
224 |
+
ex.dataset.headers = [""]
|
225 |
gr.HTML(
|
226 |
"""
|
227 |
<div class="footer">
|
pyproject.toml
CHANGED
@@ -11,8 +11,6 @@ gradio = "^3.12.0"
|
|
11 |
Pillow = "^9.3.0"
|
12 |
python-dotenv = "^0.21.0"
|
13 |
setuptools = "^65.6.3"
|
14 |
-
distribute = "^0.7.3"
|
15 |
-
|
16 |
|
17 |
[build-system]
|
18 |
requires = ["poetry-core"]
|
|
|
11 |
Pillow = "^9.3.0"
|
12 |
python-dotenv = "^0.21.0"
|
13 |
setuptools = "^65.6.3"
|
|
|
|
|
14 |
|
15 |
[build-system]
|
16 |
requires = ["poetry-core"]
|
requirements.txt
CHANGED
@@ -50,6 +50,7 @@ pytz==2022.6
|
|
50 |
PyYAML==6.0
|
51 |
requests==2.28.1
|
52 |
rfc3986==1.5.0
|
|
|
53 |
setuptools-scm==7.0.5
|
54 |
six==1.16.0
|
55 |
sniffio==1.3.0
|
|
|
50 |
PyYAML==6.0
|
51 |
requests==2.28.1
|
52 |
rfc3986==1.5.0
|
53 |
+
setuptools==65.6.3
|
54 |
setuptools-scm==7.0.5
|
55 |
six==1.16.0
|
56 |
sniffio==1.3.0
|