더북(TheBook)

그다음 데이터 세트를 만드는 과정을 진행합니다.

def make_dataset(image_file_path_list, xml_file_path_list, Classes_inDataSet):

    def process_image(image_file_path):  # ①
        image = cv2.imread(image_file_path)
        return cv2.resize(image, (224, 224)) / 255.0

    image_dataset = [process_image(image_path) for image_path in tqdm(image_file_path_list, desc="Processing images")]  # ②
    label_dataset = [get_label_fromImage(xml_path, Classes_inDataSet) for xml_path in tqdm(xml_file_path_list, desc="Processing labels")]  # ③

    image_dataset = np.array(image_dataset, dtype=np.float32)
    label_dataset = np.array(label_dataset, dtype=np.float32).reshape(-1, 7, 7, 25) # ④

    return image_dataset, tf.convert_to_tensor(label_dataset)

train_image_dataset, train_label_dataset = make_dataset(image_file_path_list,xml_file_path_list,classes_inDataSet)
test_image_dataset, test_label_dataset = make_dataset(test_image_file_path_list,test_xml_file_path_list,classes_inDataSet)
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.