FacesDisplay

class tools.preview.viewer.FacesDisplay(app: Preview, size: int, padding: int, num_faces: int)

Bases: object

Compiles the 2 rows of sample faces (original and swapped) into a single image

Parameters:
  • app (Preview) – The main tkinter Preview app

  • size (int) – The size of each individual face sample in pixels

  • padding (int) – The amount of extra padding to apply to the outside of the face

  • num_faces (int) – The number of faces to be displayed in the preview window

Attributes Summary

tk_image

The compiled preview display in tkinter display format

Methods Summary

set_centering_offset(centering, y_offset)

The centering and y-offset that the model uses is not known at initialization time.

set_display_dimensions(dimensions)

Adjust the size of the frame that will hold the preview samples.

update_tk_image()

Build the full preview images and compile tk_image for display.

Attributes Documentation

tk_image

The compiled preview display in tkinter display format

Methods Documentation

set_centering_offset(centering: Literal['face', 'head', 'legacy'], y_offset: float) None

The centering and y-offset that the model uses is not known at initialization time. Set _centering and y_offset when the model has been loaded.

Parameters:
  • centering (Literal['face', 'head', 'legacy']) – The centering that the model was trained on

  • y_offset (float)

Return type:

None

set_display_dimensions(dimensions: tuple[int, int]) None

Adjust the size of the frame that will hold the preview samples.

Parameters:

dimensions (tuple[int, int]) – The (width, height) of the frame that holds the preview

Return type:

None

update_tk_image() None

Build the full preview images and compile tk_image for display.

Return type:

None

destination: list[ndarray]

The list of numpy.ndarray swapped and patched preview images for bottom row of display

set_centering_offset(centering: Literal['face', 'head', 'legacy'], y_offset: float) None

The centering and y-offset that the model uses is not known at initialization time. Set _centering and y_offset when the model has been loaded.

Parameters:
  • centering (Literal['face', 'head', 'legacy']) – The centering that the model was trained on

  • y_offset (float)

Return type:

None

set_display_dimensions(dimensions: tuple[int, int]) None

Adjust the size of the frame that will hold the preview samples.

Parameters:

dimensions (tuple[int, int]) – The (width, height) of the frame that holds the preview

Return type:

None

source: list[ConvertItem]

The list of numpy.ndarray source preview images for top row of display

property tk_image: PhotoImage | None

The compiled preview display in tkinter display format

update_source: bool

Flag to indicate that the source images for the preview have been updated, so the preview should be recompiled.

update_tk_image() None

Build the full preview images and compile tk_image for display.

Return type:

None