Upload 2 files
Browse files- .gitattributes +1 -0
- app.py +43 -0
- pokemon_classifier_small_effnet.keras +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
pokemon_classifier_small_effnet.keras filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
+
from PIL import Image
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
# Laden Sie Ihr angepasstes EfficientNetB0-Modell
|
7 |
+
model_path = "pokemon_classifier_small_effnet.keras"
|
8 |
+
model = tf.keras.models.load_model(model_path)
|
9 |
+
|
10 |
+
labels = ['Arbok', 'Nidoking', 'Tauros']
|
11 |
+
|
12 |
+
# Vorverarbeitungsfunktion für das Bild
|
13 |
+
def preprocess_image(image):
|
14 |
+
image = Image.fromarray(image.astype('uint8'))
|
15 |
+
image = image.resize((224, 224))
|
16 |
+
image = np.array(image)
|
17 |
+
image = image / 255.0 # Normalisierung
|
18 |
+
return image
|
19 |
+
|
20 |
+
# Vorhersagefunktion mit postprocess
|
21 |
+
def predict_class(image):
|
22 |
+
image = preprocess_image(image)
|
23 |
+
prediction = model.predict(image[None, ...])
|
24 |
+
predicted_class = labels[np.argmax(prediction)]
|
25 |
+
confidence = np.round(np.max(prediction) * 100, 2)
|
26 |
+
result = f"Label: {predicted_class}, Confidence: {confidence}%"
|
27 |
+
return result
|
28 |
+
|
29 |
+
# Gradio-Schnittstelle erstellen
|
30 |
+
input_image = gr.Image()
|
31 |
+
output_text = gr.Textbox(label="Predicted Class and Confidence")
|
32 |
+
interface = gr.Interface(fn=predict_class,
|
33 |
+
inputs=input_image,
|
34 |
+
outputs=output_text,
|
35 |
+
examples=[
|
36 |
+
["images/imagesexample_pokemon1.jpeg"],
|
37 |
+
["images/imagesexample_pokemon2.jpeg"],
|
38 |
+
["images/imagesexample_pokemon3.jpeg"]
|
39 |
+
],
|
40 |
+
description="A simple classification model for Pokemon images.")
|
41 |
+
|
42 |
+
if __name__ == "__main__":
|
43 |
+
interface.launch()
|
pokemon_classifier_small_effnet.keras
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6d9fa18357912e506f43ef7355774fd52c1c1d512b0644984cbab3f35dd44d59
|
3 |
+
size 19171544
|