| import gradio as gr
|
| import tensorflow as tf
|
| print(tf.__version__)
|
| import numpy as np
|
| from PIL import Image
|
|
|
| model_path = "pokemon_transferlearning.keras"
|
| model = tf.keras.models.load_model(model_path)
|
|
|
|
|
| def predict_pokemon(image):
|
|
|
| print(type(image))
|
| image = Image.fromarray(image.astype('uint8'))
|
| image = image.resize((150, 150))
|
| image = np.array(image)
|
| image = np.expand_dims(image, axis=0)
|
|
|
|
|
| prediction = model.predict(image)
|
|
|
|
|
|
|
| prediction = np.round(prediction, 2)
|
|
|
|
|
| p_blastoise = prediction[0][0]
|
| p_caterpie = prediction[0][1]
|
| p_diglett = prediction[0][2]
|
|
|
| return {'blastoise': p_blastoise, 'caterpie': p_caterpie, 'diglett': p_diglett}
|
|
|
|
|
|
|
| input_image = gr.Image()
|
| iface = gr.Interface(
|
| fn=predict_pokemon,
|
| inputs=input_image,
|
| outputs=gr.Label(),
|
| examples=["Sample_images/sample1.png", "Sample_images/sample2.jpg", "Sample_images/sample3.jpg", "Sample_images/sample4.png", "Sample_images/sample5.jpg", "Sample_images/sample6.png"],
|
| description="TEST.")
|
|
|
| iface.launch() |