Spaces:
Runtime error
Runtime error
Commit
Β·
cbddee5
1
Parent(s):
d147789
update
Browse files
app.py
CHANGED
@@ -269,6 +269,8 @@ def text_to_image(prompt,keywords,slider_step,slider_guidance,slider_batch,slide
|
|
269 |
prompt = caption_ids + ocr_ids
|
270 |
except:
|
271 |
prompt = caption_ids
|
|
|
|
|
272 |
|
273 |
else:
|
274 |
user_prompt += ' <|endoftext|>'
|
@@ -291,6 +293,7 @@ def text_to_image(prompt,keywords,slider_step,slider_guidance,slider_batch,slide
|
|
291 |
text_str = ' '.join([f'[{c}]' for c in list(text)])
|
292 |
user_prompt += f'<|startoftext|> l{x0} t{y0} r{x1} b{y1} {text_str} <|endoftext|>'
|
293 |
|
|
|
294 |
prompt = tokenizer.encode(user_prompt)
|
295 |
|
296 |
prompt = prompt[:77]
|
@@ -339,7 +342,7 @@ def text_to_image(prompt,keywords,slider_step,slider_guidance,slider_batch,slide
|
|
339 |
# new_image.save(f'{args.output_dir}/pred_img_{sample_index}_{args.local_rank}.jpg')
|
340 |
results.insert(0, new_image)
|
341 |
# return new_image
|
342 |
-
return tuple(
|
343 |
|
344 |
with gr.Blocks() as demo:
|
345 |
|
@@ -401,6 +404,10 @@ with gr.Blocks() as demo:
|
|
401 |
|
402 |
with gr.Column(scale=1):
|
403 |
output = gr.Gallery(label='Generated image')
|
|
|
|
|
|
|
|
|
404 |
|
405 |
# with gr.Accordion("Intermediate results", open=False):
|
406 |
# gr.Markdown("Layout, segmentation mask, and details of segmentation mask from left to right.")
|
@@ -408,9 +415,19 @@ with gr.Blocks() as demo:
|
|
408 |
|
409 |
# gr.Markdown("## Prompt Examples")
|
410 |
|
411 |
-
button.click(text_to_image, inputs=[prompt,keywords,slider_step,slider_guidance,slider_batch,slider_temperature], outputs=[output])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
|
413 |
-
|
414 |
|
415 |
|
416 |
gr.HTML(
|
|
|
269 |
prompt = caption_ids + ocr_ids
|
270 |
except:
|
271 |
prompt = caption_ids
|
272 |
+
|
273 |
+
composed_prompt = tokenizer.decode(prompt)
|
274 |
|
275 |
else:
|
276 |
user_prompt += ' <|endoftext|>'
|
|
|
293 |
text_str = ' '.join([f'[{c}]' for c in list(text)])
|
294 |
user_prompt += f'<|startoftext|> l{x0} t{y0} r{x1} b{y1} {text_str} <|endoftext|>'
|
295 |
|
296 |
+
composed_prompt = user_prompt
|
297 |
prompt = tokenizer.encode(user_prompt)
|
298 |
|
299 |
prompt = prompt[:77]
|
|
|
342 |
# new_image.save(f'{args.output_dir}/pred_img_{sample_index}_{args.local_rank}.jpg')
|
343 |
results.insert(0, new_image)
|
344 |
# return new_image
|
345 |
+
return tuple(results), composed_prompt
|
346 |
|
347 |
with gr.Blocks() as demo:
|
348 |
|
|
|
404 |
|
405 |
with gr.Column(scale=1):
|
406 |
output = gr.Gallery(label='Generated image')
|
407 |
+
|
408 |
+
with gr.Accordion("Intermediate results", open=False):
|
409 |
+
gr.Markdown("Composed prompt")
|
410 |
+
composed_prompt = gr.Textbox(label='')
|
411 |
|
412 |
# with gr.Accordion("Intermediate results", open=False):
|
413 |
# gr.Markdown("Layout, segmentation mask, and details of segmentation mask from left to right.")
|
|
|
415 |
|
416 |
# gr.Markdown("## Prompt Examples")
|
417 |
|
418 |
+
button.click(text_to_image, inputs=[prompt,keywords,slider_step,slider_guidance,slider_batch,slider_temperature], outputs=[output, composed_prompt])
|
419 |
+
|
420 |
+
gr.Markdown("## Prompt Examples")
|
421 |
+
gr.Examples(
|
422 |
+
[
|
423 |
+
["A beautiful city skyline stamp of Shanghai", ""],
|
424 |
+
["A book cover named summer vibe", ""],
|
425 |
+
],
|
426 |
+
prompt,
|
427 |
+
keywords,
|
428 |
+
examples_per_page=10
|
429 |
+
)
|
430 |
|
|
|
431 |
|
432 |
|
433 |
gr.HTML(
|