import gradio as gr import tensorflow as tf from PIL import Image import numpy as np # Lade dein Modell model_path = "your_pokemon_model.keras" # Klassen Labels für deine vier Pokémon labels = ['Squirtle', 'Pikachu', 'Charizard', 'Butterfree'] def predict_pokemon(image): # Bildvorverarbeitung image = Image.fromarray(image.astype('uint8'), 'RGB') image = image.resize((224, 224)) # Anpassen der Bildgröße an das Modell image = np.array(image) / 255.0 # Normalisieren der Pixelwerte # Bild in das Modell einspeisen und Vorhersage treffen prediction = model.predict(np.expand_dims(image, axis=0)) confidences = {labels[i]: float(np.round(prediction[0][i], 2)) for i in range(len(labels))} return confidences # Gradio Interface definieren iface = gr.Interface( fn=predict_pokemon, inputs=gr.inputs.Image(shape=(224, 224), image_mode='RGB', tool='editor'), # Eingabe als Bild outputs=gr.outputs.Label(num_top_classes=4), # Zeige die Top-4 Vorhersagen title="Pokémon Classifier", description="Upload an image of a Pokémon and see the model classify it!" ) # Starte die Gradio-Schnittstelle iface.launch()