Skip to main content

PrefetchReader

A threaded image prefetch reader for efficient batch processing.

Parameters

list[str]
required
A list of image file paths to be read
int
required
Number of images to prefetch in the queue

Methods

run()

Starts the prefetch thread. Reads images from the list and puts them in the queue.

next()

Returns the next prefetched image from the queue. Returns: numpy.ndarray - The next image in BGR format Raises: StopIteration when no more images are available

iter()

Returns the iterator object (self).

Usage Example

The PrefetchReader uses threading to read images asynchronously, which can significantly improve performance when processing large batches of images by overlapping I/O and computation.

IOConsumer

A threaded consumer for asynchronous image writing operations.

Parameters

object
required
Options object containing configuration parameters
queue.Queue
required
Queue object for receiving write tasks
int
required
Worker ID for the consumer thread

Methods

run()

Runs the consumer loop. Continuously reads messages from the queue and writes images to disk. Message format:
To stop the consumer, send the string 'quit' to the queue.

Usage Example

The IOConsumer allows you to offload disk I/O operations to a separate thread, preventing write operations from blocking your main processing pipeline. This is especially useful when processing large batches of high-resolution images.

Constants

ROOT_DIR

The root directory of the Real-ESRGAN package.
Type: str Value: The directory containing the Real-ESRGAN package (parent directory of realesrgan/)