Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ import numpy as np
|
|
6 |
# Lade dein Modell
|
7 |
model_path = "pokemon-model.keras"
|
8 |
model = tf.keras.models.load_model(model_path)
|
|
|
9 |
|
10 |
# Klassen Labels für deine vier Pokémon
|
11 |
labels = ['Squirtle', 'Pikachu', 'Charizard', 'Butterfree']
|
@@ -15,14 +16,14 @@ def predict_pokemon(image):
|
|
15 |
# Bildvorverarbeitung
|
16 |
image = Image.fromarray(image.astype('uint8'), 'RGB')
|
17 |
image = image.resize((150, 150)) # Anpassen der Bildgröße an das Modell
|
18 |
-
image = np.array(image)
|
19 |
-
|
|
|
20 |
# Bild in das Modell einspeisen und Vorhersage treffen
|
21 |
-
prediction = model.predict(
|
22 |
-
confidences = {labels[i]:
|
23 |
return confidences
|
24 |
|
25 |
-
|
26 |
# Gradio Interface definieren
|
27 |
input_image = gr.Image()
|
28 |
output_text = gr.Textbox(label="Predicted Pokemon")
|
|
|
6 |
# Lade dein Modell
|
7 |
model_path = "pokemon-model.keras"
|
8 |
model = tf.keras.models.load_model(model_path)
|
9 |
+
model.summary() # Check if the model architecture loaded matches the expected one
|
10 |
|
11 |
# Klassen Labels für deine vier Pokémon
|
12 |
labels = ['Squirtle', 'Pikachu', 'Charizard', 'Butterfree']
|
|
|
16 |
# Bildvorverarbeitung
|
17 |
image = Image.fromarray(image.astype('uint8'), 'RGB')
|
18 |
image = image.resize((150, 150)) # Anpassen der Bildgröße an das Modell
|
19 |
+
image = np.array(image) # Normalisieren der Pixelwerte
|
20 |
+
print(image.shape)
|
21 |
+
|
22 |
# Bild in das Modell einspeisen und Vorhersage treffen
|
23 |
+
prediction = model.predict(image[None, ...])
|
24 |
+
confidences = {labels[i]: np.round(float(prediction[0][i]), 2) for i in range(len(labels))} return confidences
|
25 |
return confidences
|
26 |
|
|
|
27 |
# Gradio Interface definieren
|
28 |
input_image = gr.Image()
|
29 |
output_text = gr.Textbox(label="Predicted Pokemon")
|