| import streamlit as st |
| import tensorflow |
| import keras |
| from keras.saving import load_model |
| import numpy as np |
| from PIL import Image |
|
|
| |
| MODEL_PATH = r"my_best_cnn_vgg16.h5" |
| model = load_model(MODEL_PATH) |
|
|
| |
| class_labels = [ |
| 'AMERICAN GOLDFINCH', 'BARN OWL', 'CARMINE BEE-EATER', |
| 'DOWNY WOODPECKER', 'EMPEROR PENGUIN', 'FLAMINGO' |
| ] |
|
|
| |
| st.set_page_config(page_title="Bird Species Classifier", page_icon="π¦", layout="centered") |
|
|
| |
| st.markdown( |
| "<h1 style='text-align: center; color: #FF5733;'>π¦ Bird Species Classifier π¦</h1>", |
| unsafe_allow_html=True |
| ) |
|
|
| |
| st.markdown( |
| """ |
| <p style='text-align: center; color: #3498db; font-size: 20px;'> |
| This deep learning model can classify bird images into one of the following six species: |
| AMERICAN GOLDFINCH, BARN OWL, CARMINE BEE-EATER, |
| DOWNY WOODPECKER, EMPEROR PENGUIN, and FLAMINGO. |
| </p> |
| <p style='text-align: center; color: #e74c3c; font-size: 20px;font-weight: bold;'> |
| Upload an image and let AI predict the species! |
| </p> |
| """, |
| unsafe_allow_html=True |
| ) |
|
|
|
|
| |
| uploaded_file = st.file_uploader("π€ **Upload a bird image** (JPG, PNG, JPEG)", type=["jpg", "png", "jpeg"]) |
|
|
| if uploaded_file is not None: |
| |
| image = Image.open(uploaded_file) |
| st.image(image, caption="πΈ Uploaded Image", use_container_width=True) |
|
|
| |
| image = image.resize((224, 224)) |
| image = np.array(image) / 255.0 |
| image = np.expand_dims(image, axis=0) |
|
|
| |
| with st.spinner("π Analyzing the image..."): |
| prediction = model.predict(image) |
|
|
| |
| class_index = np.argmax(prediction) |
| predicted_label = class_labels[class_index] |
| confidence = np.max(prediction) * 100 |
|
|
| |
| st.success(f"π― **Predicted Bird Species:** {predicted_label}") |
| st.progress(int(confidence)) |
| st.write(f"π **Confidence Score:** {confidence:.2f}%") |
|
|
| |
| bird_facts = { |
| 'AMERICAN GOLDFINCH': "π» Loves sunflower seeds and has a bright yellow plumage.", |
| 'BARN OWL': "π¦ Known for its heart-shaped face and silent flight.", |
| 'CARMINE BEE-EATER': "π Feeds on bees and has stunning crimson feathers.", |
| 'DOWNY WOODPECKER': "π¨ Small but mighty, often seen drumming on trees.", |
| 'EMPEROR PENGUIN': "βοΈ The largest penguin species, thriving in Antarctica.", |
| 'FLAMINGO': "𦩠Gets its pink color from its shrimp-based diet!" |
| } |
| |
| st.info(bird_facts.get(predicted_label, "π¦ A fascinating bird species!")) |
|
|
| |
| st.markdown( |
| """ |
| <hr> |
| <h4 style="text-align:center;">Developed by <b>Abhisikta Moharana</b></h4> |
| <p style="text-align:center;"> |
| <a href="https://www.linkedin.com/in/abhisikta-moharana-983052270" target="_blank" style="text-decoration:none; color:#d63384;"> |
| π LinkedIn |
| </a> | |
| <a href="https://github.com/Abhi2001-git" target="_blank" style="text-decoration:none; color:#d63384;"> |
| π₯οΈ GitHub |
| </a> | |
| <a href="mailto:abhisikta.moharana2001@gmail.com" style="text-decoration:none; color:#d63384;"> |
| π© Email |
| </a> |
| </p> |
| """, |
| unsafe_allow_html=True |
| ) |
|
|