sketchkit.image2sketch package¶
Subpackages¶
- sketchkit.image2sketch.anilines package
- sketchkit.image2sketch.hed package
- sketchkit.image2sketch.photosketch package
- Subpackages
- Submodules
- sketchkit.image2sketch.photosketch.generate module
PhotoSketchModelPhotoSketchModel.DEFAULT_CHECKPOINT_DIRPhotoSketchModel.DEFAULT_INPUT_SIZEPhotoSketchModel.DEFAULT_MODEL_NAMEPhotoSketchModel.GENERATOR_FILENAMEPhotoSketchModel.GENERATOR_SHA1PhotoSketchModel.INPUT_CHANNELSPhotoSketchModel.MODEL_ARCHIVE_NAMEPhotoSketchModel.MODEL_DOWNLOAD_URLPhotoSketchModel.MODEL_DRIVE_IDPhotoSketchModel.NUM_FILTERSPhotoSketchModel.OUTPUT_CHANNELSPhotoSketchModel.RESNET_BLOCKSPhotoSketchModel._download_and_extract()PhotoSketchModel._extract_archive()PhotoSketchModel._generatorPhotoSketchModel._initialise_generator()PhotoSketchModel._install_from_local_archive()PhotoSketchModel._install_from_local_file()PhotoSketchModel._prepare_tensor()PhotoSketchModel._resolve_device()PhotoSketchModel._resolve_size()PhotoSketchModel._tensor_to_image()PhotoSketchModel._to_pil_image()PhotoSketchModel._validate_sha1()PhotoSketchModel.checkpoint_dirPhotoSketchModel.ensure_assets()PhotoSketchModel.generate()PhotoSketchModel.generate_batch()
- Module contents
PhotoSketchModelPhotoSketchModel.DEFAULT_CHECKPOINT_DIRPhotoSketchModel.DEFAULT_INPUT_SIZEPhotoSketchModel.DEFAULT_MODEL_NAMEPhotoSketchModel.GENERATOR_FILENAMEPhotoSketchModel.GENERATOR_SHA1PhotoSketchModel.INPUT_CHANNELSPhotoSketchModel.MODEL_ARCHIVE_NAMEPhotoSketchModel.MODEL_DOWNLOAD_URLPhotoSketchModel.MODEL_DRIVE_IDPhotoSketchModel.NUM_FILTERSPhotoSketchModel.OUTPUT_CHANNELSPhotoSketchModel.RESNET_BLOCKSPhotoSketchModel._download_and_extract()PhotoSketchModel._extract_archive()PhotoSketchModel._generatorPhotoSketchModel._initialise_generator()PhotoSketchModel._install_from_local_archive()PhotoSketchModel._install_from_local_file()PhotoSketchModel._prepare_tensor()PhotoSketchModel._resolve_device()PhotoSketchModel._resolve_size()PhotoSketchModel._tensor_to_image()PhotoSketchModel._to_pil_image()PhotoSketchModel._validate_sha1()PhotoSketchModel.checkpoint_dirPhotoSketchModel.ensure_assets()PhotoSketchModel.generate()PhotoSketchModel.generate_batch()
- sketchkit.image2sketch.pydiffvg package
- sketchkit.image2sketch.swiftsketch package
- Subpackages
- sketchkit.image2sketch.swiftsketch.diffusion package
- Submodules
- sketchkit.image2sketch.swiftsketch.diffusion.Loss_computation module
- sketchkit.image2sketch.swiftsketch.diffusion.fp16_util module
- sketchkit.image2sketch.swiftsketch.diffusion.gaussian_diffusion module
- sketchkit.image2sketch.swiftsketch.diffusion.logger module
- sketchkit.image2sketch.swiftsketch.diffusion.resample module
- sketchkit.image2sketch.swiftsketch.diffusion.respace module
- Module contents
- sketchkit.image2sketch.swiftsketch.model package
- sketchkit.image2sketch.swiftsketch.refine_model package
- sketchkit.image2sketch.swiftsketch.utils package
- Submodules
- sketchkit.image2sketch.swiftsketch.utils.dist_util module
- sketchkit.image2sketch.swiftsketch.utils.fixseed module
- sketchkit.image2sketch.swiftsketch.utils.get_data module
- sketchkit.image2sketch.swiftsketch.utils.get_features module
- sketchkit.image2sketch.swiftsketch.utils.model_util module
- sketchkit.image2sketch.swiftsketch.utils.parser_util module
- sketchkit.image2sketch.swiftsketch.utils.sketch_utils module
- Module contents
- sketchkit.image2sketch.swiftsketch.diffusion package
- Submodules
- sketchkit.image2sketch.swiftsketch.generate module
SwiftSketchModelSwiftSketchModel._control_points_to_sketch()SwiftSketchModel._default_diffusion_factory()SwiftSketchModel._default_feature_extractor_factory()SwiftSketchModel._default_mask_model_factory()SwiftSketchModel._device_index()SwiftSketchModel._ensure_archive()SwiftSketchModel._find_model_member()SwiftSketchModel._initialise_pipeline()SwiftSketchModel._load_args()SwiftSketchModel._load_state_dict()SwiftSketchModel._resolve_device()SwiftSketchModel._resolve_size()SwiftSketchModel._to_pil_image()SwiftSketchModel.checkpoint_dirSwiftSketchModel.deviceSwiftSketchModel.ensure_assets()SwiftSketchModel.generate()SwiftSketchModel.generate_batch()SwiftSketchModel.model_archive_pathSwiftSketchModel.refine_archive_path
- Module contents
SwiftSketchModelSwiftSketchModel._control_points_to_sketch()SwiftSketchModel._default_diffusion_factory()SwiftSketchModel._default_feature_extractor_factory()SwiftSketchModel._default_mask_model_factory()SwiftSketchModel._device_index()SwiftSketchModel._ensure_archive()SwiftSketchModel._find_model_member()SwiftSketchModel._initialise_pipeline()SwiftSketchModel._load_args()SwiftSketchModel._load_state_dict()SwiftSketchModel._resolve_device()SwiftSketchModel._resolve_size()SwiftSketchModel._to_pil_image()SwiftSketchModel.checkpoint_dirSwiftSketchModel.deviceSwiftSketchModel.ensure_assets()SwiftSketchModel.generate()SwiftSketchModel.generate_batch()SwiftSketchModel.model_archive_pathSwiftSketchModel.refine_archive_path
- Subpackages
Submodules¶
sketchkit.image2sketch.generator module¶
Unified interface for image-to-sketch methods.
Module contents¶
Unified image-to-sketch interface and backend classes.
- class sketchkit.image2sketch.AniLinesModel(*, checkpoint_dir: str | PathLike | None = None, mode: str = 'basic', device: str | device | None = None, binarize: float = -1.0, fp16: bool = True)[source]¶
Bases:
objectHigh level wrapper around the AniLines LineExtractor.
- DEFAULT_CHECKPOINT_DIR = PosixPath('/home/euruson/.cache/sketchkit/image2sketch/anilines')¶
- class sketchkit.image2sketch.HEDModel(*, checkpoint_dir: str | PathLike | None = None, auto_download: bool = True, postprocess: bool = True, postprocess_threshold: float = 0.09803921568627451, postprocess_small_edge: int = 5)[source]¶
Bases:
objectHigh level wrapper around the original HED Caffe model.
- MEAN_BGR = (104.00698793, 116.66876762, 122.67891434)¶
- MODEL_FILENAME = 'hed_pretrained_bsds.caffemodel'¶
- MODEL_SHA1 = '2c5d7842f25f880eec62fc610b500c5cf2aa351d'¶
- MODEL_URL = 'https://vcl.ucsd.edu/hed/hed_pretrained_bsds.caffemodel'¶
- property checkpoint_dir: Path¶
- class sketchkit.image2sketch.PhotoSketchModel(*, checkpoint_dir: str | PathLike | None = None, model_name: str = 'pretrained', auto_download: bool = True, device: str | device | None = None, input_size: int = 256)[source]¶
Bases:
objectHigh level wrapper around the PhotoSketch Pix2Pix generator.
- DEFAULT_CHECKPOINT_DIR = PosixPath('/home/euruson/.cache/sketchkit/image2sketch/photosketch')¶
- DEFAULT_INPUT_SIZE = 256¶
- DEFAULT_MODEL_NAME = 'pretrained'¶
- GENERATOR_FILENAME = 'latest_net_G.pth'¶
- GENERATOR_SHA1 = '5968e8f007c650008a265c11f2d2a3887e5840d4'¶
- INPUT_CHANNELS = 3¶
- MODEL_ARCHIVE_NAME = 'photosketch_pretrained.zip'¶
- MODEL_DOWNLOAD_URL = 'https://drive.google.com/uc?export=download&id=1TQf-LyS8rRDDapdcTnEgWzYJllPgiXdj'¶
- MODEL_DRIVE_ID = '1TQf-LyS8rRDDapdcTnEgWzYJllPgiXdj'¶
- NUM_FILTERS = 64¶
- OUTPUT_CHANNELS = 1¶
- RESNET_BLOCKS = 9¶
- property checkpoint_dir: Path¶
- class sketchkit.image2sketch.SketchGenerator(method: str = 'SwiftSketch', **kwargs: Any)[source]¶
Bases:
objectGenerate sketches with one of the supported image-to-sketch methods.
- class sketchkit.image2sketch.SwiftSketchModel(*, device: str | device | None = None, use_refine: bool = True, guidance_param: float = 2.5, fix_scale: bool = True, checkpoint_dir: str | PathLike | None = None, auto_download: bool = True, mask_model_factory: Callable[[device], Module] | None = None, feature_extractor_factory: Callable[[device, str], Module] | None = None, diffusion_factory: Callable[[SimpleNamespace], Tuple[Module, object]] | None = None, refine_model_factory: Callable[[SimpleNamespace], Module] | None = None)[source]¶
Bases:
objectHigh level wrapper around the SwiftSketch diffusion pipeline.
- static _control_points_to_sketch(control_points: Tensor, canvas_size: Tuple[int, int]) Sketch[source]¶
- static _resolve_device(device: str | device | None) device[source]¶
Determine which device SwiftSketch should run on.
By default, a CUDA-capable GPU is required. Users can override the selection via the
SKETCHKIT_SWIFTSKETCH_DEVICEenvironment variable or by explicitly passing adeviceargument. When neither is supplied and CUDA is unavailable, the model refuses to run unless theSKETCHKIT_ALLOW_CPU_FALLBACKenvironment variable is set to"1". This makes it possible to exercise the pipeline on CPU for testing while keeping the production default focused on GPU runtimes.
- property checkpoint_dir: Path¶
- property device: device¶
- generate(image: Image | ndarray | str | PathLike | Sequence[Image | ndarray | str | PathLike], size: int | Tuple[int, int] | None = None) Sketch | List[Sketch][source]¶
Generate sketches for the provided image(s).
- generate_batch(images: Sequence[Image | ndarray | str | PathLike], *, size: int | Tuple[int, int] | None = None) List[Sketch][source]¶
- property model_archive_path: Path¶
- property refine_archive_path: Path¶