Main Launcher

class face_crop_plus.__main__.ArgumentParserWithConfig(*args, config_arg=['-c', '--config'], **kwargs)[source]

Bases: ArgumentParser

An ArgumentParser that loads default values from a config file.

This class extends the argparse.ArgumentParser class to load default values from a config file specified by a command-line argument.

__init__(*args, config_arg=['-c', '--config'], **kwargs)[source]

Initialize ArgumentParserWithConfig object.

Parameters:
  • *args – Additional arguments for initializing argparse.ArgumentParser.

  • config_arg (str | list[str]) – The name (or the list of names) of the command-line argument that specifies the path to the JSON config file. Defaults to [“-c”, “–config”].

  • **kwargs – Additional keyword arguments for initializing argparse.ArgumentParser.

parse_args(args=None, namespace=None)[source]

Parse arguments and load default values from the config file.

This method parses the command-line arguments and loads default values from the config file specified by the config_arg parameter. The default values are only loaded once.

Parameters:
  • args (Optional[Any]) – The sequence of arguments to parse. If None, then the sequence will be retrieved by reading the command-line arguments. Defaults to None.

  • namespace (Optional[Namespace]) – The namespace object to extend with parsed arguments. If None, then a new object will be created. Defaults to None.

Return type:

Namespace

Returns:

A namespace object containing the parsed arguments.

face_crop_plus.__main__.main()[source]

Processes an input dir of images

Creates a cropper object based on the provided command-line arguments and processes a specified directory of images. There are 3 main features the cropper can do (either together or separately): align and center-crop face images, enhance quality, group by attributes. For more details, see Cropper.

face_crop_plus.__main__.parse_args()[source]

Parses command-line arguments.

Defines the possible command-line arguments that must match the acceptable arguments by Cropper. It parses those arguments and converts them to a dictionary.

Raises:

ValueError – If input_dir is not specified.

Return type:

dict[str, Any]

Returns:

A dictionary where keys represent argument names and values represent those argument values.