Skip to content

Commit

Permalink
Added saving single image
Browse files Browse the repository at this point in the history
  • Loading branch information
himat committed Apr 30, 2017
1 parent b1a0464 commit 77748a3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@
output_dir = "out"

# Uses pyplot to display the passed in image
def plot_single(image):
def plot_save_single(image, save_only=False, name=None):
if image.shape[2] == 1:
image = image.squeeze()
plt.imshow(image, cmap="Greys_r")
plt.show()

if save_only:
if name == None:
raise ValueError("Need a name for saving image to disk")

save_name = os.path.join(output_dir, name)
plt.savefig(save_name, bbox_inces='tight')
plt.close()
else:
plt.show()

# Plots a batch of images and optionally saves to disk
def plot_save_batch(batch, iter_num, save_only=False, prefix=""):
Expand Down

0 comments on commit 77748a3

Please sign in to comment.