Spaces:
Sleeping
Sleeping
Update src/app.py
Browse files- src/app.py +8 -15
src/app.py
CHANGED
|
@@ -1,25 +1,18 @@
|
|
| 1 |
-
# app.py
|
| 2 |
import streamlit as st
|
| 3 |
from tensorflow.keras.models import load_model
|
| 4 |
from tensorflow.keras.preprocessing import image
|
| 5 |
import numpy as np
|
| 6 |
-
from PIL import Image
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
model = load_model("
|
| 10 |
|
| 11 |
-
st.title("
|
| 12 |
|
| 13 |
-
|
| 14 |
-
uploaded_file = st.file_uploader("Upload a coin image", type=["jpg", "png"])
|
| 15 |
if uploaded_file:
|
| 16 |
-
img =
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
-
# --- Tahmin ---
|
| 20 |
-
x = np.expand_dims(np.array(img)/255.0, axis=0)
|
| 21 |
pred = model.predict(x)[0][0]
|
| 22 |
-
|
| 23 |
-
# --- Sonuç ---
|
| 24 |
-
st.write("Prediction:", "Heads" if pred > 0.5 else "Tails")
|
| 25 |
-
st.write("Probability of Heads:", round(float(pred), 3))
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from tensorflow.keras.models import load_model
|
| 3 |
from tensorflow.keras.preprocessing import image
|
| 4 |
import numpy as np
|
|
|
|
| 5 |
|
| 6 |
+
# Load model
|
| 7 |
+
model = load_model("cat_dog_model.h5")
|
| 8 |
|
| 9 |
+
st.title("🐱🐶 Cat vs Dog Predictor")
|
| 10 |
|
| 11 |
+
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "png"])
|
|
|
|
| 12 |
if uploaded_file:
|
| 13 |
+
img = image.load_img(uploaded_file, target_size=(224,224))
|
| 14 |
+
x = image.img_to_array(img) / 255.0
|
| 15 |
+
x = np.expand_dims(x, axis=0)
|
| 16 |
|
|
|
|
|
|
|
| 17 |
pred = model.predict(x)[0][0]
|
| 18 |
+
st.write("Prediction:", "Dog 🐶" if pred > 0.5 else "Cat 🐱")
|
|
|
|
|
|
|
|
|