48 Star 506 Fork 1.3K

Ascend/ModelZoo-PyTorch

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.gitee
ACL_PyTorch
built-in
contrib
audio
cv
classfication
detection
face
gan
image_process
image_registration/superpoint
image_retrieval/BLIP
pose_estimation
quality_enhancement
segmentation
3D_HRNet
3D_Nested_Unet
Cascade_Mask_RCNN
Cascade_Mask_RCNN_UniFormer
Cascade_RCNN
DPT
DeeplabV3+
DeeplabV3
ENet
ErfNet
FCN-8s
FastSCNN
GCNet
ICNet
IntraDA
Maskrcnn-mmdet
Nested_UNet
OCRNet
PSPNet
PointRend
PraNet
RefineNet
SETR
SOLOV1
SOLOV2
STDC
SeMask
Segformer
Segmenter
SiamMask
Swin-Transformer-Semantic-Segmentation
Transformer-SSL
UNet
Ultra-Fast-Lane-Detection
LICENSE
README.md
UFLD_aipp.config
UFLD_postprocess.py
UFLD_preprocess.py
UFLD_pth2onnx.py
modelzoo_level.txt
requirements.txt
VNet
Wseg
YOLACT
YOLACT_plus
swin100
swin_97
swin_98
swin_99
.keep
.modelparent
Cascade_
super_resolution
tracking
video_understanding
knowledge
nlp
rl
CONTRIBUTING.md
ENVIRONMENTS.md
docs
images
README.md
environment.md
get_modelID.py
MindIE
PyTorch
.gitignore
CONTRIBUTING_TRAIN.md
LICENSE
NOTICE
OWNERS
README.md
Third_Party_Open_Source_Software_Notice
克隆/下载
UFLD_preprocess.py 1.98 KB
一键复制 编辑 原始数据 按行查看 历史
# 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
import argparse
import tqdm
import numpy as np
from PIL import Image
import torch
import torchvision.transforms as transforms
def jpg_to_bin(dataset_path, bin_path):
test_txt_path = os.path.join(dataset_path, 'test.txt')
image_names = []
with open(test_txt_path, 'r', encoding='utf-8') as f:
image_names = f.readlines()
preprocess = transforms.Compose(
[transforms.Resize((288, 800)),])
if not os.path.isdir(bin_path):
os.makedirs(bin_path)
for img_name in tqdm.tqdm(image_names):
src_path = os.path.join(dataset_path, img_name.strip())
if not os.path.isfile(src_path):
continue
dst_path = os.path.join(bin_path,
img_name.strip().replace('/', '-').replace('.jpg', '.bin'))
image = Image.open(src_path).convert('RGB')
input_tensor = preprocess(image)
img = np.array(input_tensor).astype(np.uint8)
img.tofile(dst_path)
if __name__=='__main__':
parser = argparse.ArgumentParser(
'convert original image to bin file.')
parser.add_argument('--dataset-path', type=str,
help='the root path of the dataset.')
parser.add_argument('--bin-path', type=str,
help='a directory to save bin file.')
args = parser.parse_args()
jpg_to_bin(args.dataset_path, args.bin_path)
print('Preprocess Done.')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/ascend/ModelZoo-PyTorch.git
git@gitee.com:ascend/ModelZoo-PyTorch.git
ascend
ModelZoo-PyTorch
ModelZoo-PyTorch
master

搜索帮助