Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a new class, ImageGenerator, designed to asynchronously generate images using a server-side model. The images are generated based on input prompts, which are provided via a JSON file. The class handles the communication with the server through WebSocket connections, processes the generated images, and uploads them to an S3 bucket. The process involves the following key steps:
Loading and Queuing Prompts:
Prompts are loaded from a specified JSON file.
The prompts are queued for execution on the server, where they are processed asynchronously.
Asynchronous Image Retrieval:
The class listens for image data sent from the server via WebSocket.
The image data is retrieved in real-time, ensuring efficient handling of image generation tasks.
S3 Upload Integration:
The first generated image is uploaded to an S3 bucket using the upload_file_to_s3_binary utility.
The S3 URL of the uploaded image is returned, allowing easy access to the generated image.
Key Features:
Asynchronous Processing: Utilizes asyncio to handle WebSocket communication and image processing concurrently, ensuring non-blocking execution.
WebSocket Communication: Establishes a WebSocket connection to receive real-time updates and images from the server.
Dynamic Prompt Handling: Allows dynamic modification of image URLs within the prompt before sending it to the server.
S3 Upload Capability: Automatically uploads the generated image to an S3 bucket and returns the accessible URL.
Usage Example:
A sample usage has been included in the code, demonstrating how to instantiate the ImageGenerator class, queue a prompt, generate an image, and upload it to S3.
Next Steps: