def get_argument_list(): """ Put the arguments in a list so that they are accessible from both argparse and gui """ argument_list = list() argument_list.append({"opts": ("-A", "--input-A"), "action": DirFullPaths, "dest": "input_a", "default": "input_a", "help": "Input directory. A directory " "containing training images for face A. " "Defaults to 'input'"}) argument_list.append({"opts": ("-B", "--input-B"), "action": DirFullPaths, "dest": "input_b", "default": "input_b", "help": "Input directory. A directory " "containing training images for face B. " "Defaults to 'input'"}) argument_list.append({"opts": ("-ala", "--alignments-A"), "action": FileFullPaths, "filetypes": 'alignments', "type": str, "dest": "alignments_path_a", "default": None, "help": "Path to alignments file for training set A. Only required " "if you are using a masked model or warp-to-landmarks is " "enabled. Defaults to <input-A>/alignments.json if not " "provided."}) argument_list.append({"opts": ("-alb", "--alignments-B"), "action": FileFullPaths, "filetypes": 'alignments', "type": str, "dest": "alignments_path_b", "default": None, "help": "Path to alignments file for training set B. Only required " "if you are using a masked model or warp-to-landmarks is " "enabled. Defaults to <input-B>/alignments.json if not " "provided."}) argument_list.append({"opts": ("-m", "--model-dir"), "action": DirFullPaths, "dest": "model_dir", "default": "models", "help": "Model directory. This is where the " "training data will be stored. " "Defaults to 'model'"}) argument_list.append({"opts": ("-t", "--trainer"), "type": str.lower, "choices": PluginLoader.get_available_models(), "default": PluginLoader.get_default_model(), "help": "Select which trainer to use, Use " "LowMem for cards with less than 2GB of " "VRAM"}) argument_list.append({"opts": ("-s", "--save-interval"), "type": int, "action": Slider, "min_max": (10, 1000), "rounding": 10, "dest": "save_interval", "default": 100, "help": "Sets the number of iterations before saving the model"}) argument_list.append({"opts": ("-bs", "--batch-size"), "type": int, "action": Slider, "min_max": (2, 256), "rounding": 2, "dest": "batch_size", "default": 64, "help": "Batch size, as a power of 2 (64, 128, 256, etc)"}) argument_list.append({"opts": ("-it", "--iterations"), "type": int, "action": Slider, "min_max": (0, 5000000), "rounding": 20000, "default": 1000000, "help": "Length of training in iterations."}) argument_list.append({"opts": ("-g", "--gpus"), "type": int, "action": Slider, "min_max": (1, 10), "rounding": 1, "default": 1, "help": "Number of GPUs to use for training"}) argument_list.append({"opts": ("-ps", "--preview-scale"), "type": int, "action": Slider, "dest": "preview_scale", "min_max": (25, 200), "rounding": 25, "default": 100, "help": "Percentage amount to scale the preview by."}) argument_list.append({"opts": ("-p", "--preview"), "action": "store_true", "dest": "preview", "default": False, "help": "Show preview output. If not specified, " "write progress to file"}) argument_list.append({"opts": ("-w", "--write-image"), "action": "store_true", "dest": "write_image", "default": False, "help": "Writes the training result to a file " "even on preview mode"}) argument_list.append({"opts": ("-ag", "--allow-growth"), "action": "store_true", "dest": "allow_growth", "default": False, "help": "Sets allow_growth option of Tensorflow " "to spare memory on some configs"}) argument_list.append({"opts": ("-nl", "--no-logs"), "action": "store_true", "dest": "no_logs", "default": False, "help": "Disables TensorBoard logging. NB: Disabling logs means " "that you will not be able to use the graph or analysis " "for this session in the GUI."}) argument_list.append({"opts": ("-wl", "--warp-to-landmarks"), "action": "store_true", "dest": "warp_to_landmarks", "default": False, "help": "Warps training faces to closely matched Landmarks from the " "opposite face-set rather than randomly warping the face. " "This is the 'dfaker' way of doing warping. Alignments " "files for both sets of faces must be provided if using " "this option."}) argument_list.append({"opts": ("-nf", "--no-flip"), "action": "store_true", "dest": "no_flip", "default": False, "help": "To effectively learn, a random set of images are flipped " "horizontally. Sometimes it is desirable for this not to " "occur. Generally this should be left off except for " "during 'fit training'."}) argument_list.append({"opts": ("-tia", "--timelapse-input-A"), "action": DirFullPaths, "dest": "timelapse_input_a", "default": None, "help": "For if you want a timelapse: " "The input folder for the timelapse. " "This folder should contain faces of A " "which will be converted for the " "timelapse. You must supply a " "--timelapse-output and a " "--timelapse-input-B parameter."}) argument_list.append({"opts": ("-tib", "--timelapse-input-B"), "action": DirFullPaths, "dest": "timelapse_input_b", "default": None, "help": "For if you want a timelapse: " "The input folder for the timelapse. " "This folder should contain faces of B " "which will be converted for the " "timelapse. You must supply a " "--timelapse-output and a " "--timelapse-input-A parameter."}) argument_list.append({"opts": ("-to", "--timelapse-output"), "action": DirFullPaths, "dest": "timelapse_output", "default": None, "help": "The output folder for the timelapse. " "If the input folders are supplied but " "no output folder, it will default to " "your model folder /timelapse/"}) return argument_list
def get_optional_arguments(): """ Put the arguments in a list so that they are accessible from both argparse and gui """ argument_list = [] argument_list.append({"opts": ("-m", "--model-dir"), "action": DirFullPaths, "dest": "model_dir", "default": "models", "help": "Model directory. A directory " "containing the trained model you wish " "to process. Defaults to 'models'"}) argument_list.append({"opts": ("-a", "--input-aligned-dir"), "action": DirFullPaths, "dest": "input_aligned_dir", "default": None, "help": "Input \"aligned directory\". A " "directory that should contain the " "aligned faces extracted from the input " "files. If you delete faces from this " "folder, they'll be skipped during " "conversion. If no aligned dir is " "specified, all faces will be " "converted"}) argument_list.append({"opts": ("-t", "--trainer"), "type": str.lower, "choices": PluginLoader.get_available_models(), "default": PluginLoader.get_default_model(), "help": "Select the trainer that was used to " "create the model"}) argument_list.append({"opts": ("-c", "--converter"), "type": str.lower, "choices": PluginLoader.get_available_converters(), "default": "masked", "help": "Converter to use"}) argument_list.append({ "opts": ("-M", "--mask-type"), "type": str.lower, "dest": "mask_type", "choices": ["ellipse", "facehull", "dfl", # "cnn", Removed until implemented "none"], "default": "facehull", "help": "R|Mask to use to replace faces." "\nellipse: Oval around face." "\nfacehull: Face cutout based on landmarks." "\ndfl: A Face Hull mask from DeepFaceLabs." # "\ncnn: Not yet implemented" Removed until implemented "\nnone: No mask. Can still use blur and erode on the edges of the swap box."}) argument_list.append({"opts": ("-b", "--blur-size"), "type": float, "action": Slider, "min_max": (0.0, 100.0), "rounding": 2, "default": 5.0, "help": "Blur kernel size as a percentage of the swap area. Smooths " "the transition between the swapped face and the background " "image."}) argument_list.append({"opts": ("-e", "--erosion-size"), "dest": "erosion_size", "type": float, "action": Slider, "min_max": (-100.0, 100.0), "rounding": 2, "default": 0.0, "help": "Erosion kernel size as a percentage of the mask radius " "area. Positive values apply erosion which reduces the size " "of the swapped area. Negative values apply dilation which " "increases the swapped area"}) argument_list.append({"opts": ("-g", "--gpus"), "type": int, "action": Slider, "min_max": (1, 10), "rounding": 1, "default": 1, "help": "Number of GPUs to use for conversion"}) argument_list.append({"opts": ("-sh", "--sharpen"), "type": str.lower, "dest": "sharpen_image", "choices": ["box_filter", "gaussian_filter", "none"], "default": "none", "help": "Sharpen the masked facial region of " "the converted images. Choice of filter " "to use in sharpening process -- box" "filter or gaussian filter."}) argument_list.append({"opts": ("-fr", "--frame-ranges"), "nargs": "+", "type": str, "help": "frame ranges to apply transfer to e.g. " "For frames 10 to 50 and 90 to 100 use " "--frame-ranges 10-50 90-100. Files " "must have the frame-number as the last " "number in the name!"}) argument_list.append({"opts": ("-d", "--discard-frames"), "action": "store_true", "dest": "discard_frames", "default": False, "help": "When used with --frame-ranges discards " "frames that are not processed instead " "of writing them out unchanged"}) argument_list.append({"opts": ("-s", "--swap-model"), "action": "store_true", "dest": "swap_model", "default": False, "help": "Swap the model. Instead of A -> B, " "swap B -> A"}) argument_list.append({"opts": ("-S", "--seamless"), "action": "store_true", "dest": "seamless_clone", "default": False, "help": "Use cv2's seamless clone function to " "remove extreme gradients at the mask " "seam by smoothing colors."}) argument_list.append({"opts": ("-mh", "--match-histogram"), "action": "store_true", "dest": "match_histogram", "default": False, "help": "Adjust the histogram of each color " "channel in the swapped reconstruction " "to equal the histogram of the masked " "area in the orginal image"}) argument_list.append({"opts": ("-aca", "--avg-color-adjust"), "action": "store_true", "dest": "avg_color_adjust", "default": False, "help": "Adjust the mean of each color channel " " in the swapped reconstruction to " "equal the mean of the masked area in " "the orginal image"}) argument_list.append({"opts": ("-sb", "--smooth-box"), "action": "store_true", "dest": "smooth_box", "default": False, "help": "Perform a Gaussian blur on the edges of the face box " "received from the model. Helps reduce pronounced edges " "of the swap area"}) argument_list.append({"opts": ("-dt", "--draw-transparent"), "action": "store_true", "dest": "draw_transparent", "default": False, "help": "Place the swapped face on a " "transparent layer rather than the " "original frame."}) return argument_list
def get_optional_arguments(): """ Put the arguments in a list so that they are accessible from both argparse and gui """ argument_list = [] argument_list.append({ "opts": ("-m", "--model-dir"), "action": DirFullPaths, "dest": "model_dir", "default": "models", "help": "Model directory. A directory " "containing the trained model you wish " "to process. Defaults to 'models'" }) argument_list.append({ "opts": ("-a", "--input-aligned-dir"), "action": DirFullPaths, "dest": "input_aligned_dir", "default": None, "help": "Input \"aligned directory\". A " "directory that should contain the " "aligned faces extracted from the input " "files. If you delete faces from this " "folder, they'll be skipped during " "conversion. If no aligned dir is " "specified, all faces will be " "converted" }) argument_list.append({ "opts": ("-t", "--trainer"), "type": str, # case sensitive because this is used to # load a plug-in. "choices": PluginLoader.get_available_models(), "default": PluginLoader.get_default_model(), "help": "Select the trainer that was used to " "create the model" }) argument_list.append({ "opts": ("-c", "--converter"), "type": str, # case sensitive because this is used # to load a plugin. "choices": ("Masked", "Adjust"), "default": "Masked", "help": "Converter to use" }) argument_list.append({ "opts": ("-b", "--blur-size"), "type": int, "default": 2, "help": "Blur size. (Masked converter only)" }) argument_list.append({ "opts": ("-e", "--erosion-kernel-size"), "dest": "erosion_kernel_size", "type": int, "default": None, "help": "Erosion kernel size. Positive values " "apply erosion which reduces the edge " "of the swapped face. Negative values " "apply dilation which allows the " "swapped face to cover more space. " "(Masked converter only)" }) argument_list.append({ "opts": ("-M", "--mask-type"), # lowercase this, because it's just a # string later on. "type": str.lower, "dest": "mask_type", "choices": ["rect", "facehull", "facehullandrect"], "default": "facehullandrect", "help": "Mask to use to replace faces. " "(Masked converter only)" }) argument_list.append({ "opts": ("-sh", "--sharpen"), "type": str.lower, "dest": "sharpen_image", "choices": ["bsharpen", "gsharpen"], "default": None, "help": "Use Sharpen Image. bsharpen for Box " "Blur, gsharpen for Gaussian Blur " "(Masked converter only)" }) argument_list.append({ "opts": ("-g", "--gpus"), "type": int, "default": 1, "help": "Number of GPUs to use for conversion" }) argument_list.append({ "opts": ("-fr", "--frame-ranges"), "nargs": "+", "type": str, "help": "frame ranges to apply transfer to e.g. " "For frames 10 to 50 and 90 to 100 use " "--frame-ranges 10-50 90-100. Files " "must have the frame-number as the last " "number in the name!" }) argument_list.append({ "opts": ("-d", "--discard-frames"), "action": "store_true", "dest": "discard_frames", "default": False, "help": "When used with --frame-ranges discards " "frames that are not processed instead " "of writing them out unchanged" }) argument_list.append({ "opts": ("-s", "--swap-model"), "action": "store_true", "dest": "swap_model", "default": False, "help": "Swap the model. Instead of A -> B, " "swap B -> A" }) argument_list.append({ "opts": ("-S", "--seamless"), "action": "store_true", "dest": "seamless_clone", "default": False, "help": "Use cv2's seamless clone. " "(Masked converter only)" }) argument_list.append({ "opts": ("-mh", "--match-histogram"), "action": "store_true", "dest": "match_histogram", "default": False, "help": "Use histogram matching. " "(Masked converter only)" }) argument_list.append({ "opts": ("-sm", "--smooth-mask"), "action": "store_true", "dest": "smooth_mask", "default": False, "help": "Smooth mask (Adjust converter only)" }) argument_list.append({ "opts": ("-aca", "--avg-color-adjust"), "action": "store_true", "dest": "avg_color_adjust", "default": False, "help": "Average color adjust. " "(Adjust converter only)" }) argument_list.append({ "opts": ("-dt", "--draw-transparent"), "action": "store_true", "dest": "draw_transparent", "default": False, "help": "Place the swapped face on a " "transparent layer rather than the " "original frame." }) return argument_list
def get_argument_list(): """ Put the arguments in a list so that they are accessible from both argparse and gui """ argument_list = list() argument_list.append({ "opts": ("-A", "--input-A"), "action": DirFullPaths, "dest": "input_A", "default": "input_A", "help": "Input directory. A directory " "containing training images for face A. " "Defaults to 'input'" }) argument_list.append({ "opts": ("-B", "--input-B"), "action": DirFullPaths, "dest": "input_B", "default": "input_B", "help": "Input directory. A directory " "containing training images for face B. " "Defaults to 'input'" }) argument_list.append({ "opts": ("-m", "--model-dir"), "action": DirFullPaths, "dest": "model_dir", "default": "models", "help": "Model directory. This is where the " "training data will be stored. " "Defaults to 'model'" }) argument_list.append({ "opts": ("-s", "--save-interval"), "type": int, "dest": "save_interval", "default": 100, "help": "Sets the number of iterations before " "saving the model" }) argument_list.append({ "opts": ("-t", "--trainer"), "type": str, "choices": PluginLoader.get_available_models(), "default": PluginLoader.get_default_model(), "help": "Select which trainer to use, Use " "LowMem for cards with less than 2GB of " "VRAM" }) argument_list.append({ "opts": ("-bs", "--batch-size"), "type": int, "default": 64, "help": "Batch size, as a power of 2 " "(64, 128, 256, etc)" }) argument_list.append({ "opts": ("-it", "--iterations"), "type": int, "default": 1000000, "help": "Length of training in iterations" }) argument_list.append({ "opts": ("-g", "--gpus"), "type": int, "default": 1, "help": "Number of GPUs to use for training" }) argument_list.append({ "opts": ("-p", "--preview"), "action": "store_true", "dest": "preview", "default": False, "help": "Show preview output. If not specified, " "write progress to file" }) argument_list.append({ "opts": ("-w", "--write-image"), "action": "store_true", "dest": "write_image", "default": False, "help": "Writes the training result to a file " "even on preview mode" }) argument_list.append({ "opts": ("-pl", "--use-perceptual-loss"), "action": "store_true", "dest": "perceptual_loss", "default": False, "help": "Use perceptual loss while training" }) argument_list.append({ "opts": ("-ag", "--allow-growth"), "action": "store_true", "dest": "allow_growth", "default": False, "help": "Sets allow_growth option of Tensorflow " "to spare memory on some configs" }) argument_list.append({ "opts": ("-v", "--verbose"), "action": "store_true", "dest": "verbose", "default": False, "help": "Show verbose output" }) argument_list.append({ "opts": ("-tia", "--timelapse-input-A"), "action": DirFullPaths, "dest": "timelapse_input_A", "default": None, "help": "For if you want a timelapse: " "The input folder for the timelapse. " "This folder should contain faces of A " "which will be converted for the " "timelapse. You must supply a " "--timelapse-output and a " "--timelapse-input-B parameter." }) argument_list.append({ "opts": ("-tib", "--timelapse-input-B"), "action": DirFullPaths, "dest": "timelapse_input_B", "default": None, "help": "For if you want a timelapse: " "The input folder for the timelapse. " "This folder should contain faces of B " "which will be converted for the " "timelapse. You must supply a " "--timelapse-output and a " "--timelapse-input-A parameter." }) argument_list.append({ "opts": ("-to", "--timelapse-output"), "action": DirFullPaths, "dest": "timelapse_output", "default": None, "help": "The output folder for the timelapse. " "If the input folders are supplied but " "no output folder, it will default to " "your model folder /timelapse/" }) # This is a hidden argument to indicate that the GUI is being used, # so the preview window should be redirected Accordingly argument_list.append({ "opts": ("-gui", "--gui"), "action": "store_true", "dest": "redirect_gui", "default": False, "help": argparse.SUPPRESS }) return argument_list
def get_argument_list(): """ Put the arguments in a list so that they are accessible from both argparse and gui """ argument_list = list() argument_list.append({ "opts": ("-A", "--input-A"), "action": DirFullPaths, "dest": "input_a", "default": "input_a", "help": "Input directory. A directory " "containing training images for face A. " "Defaults to 'input'" }) argument_list.append({ "opts": ("-B", "--input-B"), "action": DirFullPaths, "dest": "input_b", "default": "input_b", "help": "Input directory. A directory " "containing training images for face B. " "Defaults to 'input'" }) argument_list.append({ "opts": ("-ala", "--alignments-A"), "action": FileFullPaths, "filetypes": 'alignments', "type": str, "dest": "alignments_path_a", "default": None, "help": "Path to alignments file for training set A. Only required " "if you are using a masked model or warp-to-landmarks is " "enabled. Defaults to <input-A>/alignments.json if not " "provided." }) argument_list.append({ "opts": ("-alb", "--alignments-B"), "action": FileFullPaths, "filetypes": 'alignments', "type": str, "dest": "alignments_path_b", "default": None, "help": "Path to alignments file for training set B. Only required " "if you are using a masked model or warp-to-landmarks is " "enabled. Defaults to <input-B>/alignments.json if not " "provided." }) argument_list.append({ "opts": ("-m", "--model-dir"), "action": DirFullPaths, "dest": "model_dir", "default": "models", "help": "Model directory. This is where the " "training data will be stored. " "Defaults to 'model'" }) argument_list.append({ "opts": ("-t", "--trainer"), "action": Radio, "type": str.lower, "choices": PluginLoader.get_available_models(), "default": PluginLoader.get_default_model(), "help": "R|Select which trainer to use. Trainers can be" "\nconfigured from the edit menu or the config folder." "\n'original': The original model created by /u/deepfakes." "\n'dfaker': 64px in/128px out model from dfaker." "\n\tEnable 'warp-to-landmarks' for full dfaker method." "\n'dfl-h128'. 128px in/out model from deepfacelab" "\n'iae': A model that uses intermediate layers to try to" "\n\tget better details" "\n'lightweight': A lightweight model for low-end cards." "\n\tDon't expect great results. Can train as low as 1.6GB" "\n\twith batch size 8." "\n'unbalanced': 128px in/out model from andenixa. The" "\n\tautoencoders are unbalanced so B>A swaps won't work so" "\n\twell. Very configurable," "\n'villain': 128px in/out model from villainguy. Very" "\n\tresource hungry (11GB for batchsize 16). Good for" "\n\tdetails, but more susceptible to color differences" }) argument_list.append({ "opts": ("-s", "--save-interval"), "type": int, "action": Slider, "min_max": (10, 1000), "rounding": 10, "dest": "save_interval", "default": 100, "help": "Sets the number of iterations before saving the model" }) argument_list.append({ "opts": ("-bs", "--batch-size"), "type": int, "action": Slider, "min_max": (2, 256), "rounding": 2, "dest": "batch_size", "default": 64, "help": "Batch size, as a power of 2 (64, 128, 256, etc)" }) argument_list.append({ "opts": ("-it", "--iterations"), "type": int, "action": Slider, "min_max": (0, 5000000), "rounding": 20000, "default": 1000000, "help": "Length of training in iterations." }) argument_list.append({ "opts": ("-g", "--gpus"), "type": int, "action": Slider, "min_max": (1, 10), "rounding": 1, "default": 1, "help": "Number of GPUs to use for training" }) argument_list.append({ "opts": ("-ps", "--preview-scale"), "type": int, "action": Slider, "dest": "preview_scale", "min_max": (25, 200), "rounding": 25, "default": 50, "help": "Percentage amount to scale the preview by." }) argument_list.append({ "opts": ("-p", "--preview"), "action": "store_true", "dest": "preview", "default": False, "help": "Show preview output. If not specified, " "write progress to file" }) argument_list.append({ "opts": ("-w", "--write-image"), "action": "store_true", "dest": "write_image", "default": False, "help": "Writes the training result to a file " "even on preview mode" }) argument_list.append({ "opts": ("-ag", "--allow-growth"), "action": "store_true", "dest": "allow_growth", "default": False, "help": "Sets allow_growth option of Tensorflow " "to spare memory on some configs" }) argument_list.append({ "opts": ("-nl", "--no-logs"), "action": "store_true", "dest": "no_logs", "default": False, "help": "Disables TensorBoard logging. NB: Disabling logs means " "that you will not be able to use the graph or analysis " "for this session in the GUI." }) argument_list.append({ "opts": ("-pp", "--ping-pong"), "action": "store_true", "dest": "pingpong", "default": False, "help": "Enable ping pong training. Trains one side at a time, " "switching sides at each save iteration. Training will take " "2 to 4 times longer, with about a 30%%-50%% reduction in " "VRAM useage. NB: Preview won't show until both sides have " "been trained once." }) argument_list.append({ "opts": ("-msg", "--memory-saving-gradients"), "action": "store_true", "dest": "memory_saving_gradients", "default": False, "help": "Trades off VRAM useage against computation time. Can fit " "larger models into memory at a cost of slower training " "speed. 50%%-150%% batch size increase for 20%%-50%% longer " "training time. NB: Launch time will be significantly " "delayed. Switching sides using ping-pong training will " "take longer." }) argument_list.append({ "opts": ("-wl", "--warp-to-landmarks"), "action": "store_true", "dest": "warp_to_landmarks", "default": False, "help": "Warps training faces to closely matched Landmarks from the " "opposite face-set rather than randomly warping the face. " "This is the 'dfaker' way of doing warping. Alignments " "files for both sets of faces must be provided if using " "this option." }) argument_list.append({ "opts": ("-nf", "--no-flip"), "action": "store_true", "dest": "no_flip", "default": False, "help": "To effectively learn, a random set of images are flipped " "horizontally. Sometimes it is desirable for this not to " "occur. Generally this should be left off except for " "during 'fit training'." }) argument_list.append({ "opts": ("-tia", "--timelapse-input-A"), "action": DirFullPaths, "dest": "timelapse_input_a", "default": None, "help": "For if you want a timelapse: " "The input folder for the timelapse. " "This folder should contain faces of A " "which will be converted for the " "timelapse. You must supply a " "--timelapse-output and a " "--timelapse-input-B parameter." }) argument_list.append({ "opts": ("-tib", "--timelapse-input-B"), "action": DirFullPaths, "dest": "timelapse_input_b", "default": None, "help": "For if you want a timelapse: " "The input folder for the timelapse. " "This folder should contain faces of B " "which will be converted for the " "timelapse. You must supply a " "--timelapse-output and a " "--timelapse-input-A parameter." }) argument_list.append({ "opts": ("-to", "--timelapse-output"), "action": DirFullPaths, "dest": "timelapse_output", "default": None, "help": "The output folder for the timelapse. " "If the input folders are supplied but " "no output folder, it will default to " "your model folder /timelapse/" }) return argument_list