File size: 3,852 Bytes
628e9ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e5c0c43
628e9ae
 
 
 
 
 
e5c0c43
628e9ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ee452fc
 
 
628e9ae
 
 
 
 
 
 
 
 
 
10e75d1
db05c20
17bf1e4
 
 
0b2273c
 
628e9ae
 
 
 
 
 
 
ee452fc
 
628e9ae
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Import streamlit
import streamlit as st
from streamlit_option_menu import option_menu
from fastai.vision.all import *
from fastai.learner import load_learner
import pickle
from bird_species import model_info
from bird_species import capture_photo
from bird_species import upload_photo


def app():
    #######################################################################################################################

    # Set the page config
    st.set_page_config(
        page_title="Bird Species Detector (525 Species)",  # The title of the web page
        page_icon="🕊️",  # The icon of the web page, can be an emoji or a file path
        initial_sidebar_state="collapsed"
    )

    #######################################################################################################################

    st.markdown("<h1 style='text-align: center;'>🕊️Birds Species Detector (525 Species)🕊️</h1>",
                unsafe_allow_html=True)

    #######################################################################################################################

    # Options Menu at the top of the homepage
    selected = option_menu(None, ["Upload", "Capture", "Model"],
                           icons=["cloud upload", "camera", "gear"],
                           menu_icon="cast", default_index=0, orientation="horizontal")

    #######################################################################################################################

    # Load model and model class labels (vocab)
    model = load_learner(fname="models/birds_learner.pkl")

    with open("models/birds_vocab.pkl", "rb") as f:
        vocab = pickle.load(f)
    # Sorting
    vocab = sorted(vocab)

    with open("models/freezed_model_summary.pkl", "rb") as f:
        freezed_arch_summary = pickle.load(f)

    with open("models/unfreezed_model_summary.pkl", "rb") as f:
        unfreezed_arch_summary = pickle.load(f)

    with open("models/birds_model_preprocessing.pkl","rb") as f:
        preprocessing_steps = pickle.load(f)

    #######################################################################################################################

    if selected == "Upload":
        st.caption("""Our project utilizes FastAI Vision with the ResNet50 architecture to classify 
                   525 bird species. Our dataset comprises 84,635 training images, 2,625 test images and 2,625 validation 
                   images, all standardized to 224x224x3 pixels. Initial training yields 96.6% accuracy, improved to 98% post 
                   fine-tuning. Despite gender imbalances, it's a valuable resource for accurate bird species classification.""")

        upload_photo(model=model, vocab=vocab, key="upload photo")

        # Link for other projects
        # st.divider()
        st.markdown("### `Other Projects`")
        # st.markdown("* [**Cat and Dog's Breed Detector**](https://subrata-mondal-cat-and-dog-breed-detector.streamlit.app/)")
        st.link_button(label="**Cat and Dog's Breed Detector**", url="https://subrata-mondal-cat-and-dog-breed-detector.streamlit.app/")
        st.divider()

    #######################################################################################################################

    if selected == "Capture":
        capture_photo(model=model, vocab=None, key="capture photo")

    if selected == "Model":
        model_info()
        st.subheader("Preprocessing Steps")
        st.code(preprocessing_steps)
        st.subheader("FastAi Model Summary (Freezed)")
        st.code(freezed_arch_summary)
        st.subheader("FastAi Model Summary (Unfreezed)")
        st.code(unfreezed_arch_summary)


#######################################################################################################################
if __name__ == "__main__":
    app()