Spaces:
Running
Running
Pedro Cuenca
commited on
Commit
·
8944cc5
1
Parent(s):
f68e37a
Attempts to tweak the UI.
Browse filesBrief description of the process.
Link to report.
Former-commit-id: 6976c64d585a732f04203bbdd8bf0a96282e0cae
- app/ui_gradio.py +25 -4
app/ui_gradio.py
CHANGED
|
@@ -43,21 +43,42 @@ def top_k_predictions(prompt, num_candidates=32, k=8):
|
|
| 43 |
def run_inference(prompt, num_images=32, num_preds=8):
|
| 44 |
images = top_k_predictions(prompt, num_candidates=num_images, k=num_preds)
|
| 45 |
predictions = compose_predictions(images)
|
| 46 |
-
output_title =
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
return (output_title, predictions, output_description)
|
| 49 |
|
| 50 |
outputs = [
|
| 51 |
gr.outputs.HTML(label=""), # To be used as title
|
| 52 |
-
gr.outputs.Image(label='
|
| 53 |
gr.outputs.HTML(label=""), # Additional text that appears in the screenshot
|
| 54 |
]
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
gr.Interface(run_inference,
|
| 57 |
inputs=[gr.inputs.Textbox(label='Prompt')], #, gr.inputs.Slider(1,64,1,8, label='Candidates to generate'), gr.inputs.Slider(1,8,1,1, label='Best predictions to show')],
|
| 58 |
outputs=outputs,
|
| 59 |
title='DALL·E mini',
|
| 60 |
-
description=
|
| 61 |
article="<p style='text-align: center'> DALLE·mini by Boris Dayma et al. | <a href='https://github.com/borisdayma/dalle-mini'>GitHub</a></p>",
|
| 62 |
layout='vertical',
|
| 63 |
theme='huggingface',
|
|
|
|
| 43 |
def run_inference(prompt, num_images=32, num_preds=8):
|
| 44 |
images = top_k_predictions(prompt, num_candidates=num_images, k=num_preds)
|
| 45 |
predictions = compose_predictions(images)
|
| 46 |
+
output_title = f"""
|
| 47 |
+
<p style="font-size:22px; font-style:bold">Best predictions</p>
|
| 48 |
+
<p>We asked our model to generate 32 candidates for your prompt:</p>
|
| 49 |
+
|
| 50 |
+
<pre>
|
| 51 |
+
|
| 52 |
+
<b>{prompt}</b>
|
| 53 |
+
</pre>
|
| 54 |
+
<p>We then used a pre-trained CLIP model to score them according to the
|
| 55 |
+
similarity of their text and image representations.</p>
|
| 56 |
+
|
| 57 |
+
<p>This is the result:</p>
|
| 58 |
+
"""
|
| 59 |
+
output_description = """
|
| 60 |
+
<p>Read more about the process <a href="https://wandb.ai/dalle-mini/dalle-mini/reports/DALL-E-mini--Vmlldzo4NjIxODA">in our report</a>.<p>
|
| 61 |
+
<p style='text-align: center'>Created with <a href="https://github.com/borisdayma/dalle-mini">DALLE·mini</a></p>
|
| 62 |
+
"""
|
| 63 |
return (output_title, predictions, output_description)
|
| 64 |
|
| 65 |
outputs = [
|
| 66 |
gr.outputs.HTML(label=""), # To be used as title
|
| 67 |
+
gr.outputs.Image(label=''),
|
| 68 |
gr.outputs.HTML(label=""), # Additional text that appears in the screenshot
|
| 69 |
]
|
| 70 |
|
| 71 |
+
description = """
|
| 72 |
+
Welcome to our demo of DALL·E-mini. This project was created on TPU v3-8s during the 🤗 Flax / JAX Community Week.
|
| 73 |
+
It reproduces the essential characteristics of OpenAI's DALL·E, at a fraction of the size.
|
| 74 |
+
|
| 75 |
+
Please, write what you would like the model to generate, or select one of the examples below.
|
| 76 |
+
"""
|
| 77 |
gr.Interface(run_inference,
|
| 78 |
inputs=[gr.inputs.Textbox(label='Prompt')], #, gr.inputs.Slider(1,64,1,8, label='Candidates to generate'), gr.inputs.Slider(1,8,1,1, label='Best predictions to show')],
|
| 79 |
outputs=outputs,
|
| 80 |
title='DALL·E mini',
|
| 81 |
+
description=description,
|
| 82 |
article="<p style='text-align: center'> DALLE·mini by Boris Dayma et al. | <a href='https://github.com/borisdayma/dalle-mini'>GitHub</a></p>",
|
| 83 |
layout='vertical',
|
| 84 |
theme='huggingface',
|