當前位置: 首頁>>代碼示例>>Python>>正文


Python image.imresize方法代碼示例

本文整理匯總了Python中mxnet.image.imresize方法的典型用法代碼示例。如果您正苦於以下問題:Python image.imresize方法的具體用法?Python image.imresize怎麽用?Python image.imresize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mxnet.image的用法示例。


在下文中一共展示了image.imresize方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: forward

# 需要導入模塊: from mxnet import image [as 別名]
# 或者: from mxnet.image import imresize [as 別名]
def forward(self, x):
        if isinstance(self._size, numeric_types):
            if not self._keep:
                wsize = self._size
                hsize = self._size
            else:
                h, w, _ = x.shape
                if h > w:
                    wsize = self._size
                    hsize = int(h * wsize / w)
                else:
                    hsize = self._size
                    wsize = int(w * hsize / h)
        else:
            wsize, hsize = self._size
        return image.imresize(x, wsize, hsize, self._interpolation) 
開發者ID:dmlc,項目名稱:gluon-cv,代碼行數:18,代碼來源:train_cgan.py

示例2: load_data_fashion_mnist

# 需要導入模塊: from mxnet import image [as 別名]
# 或者: from mxnet.image import imresize [as 別名]
def load_data_fashion_mnist(batch_size, resize=None, root="~/.mxnet/datasets/fashion-mnist"):
    """download the fashion mnist dataest and then load into memory"""

    def transform_mnist(data, label):
        # Transform a batch of examples.
        if resize:
            n = data.shape[0]
            new_data = nd.zeros((n, resize, resize, data.shape[3]))
            for i in range(n):
                new_data[i] = image.imresize(data[i], resize, resize)
            data = new_data
        # change data from batch x height x width x channel to batch x channel x height x width
        return nd.transpose(data.astype('float32'), (0, 3, 1, 2)) / 255, label.astype('float32')

    mnist_train = gluon.data.vision.FashionMNIST(root=root, train=True, transform=None)
    mnist_test = gluon.data.vision.FashionMNIST(root=root, train=False, transform=None)
    # Transform later to avoid memory explosion.
    train_data = DataLoader(mnist_train, batch_size, shuffle=True, transform=transform_mnist)
    test_data = DataLoader(mnist_test, batch_size, shuffle=False, transform=transform_mnist)
    return (train_data, test_data) 
開發者ID:auroua,項目名稱:InsightFace_TF,代碼行數:22,代碼來源:utils_final.py

示例3: load_data_mnist

# 需要導入模塊: from mxnet import image [as 別名]
# 或者: from mxnet.image import imresize [as 別名]
def load_data_mnist(batch_size, resize=None, root="~/.mxnet/datasets/mnist"):
    """download the fashion mnist dataest and then load into memory"""

    def transform_mnist(data, label):
        # Transform a batch of examples.
        if resize:
            n = data.shape[0]
            new_data = nd.zeros((n, resize, resize, data.shape[3]))
            for i in range(n):
                new_data[i] = image.imresize(data[i], resize, resize)
            data = new_data
        # change data from batch x height x width x channel to batch x channel x height x width
        return nd.transpose(data.astype('float32'), (0, 3, 1, 2)) / 255, label.astype('float32')

    mnist_train = gluon.data.vision.MNIST(root=root, train=True, transform=None)
    mnist_test = gluon.data.vision.MNIST(root=root, train=False, transform=None)
    # Transform later to avoid memory explosion.
    train_data = DataLoader(mnist_train, batch_size, shuffle=True, transform=transform_mnist)
    test_data = DataLoader(mnist_test, batch_size, shuffle=False, transform=transform_mnist)
    return (train_data, test_data) 
開發者ID:auroua,項目名稱:InsightFace_TF,代碼行數:22,代碼來源:utils_final.py

示例4: load_data_fashion_mnist

# 需要導入模塊: from mxnet import image [as 別名]
# 或者: from mxnet.image import imresize [as 別名]
def load_data_fashion_mnist(batch_size, resize=None, root="~/.mxnet/datasets/fashion-mnist"):
    """download the fashion mnist dataest and then load into memory"""
    def transform_mnist(data, label):
        # Transform a batch of examples.
        if resize:
            n = data.shape[0]
            new_data = nd.zeros((n, resize, resize, data.shape[3]))
            for i in range(n):
                new_data[i] = image.imresize(data[i], resize, resize)
            data = new_data
        # change data from batch x height x width x channel to batch x channel x height x width
        return nd.transpose(data.astype('float32'), (0,3,1,2))/255, label.astype('float32')

    mnist_train = gluon.data.vision.FashionMNIST(root=root, train=True, transform=None)
    mnist_test = gluon.data.vision.FashionMNIST(root=root, train=False, transform=None)
    # Transform later to avoid memory explosion. 
    train_data = DataLoader(mnist_train, batch_size, shuffle=True, transform=transform_mnist)
    test_data = DataLoader(mnist_test, batch_size, shuffle=False, transform=transform_mnist)
    return (train_data, test_data) 
開發者ID:XiuweiHe,項目名稱:EmotionClassifier,代碼行數:21,代碼來源:utils.py

示例5: load_data_fashion_mnist

# 需要導入模塊: from mxnet import image [as 別名]
# 或者: from mxnet.image import imresize [as 別名]
def load_data_fashion_mnist(batch_size, resize=None):
    """download the fashion mnist dataest and then load into memory"""
    def transform_mnist(data, label):
        if resize:
            # resize to resize x resize
            data = image.imresize(data, resize, resize)
        # change data from height x weight x channel to channel x height x weight
        return nd.transpose(data.astype('float32'), (2,0,1))/255, label.astype('float32')
    mnist_train = gluon.data.vision.FashionMNIST(root='./data',
        train=True, transform=transform_mnist)
    mnist_test = gluon.data.vision.FashionMNIST(root='./data',
        train=False, transform=transform_mnist)
    train_data = gluon.data.DataLoader(
        mnist_train, batch_size, shuffle=True)
    test_data = gluon.data.DataLoader(
        mnist_test, batch_size, shuffle=False)
    return (train_data, test_data) 
開發者ID:sxhxliang,項目名稱:CapsNet_Mxnet,代碼行數:19,代碼來源:utils.py

示例6: load_data_mnist

# 需要導入模塊: from mxnet import image [as 別名]
# 或者: from mxnet.image import imresize [as 別名]
def load_data_mnist(batch_size, resize=None):
    """download the fashion mnist dataest and then load into memory"""
    def transform_mnist(data, label):
        if resize:
            # resize to resize x resize
            data = image.imresize(data, resize, resize)
        # change data from height x weight x channel to channel x height x weight
        return nd.transpose(data.astype('float32'), (2,0,1))/255, label.astype('float32')
    mnist_train = gluon.data.vision.MNIST(root='./data',
        train=True, transform=transform_mnist)
    mnist_test = gluon.data.vision.MNIST(root='./data',
        train=False, transform=transform_mnist)
    train_data = gluon.data.DataLoader(
        mnist_train, batch_size, shuffle=True)
    test_data = gluon.data.DataLoader(
        mnist_test, batch_size, shuffle=False)
    return (train_data, test_data) 
開發者ID:sxhxliang,項目名稱:CapsNet_Mxnet,代碼行數:19,代碼來源:utils.py

示例7: process_image

# 需要導入模塊: from mxnet import image [as 別名]
# 或者: from mxnet.image import imresize [as 別名]
def process_image(fname, data_shape, rgb_mean, rgb_std):
    with open(fname, 'rb') as f:
        im = image.imdecode(f.read())
    data = image.imresize(im, data_shape, data_shape)
    data = (data.astype('float32') - rgb_mean) / rgb_std
    return data.transpose((2, 0, 1)).expand_dims(axis=0), im 
開發者ID:MashiMaroLjc,項目名稱:YOLO,代碼行數:8,代碼來源:utils.py

示例8: pre_processing

# 需要導入模塊: from mxnet import image [as 別名]
# 或者: from mxnet.image import imresize [as 別名]
def pre_processing(self, img):
        """
        對圖片進行處理
        :param img_path: 圖片
        :return:
        """
        data_augment = False
        if self.phase == 'train' and np.random.rand() > 0.5:
            data_augment = True
        if data_augment:
            img_h = 40
            img_w = 340
        else:
            img_h = self.img_h
            img_w = self.img_w
        img = image.imdecode(img, 1 if self.img_channel == 3 else 0)
        h, w = img.shape[:2]
        ratio_h = float(img_h) / h
        new_w = int(w * ratio_h)
        if new_w < img_w:
            img = image.imresize(img, w=new_w, h=img_h)
            step = nd.zeros((img_h, img_w - new_w, self.img_channel), dtype=img.dtype)
            img = nd.concat(img, step, dim=1)
        else:
            img = image.imresize(img, w=img_w, h=img_h)

        if data_augment:
            img, _ = image.random_crop(img, (self.img_w, self.img_h))
        return img 
開發者ID:WenmuZhou,項目名稱:crnn.gluon,代碼行數:31,代碼來源:dataset.py


注:本文中的mxnet.image.imresize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。