Abubakar Abid commited on
Commit
139d801
1 Parent(s): adcb063

Update app_gradio.py

Browse files
Files changed (1) hide show
  1. app/app_gradio.py +4 -22
app/app_gradio.py CHANGED
@@ -139,42 +139,24 @@ def run_inference(prompt, num_images=32, num_preds=8):
139
  images = top_k_predictions(prompt, num_candidates=num_images, k=num_preds)
140
  predictions = compose_predictions(images)
141
  output_title = f"""
142
- <p style="font-size:22px; font-style:bold">Best predictions</p>
143
- <p>We asked our model to generate 32 candidates for your prompt:</p>
144
-
145
- <pre>
146
-
147
  <b>{prompt}</b>
148
- </pre>
149
- <p>We then used a pre-trained <a href="https://huggingface.co/openai/clip-vit-base-patch32">CLIP model</a> to score them according to the
150
- similarity of the text and the image representations.</p>
151
-
152
- <p>This is the result:</p>
153
  """
154
- output_description = """
155
- <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>
156
- <p style='text-align: center'>Created with <a href="https://github.com/borisdayma/dalle-mini">DALLE·mini</a></p>
157
- """
158
- return (output_title, predictions, output_description)
159
 
160
  outputs = [
161
  gr.outputs.HTML(label=""), # To be used as title
162
  gr.outputs.Image(label=''),
163
- gr.outputs.HTML(label=""), # Additional text that appears in the screenshot
164
  ]
165
 
166
  description = """
167
- Welcome to our demo of DALL·E-mini. This project was created on TPU v3-8s during the 🤗 Flax / JAX Community Week.
168
- It reproduces the essential characteristics of OpenAI's DALL·E, at a fraction of the size.
169
-
170
- Please, write what you would like the model to generate, or select one of the examples below.
171
  """
172
  gr.Interface(run_inference,
173
- 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')],
174
  outputs=outputs,
175
  title='DALL·E mini',
176
  description=description,
177
- article="<p style='text-align: center'> DALLE·mini by Boris Dayma et al. | <a href='https://github.com/borisdayma/dalle-mini'>GitHub</a></p>",
178
  layout='vertical',
179
  theme='huggingface',
180
  examples=[['an armchair in the shape of an avocado'], ['snowy mountains by the sea']],
 
139
  images = top_k_predictions(prompt, num_candidates=num_images, k=num_preds)
140
  predictions = compose_predictions(images)
141
  output_title = f"""
 
 
 
 
 
142
  <b>{prompt}</b>
 
 
 
 
 
143
  """
144
+ return (output_title, predictions)
 
 
 
 
145
 
146
  outputs = [
147
  gr.outputs.HTML(label=""), # To be used as title
148
  gr.outputs.Image(label=''),
 
149
  ]
150
 
151
  description = """
152
+ DALL·E-mini is an AI model that generates images from any prompt you give! Generate images from text:
 
 
 
153
  """
154
  gr.Interface(run_inference,
155
+ inputs=[gr.inputs.Textbox(label='What do you want to see?')], #, gr.inputs.Slider(1,64,1,8, label='Candidates to generate'), gr.inputs.Slider(1,8,1,1, label='Best predictions to show')],
156
  outputs=outputs,
157
  title='DALL·E mini',
158
  description=description,
159
+ article="<p style='text-align: center'> Created by Boris Dayma et al. 2021 | <a href='https://github.com/borisdayma/dalle-mini'>GitHub</a> | <a href='https://wandb.ai/dalle-mini/dalle-mini/reports/DALL-E-mini--Vmlldzo4NjIxODA'>Report</a></p>",
160
  layout='vertical',
161
  theme='huggingface',
162
  examples=[['an armchair in the shape of an avocado'], ['snowy mountains by the sea']],