-
Notifications
You must be signed in to change notification settings - Fork 15
/
read_LIP_data.py
52 lines (40 loc) · 1.58 KB
/
read_LIP_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Hide the warning messages about CPU/GPU
import TensorflowUtils as utils
import glob
from tensorflow.python.platform import gfile
from six.moves import cPickle as pickle
import random
import numpy as np
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
"""
get test and validation file list
search the directory (*.jpg for input and *.png for annoation), save it into pickle file not to repeat the same serach process
"""
def read_dataset(data_dir):
# sample record: {'image': f, 'annotation': annotation_file,
# 'filename': filename}
training_records = []
testdir = "D:/Datasets/LIP/training/images/"
print("## Training dir:", testdir)
for filename in glob.glob(testdir + '*.jpg'): # assuming jpg files
record = {'image': None, 'annotation': None, 'filename': None}
record['image'] = filename
record['filename'] = filename
record['annotation'] = filename.replace(
"images", "labels").replace(
"jpg", "png")
training_records.append(record)
validation_records = []
validationdir = "D:/Datasets/LIP/validation/images/"
print("## Validation dir:", validationdir)
for filename in glob.glob(
validationdir + '*.jpg'): # assuming jpg files
record = {'image': None, 'annotation': None, 'filename': None}
record['image'] = filename
record['filename'] = filename
record['annotation'] = filename.replace(
"images", "labels").replace(
"jpg", "png")
validation_records.append(record)
return training_records, validation_records