Spaces:
Build error
Build error
Add padding between images
Browse files
app.py
CHANGED
@@ -124,21 +124,20 @@ def generate_for_prompt(input_text, state, ret_scale_factor, max_num_rets, num_w
|
|
124 |
im_names = []
|
125 |
response = ''
|
126 |
text_outputs = []
|
127 |
-
for output in model_outputs:
|
128 |
if type(output) == str:
|
|
|
|
|
129 |
text_outputs.append(output)
|
130 |
-
|
|
|
131 |
elif type(output) == list:
|
132 |
-
response += '<br/>' # Add line break between images.
|
133 |
for image in output:
|
134 |
filename = save_image_to_local(image)
|
135 |
response += f'<img src="/file={filename}" style="display: inline-block;">'
|
136 |
-
response += '<br/>'
|
137 |
elif type(output) == Image.Image:
|
138 |
filename = save_image_to_local(output)
|
139 |
-
response += '<br/>'
|
140 |
response += f'<img src="/file={filename}" style="display: inline-block;">'
|
141 |
-
response += '<br/>'
|
142 |
|
143 |
# TODO(jykoh): Persist image inputs.
|
144 |
chat_history = model_inputs + \
|
@@ -188,7 +187,7 @@ with gr.Blocks(css=css) as demo:
|
|
188 |
ret_scale_factor = gr.Slider(minimum=0.0, maximum=3.0, value=1.0, step=0.1, interactive=True,
|
189 |
label="Frequency multiplier for returning images (higher means more frequent)")
|
190 |
max_ret_images = gr.Number(
|
191 |
-
minimum=0, maximum=3, value=
|
192 |
gr_max_len = gr.Slider(minimum=1, maximum=64, value=32,
|
193 |
step=1, interactive=True, label="Max # of words returned")
|
194 |
gr_temperature = gr.Slider(
|
|
|
124 |
im_names = []
|
125 |
response = ''
|
126 |
text_outputs = []
|
127 |
+
for output_i, output in enumerate(model_outputs):
|
128 |
if type(output) == str:
|
129 |
+
if output_i > 0:
|
130 |
+
response += '<br/>'
|
131 |
text_outputs.append(output)
|
132 |
+
if len(model_outputs) > 1:
|
133 |
+
response += output + '<br/>'
|
134 |
elif type(output) == list:
|
|
|
135 |
for image in output:
|
136 |
filename = save_image_to_local(image)
|
137 |
response += f'<img src="/file={filename}" style="display: inline-block;">'
|
|
|
138 |
elif type(output) == Image.Image:
|
139 |
filename = save_image_to_local(output)
|
|
|
140 |
response += f'<img src="/file={filename}" style="display: inline-block;">'
|
|
|
141 |
|
142 |
# TODO(jykoh): Persist image inputs.
|
143 |
chat_history = model_inputs + \
|
|
|
187 |
ret_scale_factor = gr.Slider(minimum=0.0, maximum=3.0, value=1.0, step=0.1, interactive=True,
|
188 |
label="Frequency multiplier for returning images (higher means more frequent)")
|
189 |
max_ret_images = gr.Number(
|
190 |
+
minimum=0, maximum=3, value=2, precision=1, interactive=True, label="Max images to return")
|
191 |
gr_max_len = gr.Slider(minimum=1, maximum=64, value=32,
|
192 |
step=1, interactive=True, label="Max # of words returned")
|
193 |
gr_temperature = gr.Slider(
|