ExtractRunner
- class lib.infer.runner.ExtractRunner(handler: HandlerT)
Bases:
Generic[HandlerT]Runs an extract plugin
- Parameters:
handler (HandlerT) – The plugin handler that this runner will execute
Attributes Summary
The plugin handler that this runner is executing
The output queue from this plugin runner
Unique identifier for plugin ordering and multi-plugin tracking
Methods Summary
__call__(input_runner, profile)Build and start the plugin runner
flush()Flush all data currently within the pipeline
put(-> None)Put a frame into the pipeline.
put_direct(filename, image, detected_faces)Put an item directly into this runner's plugin and return the result
put_media(media)Put a frame into the pipeline that is within a FrameFaces object.
Register an external error state object.
start()Start the threads.
stop()Indicate to the runner that there is no more data to be ingested
Attributes Documentation
- handler
The plugin handler that this runner is executing
- out_queue
The output queue from this plugin runner
- uuid
Unique identifier for plugin ordering and multi-plugin tracking
Methods Documentation
- __call__(input_runner: ExtractRunner | None, profile: bool) None
Build and start the plugin runner
- Parameters:
input_runner (ExtractRunner | None) – The input plugin that feeds this plugin or
Noneif data is to be fed through the runner’s put method.profile (bool) –
Trueif the runner is to be profiled, indicating that threads will not be started
- Raises:
ValueError – If the input runner has not been called and assigned a UUID or if this runner has already been called
- Return type:
None
- flush() None
Flush all data currently within the pipeline
- Return type:
None
- put(filename: str, image: ndarray[tuple[Any, ...], dtype[uint8]], detected_faces: list[DetectedFace] | None = None, source: str | None = None, is_aligned: bool = False, frame_metadata: PNGSource | None = None, passthrough: Literal[False] = False) None
- put(filename: str, image: ndarray[tuple[Any, ...], dtype[uint8]], detected_faces: list[DetectedFace] | None = None, source: str | None = None, is_aligned: bool = False, frame_metadata: PNGSource | None = None, *, passthrough: Literal[True]) FrameFaces
Put a frame into the pipeline.
Note
When a pipeline is built using the __call__ method, this method will always put items into the first plugin in the pipeline
- Parameters:
filename (str) – The filename of the frame
image (npt.NDArray[np.uint8]) – The loaded frame as UINT8 BGR array
detected_faces (list[DetectedFace] | None) – The detected face objects for the frame.
Noneif not any. Default:Nonesource (str | None) – The full path to the source folder or video file. Default:
None(Not provided)is_aligned (bool) –
Trueif the image being passed into the pipeline is an aligned faceswap face. Default:Falseframe_metadata (PNGSource | None) – If the image is aligned then the original frame metadata can be added here. Some plugins (eg: mask) require this to be populated for aligned inputs. Default:
Nonepassthrough (bool) –
Trueif this item is meant to be passed straight through the extraction pipeline with no caching, for immediate return. Default:False
- Return type:
If passthrough is
Truereturns the output FrameFaces object, otherwiseNone
- put_direct(filename: str, image: npt.NDArray[np.uint8], detected_faces: list[DetectedFace], is_aligned: bool = False, frame_size: tuple[int, int] | None = None) ExtractBatch
Put an item directly into this runner’s plugin and return the result
- Parameters:
filename (str) – The filename of the frame
image (npt.NDArray[np.uint8]) – The loaded frame as UINT8 BGR array
detected_faces (list[DetectedFace]) – The detected face objects for the frame
is_aligned (bool) –
Trueif the image being passed into the pipeline is an aligned faceswap face. Default:Falseframe_size (tuple[int, int] | None) – The (height, width) size of the original frame if passing in an aligned image
- Raises:
ValueError – If attempting to put an ExtractBatch object to the first runner in the pipeline or if providing an aligned image with insufficient data
- Returns:
The output from this plugin for the given input
- Return type:
- put_media(media: FrameFaces) None | FrameFaces
Put a frame into the pipeline that is within a FrameFaces object.
Note
When a pipeline is built using the __call__ method, this method will always put items into the first plugin in the pipeline
- Parameters:
media (FrameFaces) – The FrameFaces object to put into the pipeline
- Returns:
If the FrameFaces’s passthrough is
Truereturns the output FrameFaces object,otherwise
None
- Return type:
None | FrameFaces
- register_external_error_state(state: ErrorState) None
Register an external error state object.
If we are not running any threads (specifically, file handler), the pipeline can hang the calling thread. The error state from the calling thread can be populated here. This can only be called if no threads have been registered for the runner
- Parameters:
state (ErrorState) – The ErrorState object to register
- Return type:
None
- start() None
Start the threads. Callback for when the profiler has finished executing
- Return type:
None
- stop() None
Indicate to the runner that there is no more data to be ingested
- Return type:
None
- __call__(input_runner: ExtractRunner | None, profile: bool) None
Build and start the plugin runner
- Parameters:
input_runner (ExtractRunner | None) – The input plugin that feeds this plugin or
Noneif data is to be fed through the runner’s put method.profile (bool) –
Trueif the runner is to be profiled, indicating that threads will not be started
- Raises:
ValueError – If the input runner has not been called and assigned a UUID or if this runner has already been called
- Return type:
None
- __next__() FrameFaces
Obtain the next item from the plugin’s output
- Return type:
The media object with populated detected faces for a frame
- flush() None
Flush all data currently within the pipeline
- Return type:
None
- property out_queue: Queue[ExtractBatch]
The output queue from this plugin runner
- put(filename: str, image: ndarray[tuple[Any, ...], dtype[uint8]], detected_faces: list[DetectedFace] | None = None, source: str | None = None, is_aligned: bool = False, frame_metadata: PNGSource | None = None, passthrough: Literal[False] = False) None
- put(filename: str, image: ndarray[tuple[Any, ...], dtype[uint8]], detected_faces: list[DetectedFace] | None = None, source: str | None = None, is_aligned: bool = False, frame_metadata: PNGSource | None = None, *, passthrough: Literal[True]) FrameFaces
Put a frame into the pipeline.
Note
When a pipeline is built using the __call__ method, this method will always put items into the first plugin in the pipeline
- Parameters:
filename (str) – The filename of the frame
image (npt.NDArray[np.uint8]) – The loaded frame as UINT8 BGR array
detected_faces (list[DetectedFace] | None) – The detected face objects for the frame.
Noneif not any. Default:Nonesource (str | None) – The full path to the source folder or video file. Default:
None(Not provided)is_aligned (bool) –
Trueif the image being passed into the pipeline is an aligned faceswap face. Default:Falseframe_metadata (PNGSource | None) – If the image is aligned then the original frame metadata can be added here. Some plugins (eg: mask) require this to be populated for aligned inputs. Default:
Nonepassthrough (bool) –
Trueif this item is meant to be passed straight through the extraction pipeline with no caching, for immediate return. Default:False
- Return type:
If passthrough is
Truereturns the output FrameFaces object, otherwiseNone
- put_direct(filename: str, image: npt.NDArray[np.uint8], detected_faces: list[DetectedFace], is_aligned: bool = False, frame_size: tuple[int, int] | None = None) ExtractBatch
Put an item directly into this runner’s plugin and return the result
- Parameters:
filename (str) – The filename of the frame
image (npt.NDArray[np.uint8]) – The loaded frame as UINT8 BGR array
detected_faces (list[DetectedFace]) – The detected face objects for the frame
is_aligned (bool) –
Trueif the image being passed into the pipeline is an aligned faceswap face. Default:Falseframe_size (tuple[int, int] | None) – The (height, width) size of the original frame if passing in an aligned image
- Raises:
ValueError – If attempting to put an ExtractBatch object to the first runner in the pipeline or if providing an aligned image with insufficient data
- Returns:
The output from this plugin for the given input
- Return type:
- put_media(media: FrameFaces) None | FrameFaces
Put a frame into the pipeline that is within a FrameFaces object.
Note
When a pipeline is built using the __call__ method, this method will always put items into the first plugin in the pipeline
- Parameters:
media (FrameFaces) – The FrameFaces object to put into the pipeline
- Returns:
If the FrameFaces’s passthrough is
Truereturns the output FrameFaces object,otherwise
None
- Return type:
None | FrameFaces
- register_external_error_state(state: ErrorState) None
Register an external error state object.
If we are not running any threads (specifically, file handler), the pipeline can hang the calling thread. The error state from the calling thread can be populated here. This can only be called if no threads have been registered for the runner
- Parameters:
state (ErrorState) – The ErrorState object to register
- Return type:
None
- start() None
Start the threads. Callback for when the profiler has finished executing
- Return type:
None
- stop() None
Indicate to the runner that there is no more data to be ingested
- Return type:
None
- property uuid: str
Unique identifier for plugin ordering and multi-plugin tracking