grobram1 commited on
Commit
b389d13
·
verified ·
1 Parent(s): 02681fb

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ from PIL import Image
4
+ import numpy as np
5
+
6
+ # Modellpfad
7
+ model_path = "pokemon_classifier_model.keras"
8
+
9
+ # Modell laden
10
+ model = tf.keras.models.load_model(model_path)
11
+
12
+ # Klassenlabels (Passe diese entsprechend deinem Modell an)
13
+ labels = ['Abra', 'Cloyster', 'Dodrio']
14
+
15
+ # Vorhersagefunktion
16
+ def predict(image):
17
+ # Bildvorverarbeitung
18
+ image = image.resize((64, 64))
19
+ image = np.array(image) / 255.0
20
+ image = np.expand_dims(image, axis=0)
21
+ predictions = model.predict(image)
22
+ confidences = {labels[i]: float(predictions[0][i]) for i in range(len(labels))}
23
+ return confidences
24
+
25
+ # Gradio-Interface erstellen
26
+ iface = gr.Interface(fn=predict,
27
+ inputs=gr.inputs.Image(shape=(64, 64)),
28
+ outputs=gr.outputs.Label(),
29
+ description="Pokémon Classifier")
30
+
31
+ if __name__ == "__main__":
32
+ iface.launch()