Skip to content

Commit

Permalink
Improve visualization function with explicit figure closing
Browse files Browse the repository at this point in the history
  • Loading branch information
valhassan committed Feb 21, 2025
1 parent cb66c34 commit 0ba2dcd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion geo_deep_learning/tools/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def visualize_prediction(image,
plt.imsave(save_path / f"{sample_name}_prediction.png", prediction, cmap=cmap, vmin=0, vmax=num_classes-1)

# Create the visualization
plt.close('all')
fig, axes = plt.subplots(1, 3, figsize=(15, 5))
# axes = axes.reshape(num_samples, 3) if num_samples > 1 else axes.reshape(1, 3)

Expand Down Expand Up @@ -75,5 +76,5 @@ def visualize_prediction(image,

if save_path:
plt.savefig(save_path)

plt.close(fig)
return fig

0 comments on commit 0ba2dcd

Please sign in to comment.