plugin_loader module

Plugin loader for Faceswap extract, training and convert tasks

class plugins.plugin_loader.PluginLoader

Bases: object

Retrieve, or get information on, Faceswap plugins

Return a specific plugin, list available plugins, or get the default plugin for a task.

Example

>>> from plugins.plugin_loader import PluginLoader
>>> align_plugins = PluginLoader.get_available_extractors('align')
>>> aligner = PluginLoader.get_aligner('cv2-dnn')
static get_aligner(name, disable_logging=False)

Return requested aligner plugin

Parameters:
  • name (str) – The name of the requested aligner plugin
  • disable_logging (bool, optional) – Whether to disable the INFO log message that the plugin is being imported. Default: False
Returns:

An extraction aligner plugin

Return type:

plugins.extract.align object

static get_available_convert_plugins(convert_category, add_none=True)

Return a list of available converter plugins in the given category

Parameters:
  • convert_category ({'color', 'mask', 'scaling', 'writer'}) – The category of converter plugin to return the plugins for
  • add_none (bool, optional) – Append “none” to the list of returned plugins. Default: True
Returns:

A list of the available converter plugin names in the given category

Return type:

list

static get_available_extractors(extractor_type, add_none=False)

Return a list of available extractors of the given type

Parameters:
  • extractor_type ({'aligner', 'detector', 'masker'}) – The type of extractor to return the plugins for
  • add_none (bool, optional) – Append “none” to the list of returned plugins. Default: False
Returns:

A list of the available extractor plugin names for the given type

Return type:

list

static get_available_models()

Return a list of available training models

Returns:A list of the available training model plugin names
Return type:list
static get_converter(category, name, disable_logging=False)

Return requested converter plugin

Converters work slightly differently to other faceswap plugins. They are created to do a specific task (e.g. color adjustment, mask blending etc.), so multiple plugins will be loaded in the convert phase, rather than just one plugin for the other phases.

Parameters:
  • name (str) – The name of the requested converter plugin
  • disable_logging (bool, optional) – Whether to disable the INFO log message that the plugin is being imported. Default: False
Returns:

A converter sub plugin

Return type:

plugins.convert object

static get_default_model()

Return the default training model plugin name

Returns:The default faceswap training model
Return type:str
static get_detector(name, disable_logging=False)

Return requested detector plugin

Parameters:
  • name (str) – The name of the requested detector plugin
  • disable_logging (bool, optional) – Whether to disable the INFO log message that the plugin is being imported. Default: False
Returns:

An extraction detector plugin

Return type:

plugins.extract.detect object

static get_masker(name, disable_logging=False)

Return requested masker plugin

Parameters:
  • name (str) – The name of the requested masker plugin
  • disable_logging (bool, optional) – Whether to disable the INFO log message that the plugin is being imported. Default: False
Returns:

An extraction masker plugin

Return type:

plugins.extract.mask object

static get_model(name, disable_logging=False)

Return requested training model plugin

Parameters:
  • name (str) – The name of the requested training model plugin
  • disable_logging (bool, optional) – Whether to disable the INFO log message that the plugin is being imported. Default: False
Returns:

A training model plugin

Return type:

plugins.train.model object

static get_trainer(name, disable_logging=False)

Return requested training trainer plugin

Parameters:
  • name (str) – The name of the requested training trainer plugin
  • disable_logging (bool, optional) – Whether to disable the INFO log message that the plugin is being imported. Default: False
Returns:

A training trainer plugin

Return type:

plugins.train.trainer object