π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
Fix RandomCrop transformation matrix to reflect actual image scaling (#3310)
Meggison Oritsemisan9a90ba397818
diff --git a/.github/actions/coverage/action.yml b/.github/actions/coverage/action.ymlindex afbd682ee..ee8c8b204 100644--- a/.github/actions/coverage/action.yml+++ b/.github/actions/coverage/action.yml@@ -49,7 +49,7 @@ runs:ref: ${{ inputs.ref }}- name: Run CPU tests coverage ${{ inputs.pytorch-dtype }}- continue-on-error: ${{ inputs.continue-on-error }}+ continue-on-error: ${{ inputs.continue-on-error == 'true' }}shell: bash -l {0}run: |coverage erasediff --git a/kornia/augmentation/_2d/geometric/crop.py b/kornia/augmentation/_2d/geometric/crop.pyindex 1e2e63fd9..cb477dd9c 100644--- a/kornia/augmentation/_2d/geometric/crop.py+++ b/kornia/augmentation/_2d/geometric/crop.py@@ -161,7 +161,18 @@ class RandomCrop(GeometricAugmentationBase2D):def compute_transformation(self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any]) -> Tensor:if flags["cropping_mode"] in ("resample", "slice"):- transform: Tensor = get_perspective_transform(params["src"].to(input), params["dst"].to(input))+ src = params["src"].to(input)+ dst = params["dst"].to(input)+ transform: Tensor = get_perspective_transform(src, dst)++ # Fast scaling correction when output exceeds input and padding disabled+ if not flags.get("pad_if_needed", False):+ h, w = input.shape[-2:]+ h_out, w_out = flags["size"]+ if h_out > h or w_out > w:+ transform[:, 0, 0] *= w_out / w+ transform[:, 1, 1] *= h_out / h+return transformraise NotImplementedError(f"Not supported type: {flags['cropping_mode']}.")diff --git a/kornia/filters/dissolving.py b/kornia/filters/dissolving.pyindex 9984dc6dd..5ccf31f7f 100644--- a/kornia/filters/dissolving.py+++ b/kornia/filters/dissolving.py@@ -139,6 +139,9 @@ class StableDiffusionDissolving(ImageModule):steps_offset=1,)+ # Filter out arguments that are not supported by all component models+ kwargs.pop("offload_state_dict", None)+if version == "1.4":self._sdm_model = StableDiffusionPipeline.from_pretrained( # type:ignore"CompVis/stable-diffusion-v1-4", scheduler=scheduler, **kwargs