Waifu2x Index / Waifu2x
Auto-generated documentation for waifu2x module.
Remove noise from an image (src) using a scale model and an alpha model.
argsargparse.Namespace - argparse namespace containing config such as the block_sizesrcImage.Image - Pillow image to remove noise frommodelChain - model for scalingshould_printbool - Flag to enable print to console
Image.Image- Pillow image with noise removed
def denoise_image(
args: argparse.Namespace, src: Image.Image, model: Chain, should_print: bool = True
) -> Image.Image: ...Load models using a args config.
argsargparse.Namespace - argparse namespace containing config such as the arch and color
dict[str,Chain] - Mapping of model names to Chain models
def load_models(args: argparse.Namespace) -> dict[str, Chain]: ...Run the program, from the main entry point.
def main() -> None: ...Run waifu2x using mostly the same inputs as CLI ones.
input_img_pathstr - Input image/ directory, defaults to "images/small.png"output_img_pathstr - Directory to write output images to, defaults to "./"gpuint - CUDA enabled GPU to use, defaults to -1 :param int | None quality: Set the quality of output images 1-100 (None=100), defaults to None :param str | None model_dir: Specify a custom directory containing models, defaults to Nonescale_ratiofloat - Specify a scale, defaults to 2.0batch_sizeint - description, defaults to 16block_sizeint - description, defaults to 128extensionstr - Select output extension png/webparchstr - description, defaults to "VGG7"methodstr - description, defaults to "scale"noise_levelint - description, defaults to 1colorstr - description, defaults to "rgb"tta_levelint - description, defaults to 8widthint - description, defaults to 0heightint - description, defaults to 0shorter_sideint - description, defaults to 0longer_sideint - description, defaults to 0should_printbool - description, defaults to True
ValueError- Output file extension not supported
def run(
input_img_path: str = "images/small.png",
output_img_path: str = "./",
gpu: int = -1,
quality: int | None = None,
model_dir: str | None = None,
scale_ratio: float = 2.0,
batch_size: int = 16,
block_size: int = 128,
extension: str = "png",
arch: str = "VGG7",
method: str = "scale",
noise_level: int = 1,
color: str = "rgb",
tta_level: int = 8,
width: int = 0,
height: int = 0,
shorter_side: int = 0,
longer_side: int = 0,
should_print: bool = True,
) -> None: ...Split the image into an rgb, and alpha tuple.
:param Image.Image src: image
modelChain - model to useshould_printbool - print to stdout?, defaults to True
Type: tuple[Image.Image, Image.Image | None] rgb, and alpha tuple
def split_alpha(
src: Image.Image, model: Chain, should_print: bool = True
) -> tuple[Image.Image, Image.Image | None]: ...Upscale an image (src) using a scale model and an alpha model.
argsargparse.Namespace - argparse namespace containing config such as the scale_ratio and block sizesrcImage.Image - Pillow image to upscalescale_modelChain - model to use for scalingalpha_modelChain, optional - model to use for alpha. Defaults to None.should_printbool - flag to enable output to console
Image.Image- upscaled Pillow image
def upscale_image(
args: argparse.Namespace,
src: Image.Image,
scale_model: Chain,
alpha_model: Chain | None = None,
should_print: bool = True,
) -> Image.Image: ...