Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.