How to use the csbdeep.data.PadAndCropResizer function in csbdeep

To help you get started, we’ve selected a few csbdeep examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CSBDeep / CSBDeep / tests / test_utils.py View on Github external
def test_resizer(axes):
    rng = np.random.RandomState(42)

    resizer = PadAndCropResizer()
    checker = NoResizer()

    for _ in range(50):

        imdims = list(rng.randint(20,40,size=len(axes)))
        div_by = list(rng.randint(1,20,size=len(axes)))

        u = np.empty(imdims,np.float32)
        if any(s%div_n!=0 for s, div_n in zip(imdims, div_by)):
            with pytest.raises(ValueError):
                checker.before(u, axes, div_by)

        v = resizer.before(u, axes, div_by)
        assert all (
            s_v >= s_u and s_v%div_n==0
            for s_u, s_v, div_n in zip(u.shape, v.shape, div_by)
github juglab / n2v / n2v / models / n2v_standard.py View on Github external
    def predict(self, img, axes, resizer=PadAndCropResizer(), n_tiles=None):
        """
        Apply the network to sofar unseen data. This method expects the raw data, i.e. not normalized.
        During prediction the mean and standard deviation, stored with the model (during data generation), are used
        for normalization.

        Parameters
        ----------
        img     : array(floats)
                  The raw images.
        axes    : String
                  Axes of the image ('YX').
        resizer : class(Resizer), optional(default=PadAndCropResizer())
        n_tiles : tuple(int)
                  Number of tiles to tile the image into, if it is too large for memory.

        Returns