trashhpandaaaa's picture
initial commit
fe34d3e verified
raw
history blame contribute delete
839 Bytes
import streamlit as st
import tensorflow as tf
from PIL import Image
import numpy as np
model = tf.keras.models.load_model('animal_classifier_model.h5')
class_names = ['airplane', 'automobile', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck']
st.title('Animal Classifier')
uploaded_file = st.file_uploader("Choose an image...", type="jpg")
if uploaded_file is not None:
image = Image.open(uploaded_file)
st.image(image, caption='Uploaded Image', use_column_width=True)
image = image.resize((32, 32))
image_array = np.array(image) / 255.0
image_array = np.expand_dims(image_array, axis=0)
predictions = model.predict(image_array)
score = tf.nn.softmax(predictions[0])
st.write(f"Prediction: {class_names[np.argmax(score)]}")
st.write(f"Confidence: {100 * np.max(score):.2f}%")