path_normalization->norm_path

own
Bobholamovic 2 years ago
parent 9c382d82bb
commit 385348ff10
  1. 2
      docs/cases/csc_cd_cn.md
  2. 4
      paddlers/datasets/cd_dataset.py
  3. 4
      paddlers/datasets/clas_dataset.py
  4. 6
      paddlers/datasets/coco.py
  5. 6
      paddlers/datasets/seg_dataset.py
  6. 6
      paddlers/datasets/voc.py
  7. 4
      paddlers/utils/__init__.py
  8. 2
      paddlers/utils/utils.py

@ -365,7 +365,7 @@ class InferDataset(paddle.io.Dataset):
names = []
for line in lines:
items = line.strip().split(' ')
items = list(map(pdrs.utils.path_normalization, items))
items = list(map(pdrs.utils.norm_path, items))
item_dict = {
'image_t1': osp.join(data_dir, items[0]),
'image_t2': osp.join(data_dir, items[1])

@ -17,7 +17,7 @@ from enum import IntEnum
import os.path as osp
from .base import BaseDataset
from paddlers.utils import logging, get_encoding, path_normalization, is_pic
from paddlers.utils import logging, get_encoding, norm_path, is_pic
class CDDataset(BaseDataset):
@ -81,7 +81,7 @@ class CDDataset(BaseDataset):
"Line[{}] in file_list[{}] has an incorrect number of file paths.".
format(line.strip(), file_list))
items = list(map(path_normalization, items))
items = list(map(norm_path, items))
full_path_im_t1 = osp.join(data_dir, items[0])
full_path_im_t2 = osp.join(data_dir, items[1])

@ -16,7 +16,7 @@ import os.path as osp
import copy
from .base import BaseDataset
from paddlers.utils import logging, get_encoding, path_normalization, is_pic
from paddlers.utils import logging, get_encoding, norm_path, is_pic
class ClasDataset(BaseDataset):
@ -62,7 +62,7 @@ class ClasDataset(BaseDataset):
"A space is defined as the delimiter to separate the image and label path, " \
"so the space cannot be in the image or label path, but the line[{}] of " \
" file_list[{}] has a space in the image or label path.".format(line, file_list))
items[0] = path_normalization(items[0])
items[0] = norm_path(items[0])
full_path_im = osp.join(data_dir, items[0])
label = items[1]
if not is_pic(full_path_im):

@ -22,7 +22,7 @@ from collections import OrderedDict
import numpy as np
from .base import BaseDataset
from paddlers.utils import logging, get_encoding, path_normalization, is_pic
from paddlers.utils import logging, get_encoding, norm_path, is_pic
from paddlers.transforms import DecodeImg, MixupImage
from paddlers.tools import YOLOAnchorCluster
@ -102,8 +102,8 @@ class COCODetection(BaseDataset):
'name': k
})
anno_path = path_normalization(os.path.join(self.data_dir, anno_path))
image_dir = path_normalization(os.path.join(self.data_dir, image_dir))
anno_path = norm_path(os.path.join(self.data_dir, anno_path))
image_dir = norm_path(os.path.join(self.data_dir, image_dir))
assert anno_path.endswith('.json'), \
'invalid coco annotation file: ' + anno_path

@ -16,7 +16,7 @@ import os.path as osp
import copy
from .base import BaseDataset
from paddlers.utils import logging, get_encoding, path_normalization, is_pic
from paddlers.utils import logging, get_encoding, norm_path, is_pic
class SegDataset(BaseDataset):
@ -62,8 +62,8 @@ class SegDataset(BaseDataset):
"A space is defined as the delimiter to separate the image and label path, " \
"so the space cannot be in the image or label path, but the line[{}] of " \
" file_list[{}] has a space in the image or label path.".format(line, file_list))
items[0] = path_normalization(items[0])
items[1] = path_normalization(items[1])
items[0] = norm_path(items[0])
items[1] = norm_path(items[1])
full_path_im = osp.join(data_dir, items[0])
full_path_label = osp.join(data_dir, items[1])
if not is_pic(full_path_im) or not is_pic(full_path_label):

@ -24,7 +24,7 @@ import xml.etree.ElementTree as ET
import numpy as np
from .base import BaseDataset
from paddlers.utils import logging, get_encoding, path_normalization, is_pic
from paddlers.utils import logging, get_encoding, norm_path, is_pic
from paddlers.transforms import DecodeImg, MixupImage
from paddlers.tools import YOLOAnchorCluster
@ -115,8 +115,8 @@ class VOCDetection(BaseDataset):
img_file, xml_file = [
osp.join(data_dir, x) for x in line.strip().split()[:2]
]
img_file = path_normalization(img_file)
xml_file = path_normalization(xml_file)
img_file = norm_path(img_file)
xml_file = norm_path(xml_file)
if not is_pic(img_file):
continue
if not osp.isfile(xml_file):

@ -15,8 +15,8 @@
from . import logging
from . import utils
from .utils import (seconds_to_hms, get_encoding, get_single_card_bs, dict2str,
EarlyStop, path_normalization, is_pic, MyEncoder,
DisablePrint, Timer)
EarlyStop, norm_path, is_pic, MyEncoder, DisablePrint,
Timer)
from .checkpoint import get_pretrain_weights, load_pretrain_weights, load_checkpoint
from .env import get_environ_info, get_num_workers, init_parallel_env
from .download import download_and_decompress, decompress

@ -69,7 +69,7 @@ def dict2str(dict_input):
return out.strip(', ')
def path_normalization(path):
def norm_path(path):
win_sep = "\\"
other_sep = "/"
if platform.system() == "Windows":

Loading…
Cancel
Save