def __get_numslices(self): ts = time.clock() # nums_slice = np.zeros(len(self.images_file_train), dtype='int') # for i, image_file in enumerate(self.images_file_train): # image_path = os.path.join(self.data_dir, image_file) # images = np.load(image_path) # nums_slice[i] = len(images) # print(nums_slice) # print(np.sum(nums_slice)) nums_slice = [41,96,276,44,177,168,183,167,186,133,189,90,226,64,181,89,241,59,37,276,110,123,119,111,250, \ 77,191,194,104,215,98,170,75,277,186,76,229,99,219,173,69,239,36,260,280,112,299,258,59,73, \ 189,29,176,116,189,233,214,179,89,92,205,118,232,56,67,170,113,169,189,132,192,139,114,194, \ 113,59,232,179,83,113,64,266,58,292,193,46,116,175,98,122,234,187,251,85,79,115,61,120,113, \ 118,215,50,37,263,56,259,215,241,248,91,149,201,79,29,198,227,112] # nums_slice = [41, 96, 276, 44, 177, 168, 183, 167, 186, 133, 189, 90] print("run time of importing all data: ", cvtSecond2HMS(time.clock() - ts)) return nums_slice
def __get_numslices(self): ts = time.clock() category = self.data_dir.split('/')[-1] info_file = 'cache/{0}/datasets/info.npy'.format(category) mkdirInCache(info_file) if os.path.isfile(info_file): self.images_file_train, nums_slice, self.images_file_test = np.load( info_file) else: nums_slice = np.zeros(len(self.images_file_train), dtype='int') for i, image_file in enumerate(self.images_file_train): image_path = os.path.join(self.data_dir, image_file) images = self._load_image(image_path) nums_slice[i] = len(images) np.save( info_file, (self.images_file_train, nums_slice, self.images_file_test)) # print(nums_slice) # print(np.sum(nums_slice)) # home # nums_slice = [41,96,276,44,177,168,183,167,186,133,189,90,226,64,181,89,241,59,37,276,110,123,119,111,250, \ # 77,191,194,104,215,98,170,75,277,186,76,229,99,219,173,69,239,36,260,280,112,299,258,59,73, \ # 189,29,176,116,189,233,214,179,89,92,205,118,232,56,67,170,113,169,189,132,192,139,114,194, \ # 113,59,232,179,83,113,64,266,58,292,193,46,116,175,98,122,234,187,251,85,79,115,61,120,113, \ # 118,215,50,37,263,56,259,215,241,248,91,149,201,79,29,198,227,112] # nums_slice = [41, 96, 276, 44, 177, 168, 183, 167, 186, 133, 189, 90] # office # nums_slice = [112, 36, 292, 132, 36, 241, 194, 59, 110, 56, 241, 194] # nums_slice = [112, 36] case_num = len(nums_slice) self.images_file_train, self.images_file_test, self.masks_file_train, self.masks_file_test = \ self.images_file_train[:case_num], self.images_file_test[:case_num], self.masks_file_train[ :case_num], self.masks_file_test[ :case_num] print("run time of importing {0} data is {1}".format( np.sum(nums_slice), cvtSecond2HMS(time.clock() - ts))) return nums_slice
modelcheckpoint='cache/breast/model/unet_gen_448_448_padecho.hdf5', batch_size=16, is_datagen=True, images_npy='cache/breast/datasets/images_pad_echo_448_448_tf.npy', masks_npy='cache/breast/datasets/masks_pad_echo_448_448_tf.npy') if __name__ == '__main__': # print_env() ts = time.clock() # (X_test, y_test, predicts) = run_unet_gen(istrain=False) # dice = 86.6 (X_test, y_test, predicts) = run_unet_gen_448_448(istrain=True) # dice = 84.7 # (X_test, y_test, predicts) = run_unet_gen_448_448_echo(istrain=False) # dice = 80.25 # (X_test, y_test, predicts) = run_unet_gen_448_448_padecho(istrain=False) # dice = 80.1 print("total process time: %s" % cvtSecond2HMS(time.clock() - ts)) # # for i in range(0, 1): # showImages(X_test[i, :, :, 0], y_test[i, :, :, 0], predicts[i, :, :, 0]) # # # for (image, mask, predict) in zip(X_test, y_test, predicts): # # seg.show(image[0, :, :], mask[0, :, :], predict[0, :, :]) # # plt.show()