Skip to content

Commit 5eac46c

Browse files
committed
update load voc for windows platform - os.path.join
1 parent 436aaf4 commit 5eac46c

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

tensorlayer/files.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,8 @@ def load_celebA_dataset(dirpath='data'):
707707
data_files[i] = os.path.join(image_path, data_files[i])
708708
return data_files
709709

710-
def load_voc_dataset(path='data/VOC', dataset='2012', contain_classes_in_person=False):
711-
""" Pascal VOC 2012 Dataset has 20 objects "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"`` and additional 3 classes ``"head", "hand", "foot" for person.
710+
def load_voc_dataset(path='data', dataset='2012', contain_classes_in_person=False):
711+
""" Pascal VOC 2012 Dataset has 20 objects "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor" and additional 3 classes "head", "hand", "foot" for person.
712712
713713
Parameters
714714
-----------
@@ -774,6 +774,7 @@ def load_voc_dataset(path='data/VOC', dataset='2012', contain_classes_in_person=
774774
- `Pascal VOC2007 Website <http://host.robots.ox.ac.uk/pascal/VOC/voc2007/>`_.
775775
- `TensorFlow/Models/object-detection <https://github.com/zsdonghao/object-detection/blob/master/g3doc/preparing_inputs.md>`_.
776776
"""
777+
path= os.path.join(path, 'VOC')
777778

778779
def _recursive_parse_xml_to_dict(xml):
779780
"""Recursively parses XML contents to python dict.
@@ -842,28 +843,32 @@ def _recursive_parse_xml_to_dict(xml):
842843
print("[VOC] object classes {}".format(classes_dict))
843844

844845
##======== 1. image path list
845-
folder_imgs = path+"/"+extracted_filename+"/JPEGImages/"
846+
# folder_imgs = path+"/"+extracted_filename+"/JPEGImages/"
847+
folder_imgs = os.path.join(path, extracted_filename, "JPEGImages")
846848
imgs_file_list = load_file_list(path=folder_imgs, regx='\\.jpg', printable=False)
847849
print("[VOC] {} images found".format(len(imgs_file_list)))
848850
imgs_file_list.sort(key=lambda s : int(s.replace('.',' ').replace('_', '').split(' ')[-2])) # 2007_000027.jpg --> 2007000027
849851
imgs_file_list = [folder_imgs+s for s in imgs_file_list]
850852
# print('IM',imgs_file_list[0::3333], imgs_file_list[-1])
851853
##======== 2. semantic segmentation maps path list
852-
folder_semseg = path+"/"+extracted_filename+"/SegmentationClass/"
854+
# folder_semseg = path+"/"+extracted_filename+"/SegmentationClass/"
855+
folder_semseg = os.path.join(path, extracted_filename, "SegmentationClass")
853856
imgs_semseg_file_list = load_file_list(path=folder_semseg, regx='\\.png', printable=False)
854857
print("[VOC] {} maps for semantic segmentation found".format(len(imgs_semseg_file_list)))
855858
imgs_semseg_file_list.sort(key=lambda s : int(s.replace('.',' ').replace('_', '').split(' ')[-2])) # 2007_000032.png --> 2007000032
856859
imgs_semseg_file_list = [folder_semseg+s for s in imgs_semseg_file_list]
857860
# print('Semantic Seg IM',imgs_semseg_file_list[0::333], imgs_semseg_file_list[-1])
858861
##======== 3. instance segmentation maps path list
859-
folder_insseg = path+"/"+extracted_filename+"/SegmentationObject/"
862+
# folder_insseg = path+"/"+extracted_filename+"/SegmentationObject/"
863+
folder_insseg = os.path.join(path, extracted_filename, "SegmentationObject")
860864
imgs_insseg_file_list = load_file_list(path=folder_insseg, regx='\\.png', printable=False)
861865
print("[VOC] {} maps for instance segmentation found".format(len(imgs_semseg_file_list)))
862866
imgs_insseg_file_list.sort(key=lambda s : int(s.replace('.',' ').replace('_', '').split(' ')[-2])) # 2007_000032.png --> 2007000032
863867
imgs_insseg_file_list = [folder_semseg+s for s in imgs_insseg_file_list]
864868
# print('Instance Seg IM',imgs_insseg_file_list[0::333], imgs_insseg_file_list[-1])
865869
##======== 4. annotations for bounding box and object class
866-
folder_ann = path+"/"+extracted_filename+"/Annotations/"
870+
# folder_ann = path+"/"+extracted_filename+"/Annotations/"
871+
folder_ann = os.path.join(path, extracted_filename, "Annotations")
867872
imgs_ann_file_list = load_file_list(path=folder_ann, regx='\\.xml', printable=False)
868873
print("[VOC] {} XML annotation files for bounding box and object class found".format(len(imgs_ann_file_list)))
869874
imgs_ann_file_list.sort(key=lambda s : int(s.replace('.',' ').replace('_', '').split(' ')[-2])) # 2007_000027.xml --> 2007000027

0 commit comments

Comments
 (0)