Pokemon / app.py
heinini2's picture
Update app.py
4899da6 verified
raw
history blame
977 Bytes
import gradio as gr
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing.image import img_to_array, load_img
import numpy as np
# Modell laden
model = load_model('pokemon-model.keras')
def classify_image(image):
image = image.resize((224, 224)) # passende Größe für das Modell
image = img_to_array(image) # Bild in Array umwandeln
image = np.expand_dims(image, axis=0) # Dimension hinzufügen
image /= 255.0 # Normalisierung
prediction = model.predict(image) # Vorhersage vom Modell
classes = ['Squirtle', 'Pikachu', 'Charizard', 'Butterfree'] # Klassen
return {classes[i]: float(prediction[0][i]) for i in range(4)} # Wahrscheinlichkeiten zurückgeben
iface = gr.Interface(
classify_image,
gr.inputs.Image(shape=(224, 224)),
gr.outputs.Label(num_top_classes=4),
title="Pokémon Classifier",
description="Upload an image of a Pokémon and see the model classify it!"
)
iface.launch()