How to use disable_logging method in localstack

Best Python code snippet using localstack_python

plugin_loader.py

Source:plugin_loader.py Github

copy

Full Screen

1#!/usr/bin/env python32""" Plugin loader for Faceswap extract, training and convert tasks """3import logging4import os5from importlib import import_module6logger = logging.getLogger(__name__) # pylint: disable=invalid-name7class PluginLoader():8 """ Retrieve, or get information on, Faceswap plugins9 Return a specific plugin, list available plugins, or get the default plugin for a10 task.11 Example12 -------13 >>> from plugins.plugin_loader import PluginLoader14 >>> align_plugins = PluginLoader.get_available_extractors('align')15 >>> aligner = PluginLoader.get_aligner('cv2-dnn')16 """17 @staticmethod18 def get_detector(name, disable_logging=False):19 """ Return requested detector plugin20 Parameters21 ----------22 name: str23 The name of the requested detector plugin24 disable_logging: bool, optional25 Whether to disable the INFO log message that the plugin is being imported.26 Default: `False`27 Returns28 -------29 :class:`plugins.extract.detect` object:30 An extraction detector plugin31 """32 return PluginLoader._import("extract.detect", name, disable_logging)33 @staticmethod34 def get_aligner(name, disable_logging=False):35 """ Return requested aligner plugin36 Parameters37 ----------38 name: str39 The name of the requested aligner plugin40 disable_logging: bool, optional41 Whether to disable the INFO log message that the plugin is being imported.42 Default: `False`43 Returns44 -------45 :class:`plugins.extract.align` object:46 An extraction aligner plugin47 """48 return PluginLoader._import("extract.align", name, disable_logging)49 @staticmethod50 def get_masker(name, disable_logging=False):51 """ Return requested masker plugin52 Parameters53 ----------54 name: str55 The name of the requested masker plugin56 disable_logging: bool, optional57 Whether to disable the INFO log message that the plugin is being imported.58 Default: `False`59 Returns60 -------61 :class:`plugins.extract.mask` object:62 An extraction masker plugin63 """64 return PluginLoader._import("extract.mask", name, disable_logging)65 @staticmethod66 def get_model(name, disable_logging=False):67 """ Return requested training model plugin68 Parameters69 ----------70 name: str71 The name of the requested training model plugin72 disable_logging: bool, optional73 Whether to disable the INFO log message that the plugin is being imported.74 Default: `False`75 Returns76 -------77 :class:`plugins.train.model` object:78 A training model plugin79 """80 return PluginLoader._import("train.model", name, disable_logging)81 @staticmethod82 def get_trainer(name, disable_logging=False):83 """ Return requested training trainer plugin84 Parameters85 ----------86 name: str87 The name of the requested training trainer plugin88 disable_logging: bool, optional89 Whether to disable the INFO log message that the plugin is being imported.90 Default: `False`91 Returns92 -------93 :class:`plugins.train.trainer` object:94 A training trainer plugin95 """96 return PluginLoader._import("train.trainer", name, disable_logging)97 @staticmethod98 def get_converter(category, name, disable_logging=False):99 """ Return requested converter plugin100 Converters work slightly differently to other faceswap plugins. They are created to do a101 specific task (e.g. color adjustment, mask blending etc.), so multiple plugins will be102 loaded in the convert phase, rather than just one plugin for the other phases.103 Parameters104 ----------105 name: str106 The name of the requested converter plugin107 disable_logging: bool, optional108 Whether to disable the INFO log message that the plugin is being imported.109 Default: `False`110 Returns111 -------112 :class:`plugins.convert` object:113 A converter sub plugin114 """115 return PluginLoader._import("convert.{}".format(category), name, disable_logging)116 @staticmethod117 def _import(attr, name, disable_logging):118 """ Import the plugin's module119 Parameters120 ----------121 name: str122 The name of the requested converter plugin123 disable_logging: bool124 Whether to disable the INFO log message that the plugin is being imported.125 Returns126 -------127 :class:`plugin` object:128 A plugin129 """130 name = name.replace("-", "_")131 ttl = attr.split(".")[-1].title()132 if not disable_logging:133 logger.info("Loading %s from %s plugin...", ttl, name.title())134 attr = "model" if attr == "Trainer" else attr.lower()135 mod = ".".join(("plugins", attr, name))136 module = import_module(mod)137 return getattr(module, ttl)138 @staticmethod139 def get_available_extractors(extractor_type, add_none=False):140 """ Return a list of available extractors of the given type141 Parameters142 ----------143 extractor_type: {'aligner', 'detector', 'masker'}144 The type of extractor to return the plugins for145 add_none: bool, optional146 Append "none" to the list of returned plugins. Default: False147 Returns148 -------149 list:150 A list of the available extractor plugin names for the given type151 """152 extractpath = os.path.join(os.path.dirname(__file__),153 "extract",154 extractor_type)155 extractors = sorted(item.name.replace(".py", "").replace("_", "-")156 for item in os.scandir(extractpath)157 if not item.name.startswith("_")158 and not item.name.endswith("defaults.py")159 and item.name.endswith(".py"))160 if add_none:161 extractors.insert(0, "none")162 return extractors163 @staticmethod164 def get_available_models():165 """ Return a list of available training models166 Returns167 -------168 list:169 A list of the available training model plugin names170 """171 modelpath = os.path.join(os.path.dirname(__file__), "train", "model")172 models = sorted(item.name.replace(".py", "").replace("_", "-")173 for item in os.scandir(modelpath)174 if not item.name.startswith("_")175 and not item.name.endswith("defaults.py")176 and item.name.endswith(".py"))177 return models178 @staticmethod179 def get_default_model():180 """ Return the default training model plugin name181 Returns182 -------183 str:184 The default faceswap training model185 """186 models = PluginLoader.get_available_models()187 return 'original' if 'original' in models else models[0]188 @staticmethod189 def get_available_convert_plugins(convert_category, add_none=True):190 """ Return a list of available converter plugins in the given category191 Parameters192 ----------193 convert_category: {'color', 'mask', 'scaling', 'writer'}194 The category of converter plugin to return the plugins for195 add_none: bool, optional196 Append "none" to the list of returned plugins. Default: True197 Returns198 -------199 list200 A list of the available converter plugin names in the given category201 """202 convertpath = os.path.join(os.path.dirname(__file__),203 "convert",204 convert_category)205 converters = sorted(item.name.replace(".py", "").replace("_", "-")206 for item in os.scandir(convertpath)207 if not item.name.startswith("_")208 and not item.name.endswith("defaults.py")209 and item.name.endswith(".py"))210 if add_none:211 converters.insert(0, "none")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful