forked from mindspore-Ecosystem/mindspore
[MD] Transform Unification - Phase 3: Update Smoke tests and remaining UTs
This commit is contained in:
parent
a4785b9baa
commit
f4fd0300c6
|
@ -106,7 +106,7 @@ Status OneHotEncoding(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tens
|
|||
} else if (input->type() == DataType::DE_UINT64) {
|
||||
RETURN_IF_NOT_OK(OneHotEncodingImpl<uint64_t>(input, &out, num_classes, i, smoothing_rate));
|
||||
} else {
|
||||
RETURN_STATUS_UNEXPECTED("OneHot: OneHot only support input of int type, but got:" + input->type().ToString());
|
||||
RETURN_STATUS_UNEXPECTED("OneHot: OneHot only supports input of int type, but got:" + input->type().ToString());
|
||||
}
|
||||
}
|
||||
out->Squeeze();
|
||||
|
|
|
@ -38,15 +38,11 @@ namespace dataset {
|
|||
// then it will fail.
|
||||
// @param output: Tensor. The shape of the output tensor is <input_shape, numClasses>
|
||||
// and the type is same as input.
|
||||
// @param num_classes: Number of classes to.
|
||||
// @param num_classes: Number of classes in dataset.
|
||||
// @param smoothing_rate: Adjustable hyperparameter for label smoothing level.
|
||||
Status OneHotEncoding(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output, dsize_t num_classes,
|
||||
double smoothing_rate = 0);
|
||||
|
||||
Status OneHotEncodingUnsigned(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output,
|
||||
dsize_t num_classes, int64_t index);
|
||||
|
||||
Status OneHotEncodingSigned(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output, dsize_t num_classes,
|
||||
int64_t index);
|
||||
template <typename T>
|
||||
Status OneHotEncodingImpl(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output, dsize_t num_classes,
|
||||
int64_t index, double smoothing_rate);
|
||||
|
|
|
@ -168,7 +168,7 @@ Status OneHotOperation::ValidateParams() {
|
|||
LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg);
|
||||
}
|
||||
if (smoothing_rate_ < 0 || smoothing_rate_ > 1) {
|
||||
std::string err_msg = "OneHot: Smoothing rate must be between 0 and 1, but got: " + std::to_string(num_classes_);
|
||||
std::string err_msg = "OneHot: Smoothing rate must be between 0 and 1, but got: " + std::to_string(smoothing_rate_);
|
||||
LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg);
|
||||
}
|
||||
return Status::OK();
|
||||
|
|
|
@ -554,7 +554,7 @@ class OneHot(TensorOperation):
|
|||
|
||||
Raises:
|
||||
TypeError: `num_classes` is not of type int.
|
||||
TypeError: `smoothing_rate` is not of type float.
|
||||
TypeError: `smoothing_rate` is not of type float or int.
|
||||
ValueError: `smoothing_rate` is not in range [0.0, 1.0].
|
||||
RuntimeError: Input tensor is not of type int.
|
||||
RuntimeError: Input tensor is not a 1-D tensor.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
# Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -21,8 +21,8 @@ from mindspore.common.api import _cell_graph_executor
|
|||
from mindspore.common import dtype as mstype
|
||||
from mindspore.ops import operations as P
|
||||
import mindspore.dataset as de
|
||||
from mindspore.dataset.vision import c_transforms as c_vision
|
||||
from mindspore.dataset.transforms import c_transforms as c_trans
|
||||
from mindspore.dataset.vision import transforms as c_vision
|
||||
from mindspore.dataset.transforms import transforms as c_trans
|
||||
|
||||
|
||||
DATA_DIR = "/home/workspace/mindspore_dataset/cifar-10-verify-bin"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2019 Huawei Technologies Co., Ltd
|
||||
# Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -22,7 +22,7 @@ import pytest
|
|||
from PIL import Image
|
||||
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.vision.c_transforms as vision
|
||||
import mindspore.dataset.vision as vision
|
||||
from mindspore.mindrecord import FileWriter, SUCCESS
|
||||
|
||||
def add_and_remove_cv_file(mindrecord):
|
||||
|
|
|
@ -19,10 +19,8 @@ import pytest
|
|||
import numpy as np
|
||||
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.transforms.py_transforms as py_transforms
|
||||
import mindspore.dataset.vision.c_transforms as CV
|
||||
import mindspore.dataset.vision.py_transforms as py_vision
|
||||
import mindspore.dataset.transforms as transforms
|
||||
import mindspore.dataset.vision as vision
|
||||
|
||||
from mindspore import context, nn
|
||||
from mindspore.common import dtype as mstype, set_seed
|
||||
|
@ -59,11 +57,11 @@ def create_dataset(data_path, batch_size=32, num_parallel_workers=1):
|
|||
shift_nml = -1 * 0.1307 / 0.3081
|
||||
|
||||
# Define map operations
|
||||
resize_op = CV.Resize((resize_height, resize_width), interpolation=Inter.LINEAR)
|
||||
rescale_nml_op = CV.Rescale(rescale_nml, shift_nml)
|
||||
rescale_op = CV.Rescale(rescale, shift)
|
||||
hwc2chw_op = CV.HWC2CHW()
|
||||
type_cast_op = C.TypeCast(mstype.int32)
|
||||
resize_op = vision.Resize((resize_height, resize_width), interpolation=Inter.LINEAR)
|
||||
rescale_nml_op = vision.Rescale(rescale_nml, shift_nml)
|
||||
rescale_op = vision.Rescale(rescale, shift)
|
||||
hwc2chw_op = vision.HWC2CHW()
|
||||
type_cast_op = transforms.TypeCast(mstype.int32)
|
||||
|
||||
# Apply map operations on images
|
||||
mnist_ds = mnist_ds.map(operations=type_cast_op, input_columns="label", num_parallel_workers=num_parallel_workers)
|
||||
|
@ -140,20 +138,18 @@ def create_dataset_pyfunc_multiproc(data_path, batch_size=32, num_op_parallel_wo
|
|||
# Define dataset with num_parallel_workers=8 for reasonable performance
|
||||
data1 = ds.MnistDataset(data_path, num_parallel_workers=8)
|
||||
|
||||
data1 = data1.map(operations=[py_vision.ToType(np.int32)], input_columns="label",
|
||||
data1 = data1.map(operations=[vision.ToType(np.int32)], input_columns="label",
|
||||
num_parallel_workers=num_op_parallel_workers,
|
||||
python_multiprocessing=True, max_rowsize=max_rowsize)
|
||||
|
||||
# Setup transforms list which include Python ops
|
||||
transforms_list = [
|
||||
py_vision.ToTensor(),
|
||||
lambda x: x,
|
||||
py_vision.HWC2CHW(),
|
||||
py_vision.RandomErasing(0.9, value='random'),
|
||||
py_vision.Cutout(4, 2),
|
||||
vision.HWC2CHW(),
|
||||
vision.RandomErasing(0.9, value='random'),
|
||||
lambda y: y
|
||||
]
|
||||
compose_op = py_transforms.Compose(transforms_list)
|
||||
compose_op = transforms.Compose(transforms_list)
|
||||
data1 = data1.map(operations=compose_op, input_columns="image", num_parallel_workers=num_op_parallel_workers,
|
||||
python_multiprocessing=True, max_rowsize=max_rowsize)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
# Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -18,7 +18,7 @@ import pickle
|
|||
import numpy as np
|
||||
import mindspore as ms
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as c_transforms
|
||||
import mindspore.dataset.transforms as transforms
|
||||
|
||||
|
||||
class InputFeatures:
|
||||
|
@ -140,7 +140,7 @@ def create_ms_dataset(data_list, label_list, max_seq_length, tokenizer, batch_si
|
|||
if do_shuffle:
|
||||
dataset = dataset.shuffle(buffer_size=10000)
|
||||
|
||||
type_cast_op = c_transforms.TypeCast(ms.int32)
|
||||
type_cast_op = transforms.TypeCast(ms.int32)
|
||||
dataset = dataset.map(operations=[type_cast_op])
|
||||
dataset = dataset.batch(batch_size=batch_size, drop_remainder=drop_remainder)
|
||||
return dataset
|
||||
|
|
|
@ -309,9 +309,8 @@
|
|||
import numpy as np
|
||||
import os
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as tC
|
||||
import mindspore.dataset.vision.py_transforms as PV
|
||||
import mindspore.dataset.transforms.py_transforms as PT
|
||||
import mindspore.dataset.vision as vision
|
||||
import mindspore.dataset.transforms as transforms
|
||||
import mindspore
|
||||
|
||||
def mkdir(path):
|
||||
|
@ -340,16 +339,16 @@
|
|||
resize_height, resize_width = img_size[0], img_size[1] # 32
|
||||
|
||||
transform = [
|
||||
PV.Decode(),
|
||||
PV.Grayscale(1),
|
||||
PV.Resize(size=(resize_height, resize_width)),
|
||||
PV.Grayscale(3),
|
||||
PV.ToTensor(),
|
||||
vision.Decode(True),
|
||||
vision.Grayscale(1),
|
||||
vision.Resize(size=(resize_height, resize_width)),
|
||||
vision.Grayscale(3),
|
||||
vision.ToTensor(),
|
||||
]
|
||||
compose = PT.Compose(transform)
|
||||
compose = transforms.Compose(transform)
|
||||
|
||||
# apply map operations on images
|
||||
mnist_ds = mnist_ds.map(input_columns="label", operations=tC.TypeCast(mindspore.int32))
|
||||
mnist_ds = mnist_ds.map(input_columns="label", operations=transforms.TypeCast(mindspore.int32))
|
||||
mnist_ds = mnist_ds.map(input_columns="image", operations=compose)
|
||||
|
||||
# apply DatasetOps
|
||||
|
|
|
@ -311,9 +311,8 @@ each user is 226.83, and the variance of the data volume of all users is 88.94.
|
|||
import numpy as np
|
||||
import os
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as tC
|
||||
import mindspore.dataset.vision.py_transforms as PV
|
||||
import mindspore.dataset.transforms.py_transforms as PT
|
||||
import mindspore.dataset.vision as vision
|
||||
import mindspore.dataset.transforms as transforms
|
||||
import mindspore
|
||||
|
||||
def mkdir(path):
|
||||
|
@ -342,16 +341,16 @@ each user is 226.83, and the variance of the data volume of all users is 88.94.
|
|||
resize_height, resize_width = img_size[0], img_size[1] # 32
|
||||
|
||||
transform = [
|
||||
PV.Decode(),
|
||||
PV.Grayscale(1),
|
||||
PV.Resize(size=(resize_height, resize_width)),
|
||||
PV.Grayscale(3),
|
||||
PV.ToTensor(),
|
||||
vision.Decode(True),
|
||||
vision.Grayscale(1),
|
||||
vision.Resize(size=(resize_height, resize_width)),
|
||||
vision.Grayscale(3),
|
||||
vision.ToTensor(),
|
||||
]
|
||||
compose = PT.Compose(transform)
|
||||
compose = transforms.Compose(transform)
|
||||
|
||||
# apply map operations on images
|
||||
mnist_ds = mnist_ds.map(input_columns="label", operations=tC.TypeCast(mindspore.int32))
|
||||
mnist_ds = mnist_ds.map(input_columns="label", operations=transforms.TypeCast(mindspore.int32))
|
||||
mnist_ds = mnist_ds.map(input_columns="image", operations=compose)
|
||||
|
||||
# apply DatasetOps
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -23,9 +23,10 @@ from numpy import random
|
|||
import cv2
|
||||
import mmcv
|
||||
import mindspore.dataset as de
|
||||
import mindspore.dataset.vision.c_transforms as C
|
||||
import mindspore.dataset.vision as C
|
||||
from mindspore.mindrecord import FileWriter
|
||||
|
||||
|
||||
def bbox_overlaps(bboxes1, bboxes2, mode='iou'):
|
||||
"""Calculate the ious between each bbox of bboxes1 and bboxes2.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
# Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -24,9 +24,8 @@ import mindspore.nn as nn
|
|||
from mindspore.common.initializer import TruncatedNormal
|
||||
from mindspore import Tensor
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.vision.py_transforms as PV
|
||||
import mindspore.dataset.transforms.py_transforms as PT
|
||||
import mindspore.dataset.transforms.c_transforms as tC
|
||||
import mindspore.dataset.vision as vision
|
||||
import mindspore.dataset.transforms as transforms
|
||||
from mindspore.train.serialization import save_checkpoint
|
||||
from mindspore.train.callback import Callback, FederatedLearningManager
|
||||
from mindspore.nn.metrics import Accuracy
|
||||
|
@ -252,16 +251,16 @@ def create_dataset_from_folder(data_path, img_size, batch_size=32, repeat_size=1
|
|||
resize_height, resize_width = img_size[0], img_size[1]
|
||||
|
||||
transform = [
|
||||
PV.Decode(),
|
||||
PV.Grayscale(1),
|
||||
PV.Resize(size=(resize_height, resize_width)),
|
||||
PV.Grayscale(3),
|
||||
PV.ToTensor()
|
||||
vision.Decode(True),
|
||||
vision.Grayscale(1),
|
||||
vision.Resize(size=(resize_height, resize_width)),
|
||||
vision.Grayscale(3),
|
||||
vision.ToTensor()
|
||||
]
|
||||
compose = PT.Compose(transform)
|
||||
compose = transforms.Compose(transform)
|
||||
|
||||
# apply map operations on images
|
||||
mnist_ds = mnist_ds.map(input_columns="label", operations=tC.TypeCast(mindspore.int32))
|
||||
mnist_ds = mnist_ds.map(input_columns="label", operations=transforms.TypeCast(mindspore.int32))
|
||||
mnist_ds = mnist_ds.map(input_columns="image", operations=compose)
|
||||
|
||||
# apply DatasetOps
|
||||
|
|
|
@ -18,8 +18,8 @@ import sys
|
|||
|
||||
import mindspore.context as context
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.vision.c_transforms as CV
|
||||
import mindspore.dataset.transforms as C
|
||||
import mindspore.dataset.vision as CV
|
||||
import mindspore.nn as nn
|
||||
from mindspore.common import dtype as mstype
|
||||
from mindspore.dataset.vision import Inter
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -21,8 +21,8 @@ from resnet import resnet50
|
|||
import mindspore.common.dtype as mstype
|
||||
import mindspore.context as context
|
||||
import mindspore.dataset as de
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.vision.c_transforms as vision
|
||||
import mindspore.dataset.transforms as C
|
||||
import mindspore.dataset.vision as vision
|
||||
import mindspore.nn as nn
|
||||
from mindspore import Tensor
|
||||
from mindspore.communication.management import init
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -21,8 +21,8 @@ from resnet import resnet50
|
|||
import mindspore.common.dtype as mstype
|
||||
import mindspore.context as context
|
||||
import mindspore.dataset as de
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.vision.c_transforms as vision
|
||||
import mindspore.dataset.transforms as C
|
||||
import mindspore.dataset.vision as vision
|
||||
import mindspore.nn as nn
|
||||
from mindspore import Tensor
|
||||
from mindspore.communication.management import init
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -25,7 +25,7 @@ from mindspore.train.model import Model
|
|||
from mindspore.train.loss_scale_manager import DynamicLossScaleManager
|
||||
from mindspore.train.callback import Callback
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as deC
|
||||
import mindspore.dataset.transforms as deC
|
||||
from mindspore import context
|
||||
from easydict import EasyDict as edict
|
||||
from tests.models.official.nlp.transformer.src.transformer_model import TransformerConfig
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -22,14 +22,14 @@ from matplotlib.colors import rgb_to_hsv, hsv_to_rgb
|
|||
from PIL import Image
|
||||
import mindspore.dataset as de
|
||||
from mindspore.mindrecord import FileWriter
|
||||
import mindspore.dataset.vision.c_transforms as C
|
||||
import mindspore.dataset.vision as C
|
||||
from src.config import ConfigYOLOV3ResNet18
|
||||
|
||||
iter_cnt = 0
|
||||
_NUM_BOXES = 50
|
||||
np.random.seed(1)
|
||||
de.config.set_seed(1)
|
||||
|
||||
|
||||
def preprocess_fn(image, box, is_training):
|
||||
"""Preprocess function for dataset."""
|
||||
config_anchors = [10, 13, 16, 30, 33, 23, 30, 61, 62, 45, 59, 119, 116, 90, 156, 198, 163, 326]
|
||||
|
@ -46,7 +46,6 @@ def preprocess_fn(image, box, is_training):
|
|||
num_layers = anchors.shape[0] // 3
|
||||
anchor_mask = [[6, 7, 8], [3, 4, 5], [0, 1, 2]]
|
||||
true_boxes = np.array(true_boxes, dtype='float32')
|
||||
# input_shape = np.array([in_shape, in_shape], dtype='int32')
|
||||
input_shape = np.array(in_shape, dtype='int32')
|
||||
boxes_xy = (true_boxes[..., 0:2] + true_boxes[..., 2:4]) // 2.
|
||||
boxes_wh = true_boxes[..., 2:4] - true_boxes[..., 0:2]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -20,7 +20,7 @@ import cv2
|
|||
from PIL import Image
|
||||
from pycocotools.coco import COCO
|
||||
import mindspore.dataset as de
|
||||
import mindspore.dataset.vision.c_transforms as CV
|
||||
import mindspore.dataset.vision as CV
|
||||
|
||||
from src.distributed_sampler import DistributedSampler
|
||||
from src.transforms import reshape_fn, MultiScaleTrans
|
||||
|
@ -45,7 +45,7 @@ def has_valid_annotation(anno):
|
|||
# if all boxes have close to zero area, there is no annotation
|
||||
if _has_only_empty_bbox(anno):
|
||||
return False
|
||||
# keypoints task have a slight different critera for considering
|
||||
# keypoints task have a slight different criteria for considering
|
||||
# if an annotation is valid
|
||||
if "keypoints" not in anno[0]:
|
||||
return True
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -21,7 +21,7 @@ import numpy as np
|
|||
import pytest
|
||||
import mindspore.common.dtype as mstype
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.transforms as C
|
||||
from mindspore import context
|
||||
from mindspore import log as logger
|
||||
from mindspore.ops import operations as P
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -31,7 +31,7 @@ from mindspore.train.serialization import load_checkpoint, load_param_into_net
|
|||
from mindspore.nn.optim import thor
|
||||
from mindspore.train.model import Model
|
||||
from mindspore.train.train_thor import ConvertModelUtils
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.transforms as C
|
||||
|
||||
from tests.models.official.nlp.bert.src.bert_for_pre_training import BertNetworkWithLoss, BertTrainOneStepCell
|
||||
from tests.models.official.nlp.bert.src.utils import get_bert_thor_lr, get_bert_thor_damping
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -21,7 +21,7 @@ import numpy as np
|
|||
import pytest
|
||||
import mindspore.common.dtype as mstype
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.transforms as C
|
||||
from mindspore import context
|
||||
from mindspore import log as logger
|
||||
from mindspore.ops import operations as P
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -18,7 +18,7 @@ Data operations, will be used in run_pretrain.py
|
|||
import os
|
||||
import mindspore.common.dtype as mstype
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.transforms as C
|
||||
from mindspore import log as logger
|
||||
from .config import bert_net_cfg
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the License);
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -16,7 +16,7 @@
|
|||
import numpy as np
|
||||
from PIL import Image
|
||||
import mindspore.dataset as de
|
||||
import mindspore.dataset.vision.c_transforms as C
|
||||
import mindspore.dataset.vision as C
|
||||
|
||||
from .ei_dataset import HwVocRawDataset
|
||||
from .utils import custom_transforms as tr
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -18,8 +18,8 @@
|
|||
import os
|
||||
import mindspore.common.dtype as mstype
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.vision.c_transforms as C
|
||||
import mindspore.dataset.transforms.c_transforms as C2
|
||||
import mindspore.dataset.vision as C
|
||||
import mindspore.dataset.transforms as C2
|
||||
|
||||
|
||||
def create_dataset(dataset_path, do_train, repeat_num=1, batch_size=32):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -50,18 +50,18 @@ def create_dataset1(dataset_path, do_train, batch_size=32, train_image_size=224,
|
|||
trans = []
|
||||
if do_train:
|
||||
trans += [
|
||||
ds.vision.c_transforms.RandomCrop((32, 32), (4, 4, 4, 4)),
|
||||
ds.vision.c_transforms.RandomHorizontalFlip(prob=0.5)
|
||||
ds.vision.RandomCrop((32, 32), (4, 4, 4, 4)),
|
||||
ds.vision.RandomHorizontalFlip(prob=0.5)
|
||||
]
|
||||
|
||||
trans += [
|
||||
ds.vision.c_transforms.Resize((train_image_size, train_image_size)),
|
||||
ds.vision.c_transforms.Rescale(1.0 / 255.0, 0.0),
|
||||
ds.vision.c_transforms.Normalize([0.4914, 0.4822, 0.4465], [0.2023, 0.1994, 0.2010]),
|
||||
ds.vision.c_transforms.HWC2CHW()
|
||||
ds.vision.Resize((train_image_size, train_image_size)),
|
||||
ds.vision.Rescale(1.0 / 255.0, 0.0),
|
||||
ds.vision.Normalize([0.4914, 0.4822, 0.4465], [0.2023, 0.1994, 0.2010]),
|
||||
ds.vision.HWC2CHW()
|
||||
]
|
||||
|
||||
type_cast_op = ds.transforms.c_transforms.TypeCast(ms.int32)
|
||||
type_cast_op = ds.transforms.TypeCast(ms.int32)
|
||||
|
||||
data_set = data_set.map(operations=type_cast_op, input_columns="label",
|
||||
num_parallel_workers=get_num_parallel_workers(8))
|
||||
|
@ -117,18 +117,18 @@ def create_dataset2(dataset_path, do_train, batch_size=32, train_image_size=224,
|
|||
# define map operations
|
||||
if do_train:
|
||||
trans = [
|
||||
ds.vision.c_transforms.RandomCropDecodeResize(train_image_size, scale=(0.08, 1.0), ratio=(0.75, 1.333)),
|
||||
ds.vision.c_transforms.RandomHorizontalFlip(prob=0.5)
|
||||
ds.vision.RandomCropDecodeResize(train_image_size, scale=(0.08, 1.0), ratio=(0.75, 1.333)),
|
||||
ds.vision.RandomHorizontalFlip(prob=0.5)
|
||||
]
|
||||
else:
|
||||
trans = [
|
||||
ds.vision.c_transforms.Decode(),
|
||||
ds.vision.c_transforms.Resize(256),
|
||||
ds.vision.c_transforms.CenterCrop(eval_image_size)
|
||||
ds.vision.Decode(),
|
||||
ds.vision.Resize(256),
|
||||
ds.vision.CenterCrop(eval_image_size)
|
||||
]
|
||||
trans_norm = [ds.vision.c_transforms.Normalize(mean=mean, std=std), ds.vision.c_transforms.HWC2CHW()]
|
||||
trans_norm = [ds.vision.Normalize(mean=mean, std=std), ds.vision.HWC2CHW()]
|
||||
|
||||
type_cast_op = ds.transforms.c_transforms.TypeCast(ms.int32)
|
||||
type_cast_op = ds.transforms.TypeCast(ms.int32)
|
||||
|
||||
data_set = data_set.map(operations=trans, input_columns="image", num_parallel_workers=get_num_parallel_workers(12))
|
||||
data_set = data_set.map(operations=trans_norm, input_columns="image",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2019 Huawei Technologies Co., Ltd
|
||||
# Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -20,8 +20,8 @@ import pytest
|
|||
|
||||
import mindspore.context as context
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.vision.c_transforms as CV
|
||||
import mindspore.dataset.transforms as C
|
||||
import mindspore.dataset.vision as CV
|
||||
import mindspore.nn as nn
|
||||
from mindspore import Tensor, ParameterTuple
|
||||
from mindspore.common import dtype as mstype
|
||||
|
|
|
@ -3,8 +3,8 @@ import os
|
|||
import pytest
|
||||
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as CT
|
||||
import mindspore.dataset.vision.c_transforms as CV
|
||||
import mindspore.dataset.transforms as CT
|
||||
import mindspore.dataset.vision as CV
|
||||
import mindspore.nn as nn
|
||||
from mindspore import ParameterTuple
|
||||
from mindspore import context
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2019 Huawei Technologies Co., Ltd
|
||||
# Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -17,7 +17,7 @@ import numpy as np
|
|||
|
||||
import mindspore.context as context
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.vision.c_transforms as vision
|
||||
import mindspore.dataset.vision as vision
|
||||
import mindspore.nn as nn
|
||||
from mindspore.common.api import _cell_graph_executor
|
||||
from mindspore.common.tensor import Tensor
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -17,8 +17,8 @@ Produce the dataset
|
|||
"""
|
||||
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.vision.c_transforms as CV
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.vision as CV
|
||||
import mindspore.dataset.transforms as C
|
||||
from mindspore.dataset.vision import Inter
|
||||
from mindspore import dtype as mstype
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -16,7 +16,7 @@ import os
|
|||
|
||||
from mindspore import dtype as mstype
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.vision.c_transforms as CV
|
||||
import mindspore.dataset.vision as CV
|
||||
import mindspore.nn as nn
|
||||
from mindspore import context, Tensor
|
||||
import mindspore.ops as ops
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -16,7 +16,7 @@ import os
|
|||
|
||||
from mindspore import dtype as mstype
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.vision.c_transforms as CV
|
||||
import mindspore.dataset.vision as CV
|
||||
import mindspore.nn as nn
|
||||
from mindspore import context, Tensor
|
||||
import mindspore.ops as ops
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -18,7 +18,7 @@ The VAE interface can be called to construct VAE-GAN network.
|
|||
import os
|
||||
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.vision.c_transforms as CV
|
||||
import mindspore.dataset.vision as CV
|
||||
import mindspore.nn as nn
|
||||
from mindspore import context
|
||||
import mindspore.ops as ops
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -14,8 +14,8 @@
|
|||
# ============================================================================
|
||||
""" test uncertainty toolbox """
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.vision.c_transforms as CV
|
||||
import mindspore.dataset.transforms as C
|
||||
import mindspore.dataset.vision as CV
|
||||
import mindspore.nn as nn
|
||||
from mindspore import context, Tensor
|
||||
from mindspore import dtype as mstype
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -17,8 +17,8 @@ Produce the dataset
|
|||
"""
|
||||
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.vision.c_transforms as CV
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.vision as CV
|
||||
import mindspore.dataset.transforms as C
|
||||
from mindspore.dataset.vision import Inter
|
||||
from mindspore import dtype as mstype
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -19,8 +19,8 @@ import numpy as np
|
|||
|
||||
from mindspore.common import dtype as mstype
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.transforms.vision.c_transforms as CV
|
||||
import mindspore.dataset.transforms as C
|
||||
import mindspore.dataset.vision as CV
|
||||
from mindspore.dataset.transforms.vision import Inter
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -24,8 +24,8 @@ from mindspore import dataset as ds
|
|||
from mindspore import nn, Tensor, context
|
||||
from mindspore.nn.metrics import Accuracy
|
||||
from mindspore.nn.optim import Momentum
|
||||
from mindspore.dataset.transforms import c_transforms as C
|
||||
from mindspore.dataset.vision import c_transforms as CV
|
||||
from mindspore.dataset.transforms import transforms as C
|
||||
from mindspore.dataset.vision import transforms as CV
|
||||
from mindspore.dataset.vision import Inter
|
||||
from mindspore.common import dtype as mstype
|
||||
from mindspore.common.initializer import TruncatedNormal
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -18,8 +18,8 @@ import argparse
|
|||
|
||||
import mindspore.context as context
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.vision.c_transforms as CV
|
||||
import mindspore.dataset.transforms as C
|
||||
import mindspore.dataset.vision as CV
|
||||
import mindspore.nn as nn
|
||||
from mindspore.common import dtype as mstype
|
||||
from mindspore.dataset.vision import Inter
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -18,8 +18,8 @@ import argparse
|
|||
import numpy as np
|
||||
import mindspore.context as context
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.vision.c_transforms as CV
|
||||
import mindspore.dataset.transforms as C
|
||||
import mindspore.dataset.vision as CV
|
||||
from mindspore.common import dtype as mstype
|
||||
from mindspore.dataset.vision import Inter
|
||||
from mindspore.common.tensor import Tensor
|
||||
|
|
|
@ -22,8 +22,8 @@ import pytest
|
|||
|
||||
import mindspore.common.dtype as mstype
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.vision.c_transforms as vision
|
||||
import mindspore.dataset.transforms as C
|
||||
import mindspore.dataset.vision as vision
|
||||
import mindspore.nn as nn
|
||||
import mindspore.ops.functional as F
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -19,8 +19,8 @@ import numpy as np
|
|||
|
||||
import mindspore.common.dtype as mstype
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.vision.c_transforms as vision
|
||||
import mindspore.dataset.transforms as C
|
||||
import mindspore.dataset.vision as vision
|
||||
import mindspore.nn as nn
|
||||
import mindspore.ops.functional as F
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -17,8 +17,8 @@ Produce the dataset
|
|||
"""
|
||||
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.vision.c_transforms as CV
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.vision as CV
|
||||
import mindspore.dataset.transforms as C
|
||||
from mindspore.dataset.vision import Inter
|
||||
from mindspore.common import dtype as mstype
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -17,8 +17,8 @@
|
|||
from functools import partial
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.common.dtype as mstype
|
||||
import mindspore.dataset.vision.c_transforms as C
|
||||
import mindspore.dataset.transforms.c_transforms as C2
|
||||
import mindspore.dataset.vision as C
|
||||
import mindspore.dataset.transforms as C2
|
||||
|
||||
|
||||
def create_dataset(dataset_path, config, repeat_num=1, batch_size=32):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -18,8 +18,8 @@ from functools import partial
|
|||
|
||||
import mindspore.common.dtype as mstype
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C2
|
||||
import mindspore.dataset.vision.c_transforms as C
|
||||
import mindspore.dataset.transforms as C2
|
||||
import mindspore.dataset.vision as C
|
||||
|
||||
|
||||
def create_dataset(dataset_path, config, repeat_num=1, batch_size=32):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -17,9 +17,9 @@ import os
|
|||
|
||||
from mindspore import dataset as ds
|
||||
from mindspore.common import dtype as mstype
|
||||
from mindspore.dataset.transforms import c_transforms as C
|
||||
from mindspore.dataset.transforms import transforms as C
|
||||
from mindspore.dataset.vision import Inter
|
||||
from mindspore.dataset.vision import c_transforms as CV
|
||||
from mindspore.dataset.vision import transforms as CV
|
||||
|
||||
|
||||
def create_mnist_dataset(mode='train', num_samples=2, batch_size=2):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -23,8 +23,8 @@ import mindspore.ops.functional as F
|
|||
from mindspore.train.callback import ModelCheckpoint, CheckpointConfig, LossMonitor, TimeMonitor
|
||||
from mindspore.train.serialization import load_checkpoint, load_param_into_net
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.vision.c_transforms as vision
|
||||
import mindspore.dataset.transforms as C
|
||||
import mindspore.dataset.vision as vision
|
||||
import mindspore.nn as nn
|
||||
from mindspore import Tensor
|
||||
from mindspore import context
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -20,8 +20,8 @@ from resnet import resnet50
|
|||
|
||||
import mindspore.common.dtype as mstype
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.vision.c_transforms as vision
|
||||
import mindspore.dataset.transforms as C
|
||||
import mindspore.dataset.vision as vision
|
||||
import mindspore.nn as nn
|
||||
import mindspore.ops.functional as F
|
||||
from mindspore import Tensor
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -21,8 +21,8 @@ import numpy as np
|
|||
from resnet import resnet50
|
||||
import mindspore.common.dtype as mstype
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.vision.c_transforms as vision
|
||||
import mindspore.dataset.transforms as C
|
||||
import mindspore.dataset.vision as vision
|
||||
import mindspore.nn as nn
|
||||
import mindspore.ops.functional as F
|
||||
from mindspore import Tensor
|
||||
|
|
|
@ -12,13 +12,15 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
|
||||
"""
|
||||
Test MindData vision utility get_image_num_channels
|
||||
"""
|
||||
import numpy as np
|
||||
import pytest
|
||||
from PIL import Image
|
||||
|
||||
import mindspore.dataset.vision.utils as vision
|
||||
import mindspore.dataset.vision.c_transforms as C
|
||||
import mindspore.dataset.vision.utils as vision_utils
|
||||
import mindspore.dataset.vision as vision
|
||||
from mindspore import log as logger
|
||||
|
||||
|
||||
|
@ -30,8 +32,8 @@ def test_get_image_num_channels_output_array():
|
|||
"""
|
||||
expect_output = 3
|
||||
img = np.fromfile("../data/dataset/apple.jpg", dtype=np.uint8)
|
||||
input_array = C.Decode()(img)
|
||||
output = vision.get_image_num_channels(input_array)
|
||||
input_array = vision.Decode()(img)
|
||||
output = vision_utils.get_image_num_channels(input_array)
|
||||
assert expect_output == output
|
||||
|
||||
|
||||
|
@ -44,7 +46,7 @@ def test_get_image_num_channels_output_img():
|
|||
testdata = "../data/dataset/apple.jpg"
|
||||
img = Image.open(testdata)
|
||||
expect_channel = 3
|
||||
output_channel = vision.get_image_num_channels(img)
|
||||
output_channel = vision_utils.get_image_num_channels(img)
|
||||
assert expect_channel == output_channel
|
||||
|
||||
|
||||
|
@ -58,7 +60,7 @@ def test_get_image_num_channels_invalid_input():
|
|||
def test_invalid_input(test_name, image, error, error_msg):
|
||||
logger.info("Test get_image_num_channels with wrong params: {0}".format(test_name))
|
||||
with pytest.raises(error) as error_info:
|
||||
vision.get_image_num_channels(image)
|
||||
vision_utils.get_image_num_channels(image)
|
||||
assert error_msg in str(error_info.value)
|
||||
|
||||
invalid_input = 1
|
||||
|
|
|
@ -12,52 +12,54 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
|
||||
"""
|
||||
Test MindData vision utility get_image_size
|
||||
"""
|
||||
import numpy as np
|
||||
import pytest
|
||||
from PIL import Image
|
||||
|
||||
import mindspore.dataset.vision.utils as vision
|
||||
import mindspore.dataset.vision.c_transforms as C
|
||||
import mindspore.dataset.vision.utils as vision_utils
|
||||
import mindspore.dataset.vision as vision
|
||||
from mindspore import log as logger
|
||||
|
||||
|
||||
def test_get_image_size_output_array():
|
||||
"""
|
||||
Feature: get_image_num_channels array(after Decode array.shape is HWC)
|
||||
Description: Test get_image_num_channels
|
||||
Feature: get_image_size
|
||||
Description: Test get_image_size array
|
||||
Expectation: The returned result is as expected
|
||||
"""
|
||||
expect = [2268, 4032]
|
||||
img = np.fromfile("../data/dataset/apple.jpg", dtype=np.uint8)
|
||||
input_array = C.Decode()(img)
|
||||
output = vision.get_image_size(input_array)
|
||||
input_array = vision.Decode()(img)
|
||||
output = vision_utils.get_image_size(input_array)
|
||||
assert expect == output
|
||||
|
||||
|
||||
def test_get_image_num_size_output_img():
|
||||
def test_get_image_size_output_img():
|
||||
"""
|
||||
Feature: get_image_num_channels img(Image.size is [H, W])
|
||||
Description: Test get_image_num_channels
|
||||
Feature: get_image_size
|
||||
Description: Test get_image_size image (Image.size is [H, W])
|
||||
Expectation: The returned result is as expected
|
||||
"""
|
||||
expect = [2268, 4032]
|
||||
img = Image.open("../data/dataset/apple.jpg")
|
||||
output_size = vision.get_image_size(img)
|
||||
output_size = vision_utils.get_image_size(img)
|
||||
assert expect == output_size
|
||||
|
||||
|
||||
def test_get_image_num_channels_invalid_input():
|
||||
def test_get_image_size_invalid_input():
|
||||
"""
|
||||
Feature: get_image_num_channels
|
||||
Description: Test get_image_num_channels invalid input
|
||||
Feature: get_image_size
|
||||
Description: Test get_image_size invalid input
|
||||
Expectation: Correct error is raised as expected
|
||||
"""
|
||||
|
||||
def test_invalid_input(test_name, image, error, error_msg):
|
||||
logger.info("Test GetImageNumChannels with wrong params: {0}".format(test_name))
|
||||
logger.info("Test GetImageSize with wrong params: {0}".format(test_name))
|
||||
with pytest.raises(error) as error_info:
|
||||
vision.get_image_size(image)
|
||||
vision_utils.get_image_size(image)
|
||||
assert error_msg in str(error_info.value)
|
||||
|
||||
invalid_input = 1
|
||||
|
@ -71,5 +73,5 @@ def test_get_image_num_channels_invalid_input():
|
|||
|
||||
if __name__ == "__main__":
|
||||
test_get_image_size_output_array()
|
||||
test_get_image_num_size_output_img()
|
||||
test_get_image_num_channels_invalid_input()
|
||||
test_get_image_size_output_img()
|
||||
test_get_image_size_invalid_input()
|
||||
|
|
|
@ -80,7 +80,6 @@ def create_dataset_pyop_multiproc(num_parallel_workers=None, max_rowsize=16, bat
|
|||
lambda x: x,
|
||||
vision.HWC2CHW(),
|
||||
vision.RandomErasing(0.9, value='random'),
|
||||
vision.CutOut(4, 2, is_hwc=False),
|
||||
lambda y: y
|
||||
]
|
||||
compose_op = transforms.Compose(transforms_list)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
# Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -22,7 +22,7 @@ import numpy as np
|
|||
import pytest
|
||||
import mindspore.common.dtype as mstype
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as C
|
||||
import mindspore.dataset.transforms as transforms
|
||||
import mindspore._c_dataengine as cde
|
||||
from mindspore.profiler.parser.minddata_analyzer import MinddataProfilingAnalyzer
|
||||
|
||||
|
@ -143,14 +143,16 @@ class TestMinddataProfilingAnalyzer:
|
|||
|
||||
def test_analyze_basic(self, tmp_path):
|
||||
"""
|
||||
Test MindData profiling analyze summary files exist with basic pipeline.
|
||||
Also test basic content (subset of keys and values) from the returned summary result.
|
||||
Feature: MindData Profiling Analyzer
|
||||
Description: Test MindData profiling analyze summary files exist with basic pipeline.
|
||||
Also test basic content (subset of keys and values) from the returned summary result.
|
||||
Expectation: MindData Profiling Analyzer output is as expected
|
||||
"""
|
||||
|
||||
# Create this basic and common linear pipeline
|
||||
# Generator -> Map -> Batch -> Repeat -> EpochCtrl
|
||||
data1 = ds.GeneratorDataset(self.mysource, ["col1"])
|
||||
type_cast_op = C.TypeCast(mstype.int32)
|
||||
type_cast_op = transforms.TypeCast(mstype.int32)
|
||||
data1 = data1.map(operations=type_cast_op, input_columns="col1")
|
||||
data1 = data1.batch(16)
|
||||
data1 = data1.repeat(2)
|
||||
|
@ -206,13 +208,15 @@ class TestMinddataProfilingAnalyzer:
|
|||
|
||||
def test_analyze_sequential_pipelines_invalid(self, tmp_path):
|
||||
"""
|
||||
Test invalid scenario in which MinddataProfilingAnalyzer is called for two sequential pipelines.
|
||||
Feature: MindData Profiling Analyzer
|
||||
Description: Test invalid scenario in which MinddataProfilingAnalyzer is called for two sequential pipelines.
|
||||
Expectation: MindData Profiling Analyzer output in each pipeline is as expected
|
||||
"""
|
||||
|
||||
# Create the pipeline
|
||||
# Generator -> Map -> Batch -> EpochCtrl
|
||||
data1 = ds.GeneratorDataset(self.mysource, ["col1"])
|
||||
type_cast_op = C.TypeCast(mstype.int32)
|
||||
type_cast_op = transforms.TypeCast(mstype.int32)
|
||||
data1 = data1.map(operations=type_cast_op, input_columns="col1")
|
||||
data1 = data1.batch(64)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -17,13 +17,14 @@ import os
|
|||
|
||||
from mindspore import dataset as ds
|
||||
from mindspore.common import dtype as mstype
|
||||
from mindspore.dataset.transforms import c_transforms as C
|
||||
import mindspore.dataset.transforms as C
|
||||
from mindspore.dataset.vision import Inter
|
||||
from mindspore.dataset.vision import c_transforms as CV
|
||||
import mindspore.dataset.vision as CV
|
||||
from mindspore import nn, Tensor
|
||||
from mindspore.common.initializer import Normal
|
||||
from mindspore.ops import operations as P
|
||||
|
||||
|
||||
def create_mnist_dataset(mode='train', num_samples=2, batch_size=2):
|
||||
"""create dataset for train or test"""
|
||||
mnist_path = '/home/workspace/mindspore_dataset/mnist'
|
||||
|
|
|
@ -1,10 +1,25 @@
|
|||
# Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
"""Test export"""
|
||||
import os
|
||||
import numpy as np
|
||||
|
||||
import mindspore.nn as nn
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.vision.c_transforms as CV
|
||||
import mindspore.dataset.transforms.c_transforms as CT
|
||||
import mindspore.dataset.vision as CV
|
||||
import mindspore.dataset.transforms as CT
|
||||
from mindspore.dataset.vision import Inter
|
||||
from mindspore import context
|
||||
from mindspore.common import dtype as mstype
|
||||
|
|
Loading…
Reference in New Issue