Spaces:
Runtime error
Runtime error
initial commit
Browse files- .gitattributes +1 -0
- app.py +43 -0
- pokemon_classification_model_xception_v2.keras +3 -0
- requirements.txt +1 -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_classification_model_xception_v2.keras filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import numpy as np
|
3 |
+
from tensorflow.keras.preprocessing import image
|
4 |
+
|
5 |
+
# Lade das gespeicherte Modell
|
6 |
+
model = tf.keras.models.load_model("pokemon_classification_model_xception_v2.keras")
|
7 |
+
|
8 |
+
# Setze die Bildabmessungen
|
9 |
+
img_height, img_width = 299, 299 # Eingabegröße für Xception
|
10 |
+
|
11 |
+
# Definiere eine Funktion zur Vorhersage und Rückgabe des Labels und der Wahrscheinlichkeit
|
12 |
+
def predict_label_and_probability(image_path):
|
13 |
+
# Lade das Bild und passe es an die Eingabegröße des Modells an
|
14 |
+
img = image.load_img(image_path, target_size=(img_height, img_width))
|
15 |
+
x = image.img_to_array(img)
|
16 |
+
x = np.expand_dims(x, axis=0)
|
17 |
+
x /= 255. # Skalieren der Bildpixel
|
18 |
+
|
19 |
+
# Vorhersage mit dem Modell
|
20 |
+
preds = model.predict(x)
|
21 |
+
class_idx = np.argmax(preds[0])
|
22 |
+
|
23 |
+
# Mappe Klassenindizes auf Klassennamen
|
24 |
+
class_labels = {0: 'Abra', 1: 'Butterfree', 2: 'Eevee'}
|
25 |
+
predicted_class = class_labels[class_idx]
|
26 |
+
|
27 |
+
# Gib das vorhergesagte Label und die Wahrscheinlichkeit zurück
|
28 |
+
probability = preds[0][class_idx]
|
29 |
+
return predicted_class, probability
|
30 |
+
|
31 |
+
# Streamlit App
|
32 |
+
st.title("Pokémon Classification")
|
33 |
+
|
34 |
+
uploaded_file = st.file_uploader("Choose a Pokémon image...", type="jpg")
|
35 |
+
|
36 |
+
if uploaded_file is not None:
|
37 |
+
# Zeige das hochgeladene Bild
|
38 |
+
st.image(uploaded_file, caption='Uploaded Pokémon Image.', use_column_width=True)
|
39 |
+
|
40 |
+
# Führe die Vorhersage durch und zeige das Ergebnis
|
41 |
+
label, probability = predict_label_and_probability(uploaded_file)
|
42 |
+
st.write("Prediction:", label)
|
43 |
+
st.write("Probability:", probability)
|
pokemon_classification_model_xception_v2.keras
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2c2b55f66e325b28ea57ff7580c0634eb1e7a6dc79f70fe6e0db8224b2272307
|
3 |
+
size 167750092
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
tensorflow
|