Amaanali01's picture
Create app.py
1b950c0 verified
raw
history blame contribute delete
721 Bytes
import streamlit as st
import tensorflow as tf
import numpy as np
import pickle
from tensorflow.keras.preprocessing import image
model = tf.keras.models.load_model("animal_mobilenet_model.keras")
labels = pickle.load(open("labels.pkl","rb"))
class_names = list(labels.keys())
st.title("🐾 Animal Classifier (MobileNetV2)")
uploaded_file = st.file_uploader("Upload Animal Image")
if uploaded_file:
img = image.load_img(uploaded_file, target_size=(224,224))
img_array = image.img_to_array(img)/255
img_array = np.expand_dims(img_array, axis=0)
prediction = model.predict(img_array)
predicted_class = class_names[np.argmax(prediction)]
st.success(f"Predicted Animal: {predicted_class}")