Commit 5f722c8b authored by sjromuel's avatar sjromuel
Browse files

d

parent 194d9312
......@@ -94,7 +94,7 @@ def main():
img_path = "data/npy_thresh/"
#specificmodels = [0, 1, 2, 3]
specificmodels = [6]
specificmodels = [0]
if cross_val:
log = open("logs" + modelname + ".txt", "w+")
log.write(modelname + "\r")
......
......@@ -21,7 +21,7 @@ def main():
root = tk.Tk()
root.withdraw()
file_path = filedialog.askopenfilename(initialdir="saves/")
file_path = filedialog.askopenfilename(initialdir="finalResults/")
file_path = file_path[:-9]
print(file_path)
......@@ -162,10 +162,18 @@ def main():
print(test_patients)
TP_num = test_patients[j]
#test_patient_pred = run_test_patient(test_dataset, weights, filter_multiplier)
np.save(img_savepath + "P" + str(TP_num).zfill(2) +"_Inputimg3D", X_test)
np.save(img_savepath + "P" + str(TP_num).zfill(2) + "_gt3D", GT_test)
np.save(img_savepath + "P" + str(TP_num).zfill(2) + "_true3D", ytrue)
###################################################################################
detailed_images = True
npys3d = False
###################################################################################
if npys3d:
#test_patient_pred = run_test_patient(test_dataset, weights, filter_multiplier)
np.save(img_savepath + "P" + str(TP_num).zfill(2) +"_Inputimg3D", X_test)
np.save(img_savepath + "P" + str(TP_num).zfill(2) + "_gt3D", GT_test)
np.save(img_savepath + "P" + str(TP_num).zfill(2) + "_true3D", ytrue)
......@@ -178,12 +186,14 @@ def main():
image, y_true = features
y_true = onehotencode(y_true)
y_pred = Unet(image, weights, filter_multiplier, training=False)
if y_pred3d == []:
y_pred3d = y_pred[:,:,:,0].numpy()
else:
y_pred3d = np.append(y_pred[:,:,:,0].numpy(), y_pred3d, axis=0)
print(np.shape(y_pred3d))
if detailed_images:
if y_pred3d == []:
y_pred3d = y_pred[:,:,:,0].numpy()
else:
y_pred3d = np.append(y_pred[:,:,:,0].numpy(), y_pred3d, axis=0)
print(np.shape(y_pred3d))
# print(tf.shape(y_pred), tf.shape(y_true))
#y_true = onehotencode(tf.reshape(y_true, (1, 512, 512, 1)), autoencoder=True)
#y_pred = tf.reshape(y_pred, (1, 512, 512, 2))
......@@ -232,25 +242,27 @@ def main():
# save images:
matplotlib.image.imsave(img_savepath + "P" + str(TP_num).zfill(2) +"_" + str(counter).zfill(2)+"_Inputimg.png", image[0,:,:,0],
cmap=plt.cm.bone)
matplotlib.image.imsave(img_savepath + "P" + str(TP_num).zfill(2) +"_" + str(counter).zfill(2) + "_ytrue.png",
y_true[0, :, :, 0],
cmap=plt.cm.bone)
matplotlib.image.imsave(img_savepath + "P" + str(TP_num).zfill(2) +"_" + str(counter).zfill(2) + "_ytrain.png",
GT_test[counter-1, :, :, 0],
cmap=plt.cm.bone)
if 'Cluster' in file_path:
matplotlib.image.imsave(img_savepath + "P" + str(TP_num).zfill(2) +"_" + str(counter).zfill(2) + "_clusterpred.png",
y_pred[0, :, :, 0], cmap=plt.cm.bone)
elif 'class' in file_path:
matplotlib.image.imsave(img_savepath + "P" + str(TP_num).zfill(2) +"_" + str(counter).zfill(2) + "_classpred.png",
if detailed_images:
matplotlib.image.imsave(img_savepath + "P" + str(TP_num).zfill(2) +"_" + str(counter).zfill(2)+"_Inputimg.png", image[0,:,:,0],
cmap=plt.cm.bone)
matplotlib.image.imsave(img_savepath + "P" + str(TP_num).zfill(2) +"_" + str(counter).zfill(2) + "_ytrue.png",
y_true[0, :, :, 0],
cmap=plt.cm.bone)
matplotlib.image.imsave(img_savepath + "P" + str(TP_num).zfill(2) +"_" + str(counter).zfill(2) + "_ytrain.png",
GT_test[counter-1, :, :, 0],
cmap=plt.cm.bone)
if 'Cluster' in file_path:
matplotlib.image.imsave(img_savepath + "P" + str(TP_num).zfill(2) +"_" + str(counter).zfill(2) + "_clusterpred"+ str(loss)[0:6] +".png",
y_pred[0, :, :, 0], cmap=plt.cm.bone)
elif 'class' in file_path:
matplotlib.image.imsave(img_savepath + "P" + str(TP_num).zfill(2) +"_" + str(counter).zfill(2) + "_classpred"+ str(loss)[0:6] +".png",
y_pred[0, :, :, 0], cmap=plt.cm.bone)
else:
matplotlib.image.imsave(img_savepath + "P" + str(TP_num).zfill(2) + "_" + str(counter).zfill(2) + "_unetpred"+ str(loss)[0:6] +".png",
y_pred[0, :, :, 0], cmap=plt.cm.bone)
else:
matplotlib.image.imsave(img_savepath + "P" + str(TP_num).zfill(2) + "_" + str(counter).zfill(2) + "_unetpred.png",
y_pred[0, :, :, 0], cmap=plt.cm.bone)
np.save(img_savepath + "P" + str(TP_num).zfill(2) + "_pred3D", y_pred3d)
if npys3d:
np.save(img_savepath + "P" + str(TP_num).zfill(2) + "_pred3D", y_pred3d)
#plt.show()
#print(test_loss)
print("TestLoss Mean for P", test_patients[j], ": ", np.mean(test_loss))
......
Supports Markdown
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