|
- # Copyright 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.
- # ============================================================================
-
- import os
- from custom_datasets import create_test_dataset
- from config import get_args
- from tools import *
-
- if __name__ == "__main__":
- c = get_args()
- c.action_type = 'norm-test'
- c.img_size = (c.input_size, c.input_size)
- c.crp_size = (c.input_size, c.input_size)
- c.norm_mean, c.norm_std = [0.485, 0.456, 0.406], [0.229, 0.224, 0.225]
- predata_result_dir = './predata_result/' + c.class_name
-
- if not os.path.exists('./predata_result/'):
- os.mkdir('./predata_result/')
- if not os.path.exists('./predata_result/' + c.class_name):
- os.mkdir('./predata_result/' + c.class_name)
- dataset = create_test_dataset(c, repeat_num=1, batch_size=c.batch_size, target="Ascend")
- I = dataset.get_dataset_size()
- data_iter = dataset.create_tuple_iterator()
-
- for i in range(I):
- image, label, mask = data_iter.__next__()
- # image[bs,3,H,W],label[bs],mask[bs,1,H,W]
- image = t2np(image)
- print(image.shape, image.dtype)
- image.tofile(os.path.join(predata_result_dir, c.class_name + "_batchimage_" + str(i) + '.bin'))
|