Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from tensorflow.keras.models import load_model | |
| from tensorflow.keras.preprocessing import image | |
| import numpy as np | |
| # Load model | |
| model = load_model("src/cat_dog_tl_model.keras") | |
| st.title("🐱🐶 Cat vs Dog Predictor") | |
| uploaded_file = st.file_uploader("Upload an image", type=["jpg", "png"]) | |
| if uploaded_file: | |
| img = image.load_img(uploaded_file, target_size=(224,224)) | |
| x = image.img_to_array(img) / 255.0 | |
| x = np.expand_dims(x, axis=0) | |
| pred = model.predict(x)[0][0] | |
| st.write("Prediction:", "Dog 🐶" if pred > 0.5 else "Cat 🐱") |