提交 4f4211ef 编写于 作者: S SunAhong1993

fix

上级 ca747f65
......@@ -14,11 +14,11 @@
from __future__ import absolute_import
import os.path as osp
import platform
import random
import copy
import json
import paddlex.utils.logging as logging
from paddlex.utils import path_normalization
from .imagenet import ImageNet
from .dataset import is_pic
from .dataset import get_encoding
......@@ -65,18 +65,12 @@ class EasyDataCls(ImageNet):
item = line.strip()
self.labels.append(item)
logging.info("Starting to read file list from dataset...")
win_sep = "\\"
other_sep = "/"
with open(file_list, encoding=get_encoding(file_list)) as f:
for line in f:
img_file, json_file = [osp.join(data_dir, x) \
for x in line.strip().split()[:2]]
if platform.system() == "Windows":
img_file = win_sep.join(img_file.split(other_sep))
json_file = win_sep.join(json_file.split(other_sep))
else:
img_file = other_sep.join(img_file.split(win_sep))
json_file = other_sep.join(json_file.split(win_sep))
img_file = path_normalization(img_file)
json_file = path_normalization(json_file)
if not is_pic(img_file):
continue
if not osp.isfile(json_file):
......
......@@ -14,13 +14,13 @@
from __future__ import absolute_import
import os.path as osp
import platform
import random
import copy
import json
import cv2
import numpy as np
import paddlex.utils.logging as logging
from paddlex.utils import path_normalization
from .voc import VOCDetection
from .dataset import is_pic
from .dataset import get_encoding
......@@ -84,18 +84,12 @@ class EasyDataDet(VOCDetection):
from pycocotools.mask import decode
ct = 0
ann_ct = 0
win_sep = "\\"
other_sep = "/"
with open(file_list, encoding=get_encoding(file_list)) as f:
for line in f:
img_file, json_file = [osp.join(data_dir, x) \
for x in line.strip().split()[:2]]
if platform.system() == "Windows":
img_file = win_sep.join(img_file.split(other_sep))
json_file = win_sep.join(json_file.split(other_sep))
else:
img_file = other_sep.join(img_file.split(win_sep))
json_file = other_sep.join(json_file.split(win_sep))
img_file = path_normalization(img_file)
json_file = path_normalization(json_file)
if not is_pic(img_file):
continue
if not osp.isfile(json_file):
......
......@@ -14,13 +14,13 @@
from __future__ import absolute_import
import os.path as osp
import platform
import random
import copy
import json
import cv2
import numpy as np
import paddlex.utils.logging as logging
from paddlex.utils import path_normalization
from .dataset import Dataset
from .dataset import get_encoding
from .dataset import is_pic
......@@ -62,8 +62,6 @@ class EasyDataSeg(Dataset):
from pycocotools.mask import decode
cname2cid = {}
label_id = 0
win_sep = "\\"
other_sep = "/"
with open(label_list, encoding=get_encoding(label_list)) as fr:
for line in fr.readlines():
cname2cid[line.strip()] = label_id
......@@ -74,12 +72,8 @@ class EasyDataSeg(Dataset):
for line in f:
img_file, json_file = [osp.join(data_dir, x) \
for x in line.strip().split()[:2]]
if platform.system() == "Windows":
img_file = win_sep.join(img_file.split(other_sep))
json_file = win_sep.join(json_file.split(other_sep))
else:
img_file = other_sep.join(img_file.split(win_sep))
json_file = other_sep.join(json_file.split(win_sep))
img_file = path_normalization(img_file)
json_file = path_normalization(json_file)
if not is_pic(img_file):
continue
if not osp.isfile(json_file):
......
......@@ -14,10 +14,10 @@
from __future__ import absolute_import
import os.path as osp
import platform
import random
import copy
import paddlex.utils.logging as logging
from paddlex.utils import path_normalization
from .dataset import Dataset
from .dataset import is_pic
from .dataset import get_encoding
......@@ -64,15 +64,10 @@ class ImageNet(Dataset):
item = line.strip()
self.labels.append(item)
logging.info("Starting to read file list from dataset...")
win_sep = "\\"
other_sep = "/"
with open(file_list, encoding=get_encoding(file_list)) as f:
for line in f:
items = line.strip().split()
if platform.system() == "Windows":
items[0] = win_sep.join(items[0].split(other_sep))
else:
items[0] = other_sep.join(items[0].split(win_sep))
items[0] = path_normalization(items[0])
if not is_pic(items[0]):
continue
full_path = osp.join(data_dir, items[0])
......
......@@ -14,10 +14,10 @@
from __future__ import absolute_import
import os.path as osp
import platform
import random
import copy
import paddlex.utils.logging as logging
from paddlex.utils import path_normalization
from .dataset import Dataset
from .dataset import get_encoding
from .dataset import is_pic
......@@ -62,17 +62,11 @@ class SegDataset(Dataset):
for line in f:
item = line.strip()
self.labels.append(item)
win_sep = "\\"
other_sep = "/"
with open(file_list, encoding=get_encoding(file_list)) as f:
for line in f:
items = line.strip().split()
if platform.system() == "Windows":
items[0] = win_sep.join(items[0].split(other_sep))
items[1] = win_sep.join(items[1].split(other_sep))
else:
items[0] = other_sep.join(items[0].split(win_sep))
items[1] = other_sep.join(items[1].split(win_sep))
items[0] = path_normalization(items[0])
items[1] = path_normalization(items[1])
if not is_pic(items[0]):
continue
full_path_im = osp.join(data_dir, items[0])
......
......@@ -16,13 +16,13 @@ from __future__ import absolute_import
import copy
import os
import os.path as osp
import platform
import random
import re
import numpy as np
from collections import OrderedDict
import xml.etree.ElementTree as ET
import paddlex.utils.logging as logging
from paddlex.utils import path_normalization
from .dataset import Dataset
from .dataset import is_pic
from .dataset import get_encoding
......@@ -86,8 +86,6 @@ class VOCDetection(Dataset):
})
ct = 0
ann_ct = 0
win_sep = "\\"
other_sep = "/"
with open(file_list, 'r', encoding=get_encoding(file_list)) as fr:
while True:
line = fr.readline()
......@@ -95,12 +93,8 @@ class VOCDetection(Dataset):
break
img_file, xml_file = [osp.join(data_dir, x) \
for x in line.strip().split()[:2]]
if platform.system() == "Windows":
img_file = win_sep.join(img_file.split(other_sep))
xml_file = win_sep.join(xml_file.split(other_sep))
else:
img_file = other_sep.join(img_file.split(win_sep))
xml_file = other_sep.join(xml_file.split(win_sep))
img_file = path_normalization(img_file)
xml_file = path_normalization(xml_file)
if not is_pic(img_file):
continue
if not osp.isfile(xml_file):
......
......@@ -23,6 +23,7 @@ import shutil
import numpy as np
import PIL.ImageDraw
from .base import MyEncoder, is_pic, get_encoding
from paddlex.utils import path_normalization
class X2COCO(object):
......@@ -101,12 +102,7 @@ class LabelMe2COCO(X2COCO):
image["height"] = json_info["imageHeight"]
image["width"] = json_info["imageWidth"]
image["id"] = image_id + 1
win_sep = "\\"
other_sep = "/"
if platform.system() == "Windows":
json_info["imagePath"] = win_sep.join(json_info["imagePath"].split(other_sep))
else:
json_info["imagePath"] = other_sep.join(json_info["imagePath"].split(win_sep))
json_info["imagePath"] = path_normalization(json_info["imagePath"])
image["file_name"] = osp.split(json_info["imagePath"])[-1]
return image
......@@ -194,12 +190,7 @@ class EasyData2COCO(X2COCO):
image["height"] = img.shape[0]
image["width"] = img.shape[1]
image["id"] = image_id + 1
win_sep = "\\"
other_sep = "/"
if platform.system() == "Windows":
img_path = win_sep.join(img_path.split(other_sep))
else:
img_path = other_sep.join(img_path.split(win_sep))
img_path = path_normalization(img_path)
image["file_name"] = osp.split(img_path)[-1]
return image
......
......@@ -17,6 +17,7 @@ from . import logging
from . import utils
from . import save
from .utils import seconds_to_hms
from .utils import path_normalization
from .download import download
from .download import decompress
from .download import download_and_decompress
......@@ -20,6 +20,7 @@ import numpy as np
import six
import yaml
import math
import platform
from . import logging
......@@ -49,6 +50,14 @@ def get_environ_info():
info['num'] = fluid.core.get_cuda_device_count()
return info
def path_normalization(path):
win_sep = "\\"
other_sep = "/"
if platform.system() == "Windows":
path = win_sep.join(path.split(other_sep))
else:
path = other_sep.join(path.split(win_sep))
return path
def parse_param_file(param_file, return_shape=True):
from paddle.fluid.proto.framework_pb2 import VarType
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册