Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,7 @@ def predict_pokemon(image):
|
|
24 |
probabilities = tf.nn.softmax(prediction, axis=1)
|
25 |
|
26 |
# Map probabilities to Pokemon classes
|
27 |
-
class_names = ['
|
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
|
@@ -47,19 +47,4 @@ if uploaded_image is not None:
|
|
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/train/chansey/00000000.png", "pokemon/train/growlithe/00000000.png", "pokemon/train/lapras/00000000.png"]
|
64 |
-
for example_image in example_images:
|
65 |
-
st.sidebar.image(example_image, use_column_width=True)
|
|
|
24 |
probabilities = tf.nn.softmax(prediction, axis=1)
|
25 |
|
26 |
# Map probabilities to Pokemon classes
|
27 |
+
class_names = ['Charizard', 'Lapras', 'Machamp']
|
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
|
|
|
47 |
# Display predictions as a DataFrame
|
48 |
st.write("### Prediction Probabilities")
|
49 |
df = pd.DataFrame(predictions.items(), columns=["Pokemon", "Probability"])
|
50 |
+
st.dataframe(df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|