Spaces:
Runtime error
Runtime error
Added History (#16)
Browse files- Added History (34b60b092babdbb43e22aecbe12237b4083deaba)
- no need for this (664901dded1c7625b045deb078911a1693a917f3)
Co-authored-by: Nishith Jain <KingNish@users.noreply.huggingface.co>
200 unmodified lines20120220320420520620720820921021121221394 unmodified lines30830931031131231332 unmodified lines346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380200 unmodified linesdef toggle_custom_resize_slider(resize_option):return gr.update(visible=(resize_option == "Custom"))css = """.gradio-container {width: 1200px !important;}"""title = """<h1 align="center">Diffusers Image Outpaint</h1><div align="center">Drop an image you would like to extend, pick your expected ratio and hit Generate.</div><div style="display: flex; justify-content: center; align-items: center; text-align: center;">94 unmodified lines)use_as_input_button = gr.Button("Use as Input Image", visible=False)def use_output_as_input(output_image):"""Sets the generated output as the new input image."""return gr.update(value=output_image[1])32 unmodified linesqueue=False)run_button.click(fn=clear_result,inputs=None,outputs=result,).then(fn=infer,inputs=[input_image, width_slider, height_slider, overlap_width, num_inference_steps,resize_option, custom_resize_size, prompt_input, alignment_dropdown],outputs=result,).then(fn=lambda: gr.update(visible=True),inputs=None,outputs=use_as_input_button,)prompt_input.submit(fn=clear_result,inputs=None,outputs=result,).then(fn=infer,inputs=[input_image, width_slider, height_slider, overlap_width, num_inference_steps,resize_option, custom_resize_size, prompt_input, alignment_dropdown],outputs=result,).then(fn=lambda: gr.update(visible=True),inputs=None,outputs=use_as_input_button,)demo.queue(max_size=12).launch(share=False)200 unmodified lines20120220320420520620720820921021121221321421521621721821994 unmodified lines31431531631731831932032132 unmodified lines354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395200 unmodified linesdef toggle_custom_resize_slider(resize_option):return gr.update(visible=(resize_option == "Custom"))def update_history(new_image, history):"""Updates the history gallery with the new image."""if history is None:history = []history.insert(0, new_image)return historycss = """.gradio-container {width: 1200px !important;}"""title = """<h1 align="center">Diffusers Image Outpaint</h1><div align="center">Drop an image you would like to extend, pick your expected ratio and hit Generate.</div><div style="display: flex; justify-content: center; align-items: center; text-align: center;">94 unmodified lines)use_as_input_button = gr.Button("Use as Input Image", visible=False)history_gallery = gr.Gallery(label="History", columns=6, object_fit="contain")def use_output_as_input(output_image):"""Sets the generated output as the new input image."""return gr.update(value=output_image[1])32 unmodified linesqueue=False)run_button.click( # Clear the resultfn=clear_result,inputs=None,outputs=result,).then( # Generate the new imagefn=infer,inputs=[input_image, width_slider, height_slider, overlap_width, num_inference_steps,resize_option, custom_resize_size, prompt_input, alignment_dropdown],outputs=result,).then( # Update the history galleryfn=lambda x, history: update_history(x[1], history),inputs=[result, history_gallery],outputs=history_gallery,).then( # Show the "Use as Input Image" buttonfn=lambda: gr.update(visible=True),inputs=None,outputs=use_as_input_button,)prompt_input.submit( # Clear the resultfn=clear_result,inputs=None,outputs=result,).then( # Generate the new imagefn=infer,inputs=[input_image, width_slider, height_slider, overlap_width, num_inference_steps,resize_option, custom_resize_size, prompt_input, alignment_dropdown],outputs=result,).then( # Update the history galleryfn=lambda x, history: update_history(x[1], history),inputs=[result, history_gallery],outputs=history_gallery,).then( # Show the "Use as Input Image" buttonfn=lambda: gr.update(visible=True),inputs=None,outputs=use_as_input_button,)demo.queue(max_size=12).launch(share=False)
app.py+23-8