Upload 5 files
Browse files- .gitattributes +1 -0
- README.md +6 -5
- app.py +65 -0
- gitattributes.txt +53 -0
- pokemon-model_transferlearning1.keras +3 -0
- requirements.txt +5 -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_transferlearning1.keras filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: streamlit
|
7 |
-
sdk_version: 1.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: Pokemon
|
3 |
+
emoji: 🏃
|
4 |
+
colorFrom: pink
|
5 |
+
colorTo: red
|
6 |
sdk: streamlit
|
7 |
+
sdk_version: 1.34.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
+
license: other
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import tensorflow as tf
|
3 |
+
import numpy as np
|
4 |
+
from PIL import Image
|
5 |
+
import pandas as pd
|
6 |
+
import matplotlib.pyplot as plt
|
7 |
+
|
8 |
+
# Load the trained model
|
9 |
+
model_path = "pokemon-model_transferlearning1.keras"
|
10 |
+
model = tf.keras.models.load_model(model_path)
|
11 |
+
|
12 |
+
# Define the core prediction function
|
13 |
+
def predict_pokemon(image):
|
14 |
+
# Preprocess image
|
15 |
+
image = image.resize((150, 150)) # Resize the image to 150x150
|
16 |
+
image = image.convert('RGB') # Ensure image has 3 channels
|
17 |
+
image = np.array(image)
|
18 |
+
image = np.expand_dims(image, axis=0) # Add batch dimension
|
19 |
+
|
20 |
+
# Predict
|
21 |
+
prediction = model.predict(image)
|
22 |
+
|
23 |
+
# Apply softmax to get probabilities for each class
|
24 |
+
probabilities = tf.nn.softmax(prediction, axis=1)
|
25 |
+
|
26 |
+
# Map probabilities to Pokemon classes
|
27 |
+
class_names = ['Chansey', 'Growlithe', 'Lapras']
|
28 |
+
probabilities_dict = {pokemon_class: round(float(probability), 2) for pokemon_class, probability in zip(class_names, probabilities.numpy()[0])}
|
29 |
+
|
30 |
+
return probabilities_dict
|
31 |
+
|
32 |
+
# Streamlit interface
|
33 |
+
st.title("Pokemon Classifier")
|
34 |
+
st.write("Welches Pokemon hast du ausgewählt?")
|
35 |
+
|
36 |
+
# Upload image
|
37 |
+
uploaded_image = st.file_uploader("Choose an image...", type=["jpg", "png"])
|
38 |
+
|
39 |
+
if uploaded_image is not None:
|
40 |
+
image = Image.open(uploaded_image)
|
41 |
+
st.image(image, caption='Uploaded Image.', use_column_width=True)
|
42 |
+
st.write("")
|
43 |
+
st.write("Classifying...")
|
44 |
+
|
45 |
+
predictions = predict_pokemon(image)
|
46 |
+
|
47 |
+
# Display predictions as a DataFrame
|
48 |
+
st.write("### Prediction Probabilities")
|
49 |
+
df = pd.DataFrame(predictions.items(), columns=["Pokemon", "Probability"])
|
50 |
+
st.dataframe(df)
|
51 |
+
|
52 |
+
# Display predictions as a bar chart
|
53 |
+
st.write("### Prediction Chart")
|
54 |
+
fig, ax = plt.subplots()
|
55 |
+
ax.barh(df["Pokemon"], df["Probability"], color='skyblue')
|
56 |
+
ax.set_xlim(0, 1)
|
57 |
+
ax.set_xlabel('Probability')
|
58 |
+
ax.set_title('Prediction Probabilities')
|
59 |
+
st.pyplot(fig)
|
60 |
+
|
61 |
+
# Example images
|
62 |
+
st.sidebar.title("Examples")
|
63 |
+
example_images = ["pokemon/00000000.png","pokemon/00000001.png","pokemon/00000002.png"]
|
64 |
+
for example_image in example_images:
|
65 |
+
st.sidebar.image(example_image, use_column_width=True)
|
gitattributes.txt
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz 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/train/chansey/00000149.png filter=lfs diff=lfs merge=lfs -text
|
37 |
+
pokemon/train/chansey/00000167.gif filter=lfs diff=lfs merge=lfs -text
|
38 |
+
pokemon/train/growlithe/00000000.png filter=lfs diff=lfs merge=lfs -text
|
39 |
+
pokemon/train/growlithe/00000209.png filter=lfs diff=lfs merge=lfs -text
|
40 |
+
pokemon/train/growlithe/00000227.gif filter=lfs diff=lfs merge=lfs -text
|
41 |
+
pokemon/train/lapras/00000006.png filter=lfs diff=lfs merge=lfs -text
|
42 |
+
pokemon/train/lapras/00000031.png filter=lfs diff=lfs merge=lfs -text
|
43 |
+
pokemon/train/lapras/00000042.jpg filter=lfs diff=lfs merge=lfs -text
|
44 |
+
pokemon/train/lapras/00000059.jpg filter=lfs diff=lfs merge=lfs -text
|
45 |
+
pokemon/train/lapras/00000103.gif filter=lfs diff=lfs merge=lfs -text
|
46 |
+
pokemon/val/growlithe/00000000.png filter=lfs diff=lfs merge=lfs -text
|
47 |
+
pokemon/val/growlithe/00000209.png filter=lfs diff=lfs merge=lfs -text
|
48 |
+
pokemon/val/growlithe/00000227.gif filter=lfs diff=lfs merge=lfs -text
|
49 |
+
pokemon/val/lapras/00000042.jpg filter=lfs diff=lfs merge=lfs -text
|
50 |
+
pokemon/val/lapras/00000103.gif filter=lfs diff=lfs merge=lfs -text
|
51 |
+
pokemon-model_transferlearning.keras filter=lfs diff=lfs merge=lfs -text
|
52 |
+
pokemon-model_transferlearning1.keras filter=lfs diff=lfs merge=lfs -text
|
53 |
+
pokemon/00000001.png filter=lfs diff=lfs merge=lfs -text
|
pokemon-model_transferlearning1.keras
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8f63f7dc8b294af5a9028375143425ee082c5239aaa700524570641c1c3e97d6
|
3 |
+
size 250560147
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
tensorflow==2.16.1
|
2 |
+
protobuf==3.20.3
|
3 |
+
numpy
|
4 |
+
streamlit
|
5 |
+
pillow
|