Skip to content

Instantly share code, notes, and snippets.

@frogermcs
Created June 9, 2019 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frogermcs/cd146894962952cf926b928c08ae881e to your computer and use it in GitHub Desktop.
Save frogermcs/cd146894962952cf926b928c08ae881e to your computer and use it in GitHub Desktop.
from PIL import Image
VAL_BATCH_DIR = "validation_batch"
!mkdir {VAL_BATCH_DIR}
# Export batch to *.jpg files with specific naming convention.
# Make sure they are exported in the full quality, otherwise the inference
# process will return different results.
for n in range(32):
filename = "n{:0.0f}_true{:0.0f}_pred{:0.0f}.jpg".format(
n,
true_label_ids[n],
tflite_model_pred_simplified[n][0]
)
img_arr = np.copy(val_image_batch[n])
img_arr *= 255
img_arr = img_arr.astype("uint8")
img11 = Image.fromarray(img_arr, 'RGB')
img11.save("{}/{}".format(VAL_BATCH_DIR, filename), "JPEG", quality=100)
# Create archive with images
!tar -zcvf {VAL_BATCH_DIR}.tar.gz {VAL_BATCH_DIR}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment