Category

Prototyping

Concurrent Image Generation.

Prototyping

Introduction

With the image generation functionality fully integrated into the tool, I found a performance problem. If a user wanted to generate more than one image, the process took quite a bit of time because the system would wait for the first image to finish generating before starting on the next one. This created a bottleneck and caused longer wait times and a worse user experience. I needed to find a way to optimize this to make it quicker and more efficient for users who wanted to generate multiple images.

Abstract

To fix this problem the solution was quite simple: concurrent image generation. By enabling the backend to generate multiple images at the same time, the tool could complete the image generation in around the same amount of time, no matter the number of images requested. This would greatly reduce the wait time for users who needed to generate multiple images at once.

For example, generating a single image takes around 20 seconds. If a user wanted to generate five images, they would need to wait around a minute and a half. By implementing concurrent processing the total time taken to generate all five images would stay close to 20 seconds.

Luckily Python offers a package called Asyncio that allows functions to run concurrently. I split the image generation function into a smaller, single function called process_single_image. I then used Asyncio to call this function as many times as needed, based on the number of images the user wanted to generate. This way, all image generation tasks would start at the same time.

Prompts

Here’s a simplified overview of how this concurrency improves image generation times:

Concurrent Generation table

This concurrency greatly improved the efficiency of the tool which makes it much faster for users to get all their images generated.

Conclusion

Implementing concurrent image generation was another good improvement for the tool that greatly reduced the time required to generate multiple images. This feature both sped up the overall image generation process and improved the user experience by minimizing wait times. Because of this, users could now generate pages with multiple images much more quickly which makes the tool more efficient and user friendly.

Luuk Briels - 467020 - Media Design

Luuk Briels - 467020 - Media Design

Luuk Briels - 467020 - Media Design