gassmdav commited on
Commit
0795798
1 Parent(s): fd18056

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -44
app.py DELETED
@@ -1,44 +0,0 @@
1
- import gradio as gr
2
- import tensorflow as tf
3
- from PIL import Image
4
- import numpy as np
5
-
6
- # Laden des vortrainierten Pokémon-Modells
7
- model_path = "kia_pokemon_keras_model.h5"
8
- model = tf.keras.models.load_model(model_path)
9
-
10
- # Labels für den Pokémon Classifier (angepasst an Ihre Klassen)
11
- labels = [
12
- 'Charmander', 'Bulbasaur', 'Squirtle'
13
- ]
14
-
15
- def predict_pokemon(image):
16
- # Bild konvertieren und Größe anpassen
17
- image = Image.fromarray(image).resize((224, 224))
18
- # Normalisieren und in ein numpy-Array umwandeln
19
- image = np.array(image) / 255.0
20
- # Reshape für das Modell (erwarte 3 Farbkanäle)
21
- image = image.reshape(1, 224, 224, 3)
22
-
23
- # Vorhersage treffen
24
-
25
- predictions = model.predict(image)
26
- prediction = np.argmax(predictions, axis=1)[0]
27
- confidence = np.max(predictions)
28
-
29
- # Vorbereiten der Ausgabe
30
- result = f"Predicted Pokémon: {labels[prediction]} with confidence: {confidence:.2f}"
31
- return result
32
-
33
- # Erstellen der Gradio-Oberfläche
34
- input_image = gr.Image(width=224, height=224, image_mode='RGB')
35
- output_label = gr.Label()
36
- interface = gr.Interface(fn=predict_pokemon,
37
- inputs=input_image,
38
- outputs=output_label,
39
- examples=["images/bulbasaur.png", "images/charmander.png", "images/squirtle.png"],
40
- title="Pokémon Classifier",
41
- description="Drag and drop an image or select an example below to predict the Pokémon.")
42
-
43
- # Interface starten
44
- interface.launch()