deneme2 / src /streamlit_app.py
omercann's picture
Update src/streamlit_app.py
88d012b verified
import streamlit as st
import numpy as np
from PIL import Image
from tensorflow.keras.models import load_model
from tensorflow.keras.applications.resnet50 import preprocess_input
class_names = [
'Asian Green Bee-Eater',
'Brown-Headed Barbet',
'Cattle Egret',
'Common Kingfisher',
'Common Myna',
'Common Rosefinch',
'Common Tailorbird',
'Coppersmith Barbet',
'Forest Wagtail',
'Gray Wagtail',
'Hoopoe',
'House Crow',
'Indian Grey Hornbill',
'Indian Peacock',
'Indian Pitta',
'Indian Roller',
'Jungle Babbler',
'Northern Lapwing',
'Red-Wattled Lapwing',
'Ruddy Shelduck',
'Rufous Treepie',
'Sarus Crane',
'White Wagtail',
'White-Breasted Kingfisher',
'White-Breasted Waterhen'
]
model = load_model("src/indianBirds_InceptionV3Model.keras")
st.title("Indian Bird Species Classifier")
uploaded_file = st.file_uploader("Upload a bird image", type=["jpg", "jpeg", "png"])
if uploaded_file:
image = Image.open(uploaded_file).convert("RGB")
st.image(image, use_container_width=True)
img = image.resize((224, 224))
x = np.expand_dims(np.array(img), axis=0)
x = preprocess_input(x)
preds = model.predict(x)
idx = np.argmax(preds[0])
st.markdown(f"### Predicted Species: **{class_names[idx]}**")