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