Commit 445d587e authored by zhiyang.zhou's avatar zhiyang.zhou

fix a bug of preprocess_data

parent 96e31bcc
......@@ -89,32 +89,33 @@ def preprocess_data():
if os.path.isdir(path):
# take image dir and xlsx file
sub_paths = os.listdir(path)
img_path = None
img_paths = []
xlsx_path = None
for j in range(0, len(sub_paths)):
sub_path = os.path.join(path, sub_paths[j])
if os.path.isdir(sub_path):
img_path = sub_path
img_paths.append(sub_path)
elif os.path.isfile(sub_path):
xlsx_path = sub_path
# take patient info
# take images
processed_dir = './processed-data'
if not os.path.exists(processed_dir):
os.makedirs(processed_dir)
img_files = os.listdir(img_path)
for k in range(0, len(img_files)):
img_file = os.path.join(img_path, img_files[k])
img_file_only = img_files[k]
islabeled, name, label = check_label(xlsx_path, img_file_only, property=property)
if islabeled and label!=None:
if label >= 8:
continue
tmpstrs = os.path.splitext(img_file_only)
dst_img_file_only = tmpstrs[0] + '-' + property + '_' + str(label) + tmpstrs[1]
dst_img_file = os.path.join(processed_dir, dst_img_file_only)
copyfile(img_file, dst_img_file)
for img_path in img_paths:
processed_dir = './processed-data'
if not os.path.exists(processed_dir):
os.makedirs(processed_dir)
img_files = os.listdir(img_path)
for k in range(0, len(img_files)):
img_file = os.path.join(img_path, img_files[k])
img_file_only = img_files[k]
islabeled, name, label = check_label(xlsx_path, img_file_only, property=property)
if islabeled and label!=None:
if label >= 8:
continue
tmpstrs = os.path.splitext(img_file_only)
dst_img_file_only = tmpstrs[0] + '-' + property + '_' + str(label) + tmpstrs[1]
dst_img_file = os.path.join(processed_dir, dst_img_file_only)
copyfile(img_file, dst_img_file)
def crop_img():
from PIL import Image
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment