Skip to content
Snippets Groups Projects
Commit e3837fb3 authored by Tamino Huxohl's avatar Tamino Huxohl
Browse files

implement capability to save visulizations of model predictions

parent 18aa3d5a
No related branches found
No related tags found
No related merge requests found
......@@ -65,7 +65,7 @@ def main(
_mse = mse(prediction, mu_map)
print_func(f"{_id:03d} | {_nmae:.6f} | {_mse:.6f}")
prediction = np.clip(prediction, 0, prediction.max())
prediction = np.clip(prediction, 0, mu_map.max())
diff = np.abs(prediction - mu_map)
volumes = [prediction, mu_map, diff]
......@@ -75,6 +75,8 @@ def main(
_slice = 0
_break_outer = False
timeout = 100
show_text = True
while True:
images = map(lambda v: v[_slice], volumes)
images = map(
......@@ -83,13 +85,14 @@ def main(
images = map(lambda img: cv.resize(img, (512, 512)), images)
images = list(images)
txt = f"{str(_slice):{len(str(n_slices))}}/{n_slices}"
cv.putText(images[0], txt, (0, 30), cv.FONT_HERSHEY_SIMPLEX, 1, 255, 3)
if show_text:
txt = f"{str(_slice):{len(str(n_slices))}}/{n_slices}"
cv.putText(images[0], txt, (0, 30), cv.FONT_HERSHEY_SIMPLEX, 1, 255, 3)
_slice = (_slice + 1) % n_slices
cv.imshow(wname, join_images(images))
key = cv.waitKey(100)
key = cv.waitKey(timeout)
if action is not None and action(key):
_break_outer = True
break
......@@ -102,6 +105,19 @@ def main(
_slice = (_slice - 2) % n_slices
elif key == ord("p"):
timeout = 0 if timeout > 0 else 100
elif key == ord("t"):
show_text = not show_text
_slice = (_slice - 1) % n_slices
elif key == ord("s"):
_slice = (_slice - 1) % n_slices
cv.imwrite("prediction.png", images[0])
cv.imwrite("mu_map.png", images[1])
cv.imwrite("difference.png", images[2])
with open("info.txt", mode="w") as f:
f.write(f"Arguments: {args}\n")
f.write("\n")
f.write(f"Id: {_id}\n")
f.write(f"Slice: {_slice}\n")
if _break_outer:
break
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment