|
import gradio as gr
|
|
import tensorflow as tf
|
|
import numpy as np
|
|
from PIL import Image
|
|
|
|
model_path = "pokemon_model_loretmar.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_abra = prediction[0][0]
|
|
p_aerodactyl = prediction[0][1]
|
|
p_eevee = prediction[0][2]
|
|
|
|
|
|
return {'Abra': p_abra, 'Aerodactyl': p_aerodactyl, 'Eevee': p_eevee}
|
|
|
|
|
|
input_image = gr.Image()
|
|
iface = gr.Interface(
|
|
fn=predict_pokemon,
|
|
inputs=input_image,
|
|
outputs=gr.Label(),
|
|
examples=["images/00000000.png", "images/00000001.png", "images/00000002.png", "images/00000003.png", "images/00000004.png", "images/00000005.jpg"],
|
|
|
|
description="TEST.")
|
|
|
|
iface.launch() |