Advertisement
Merevoli

Untitled

Apr 21st, 2022
35
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. from PIL import Image
  3. from tensorflow import keras
  4. import tensorflow as tf
  5.  
  6. def format_y(y):
  7. return ''.join(map(lambda x: chr(int(x)), y))
  8.  
  9. im = Image.open('./image_data/4.jpg')
  10. images = []
  11. image = np.array(im) / 255.0
  12. images.append(np.array(image))
  13. images = np.array(images)
  14.  
  15. model = keras.models.load_model('./captcha_model_keras_90.h5')
  16. # image = model.predict_on_batch(images)
  17. y_pred = model.predict(images)
  18. y_pred = tf.math.argmax(y_pred, axis=-1)
  19. captcha = format_y(y_pred[0])
  20.  
  21. print(captcha)
Advertisement
RAW Paste Data Copied
Advertisement