divya55 commited on
Commit
7c013c5
·
verified ·
1 Parent(s): a5b4632

Upload 3 files

Browse files
Files changed (3) hide show
  1. src/1.jpeg +0 -0
  2. src/242.jpeg +0 -0
  3. src/streamlit_app.py +152 -0
src/1.jpeg ADDED
src/242.jpeg ADDED
src/streamlit_app.py ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pickle
3
+ import numpy as np
4
+ from PIL import Image
5
+ import matplotlib.pyplot as plt
6
+
7
+ # -----------------------------
8
+ # Load trained model
9
+ # -----------------------------
10
+ with open("image_model.pkl", "rb") as f:
11
+ model = pickle.load(f)
12
+
13
+ # -----------------------------
14
+ # Page Config
15
+ # -----------------------------
16
+ st.set_page_config(page_title="Panda vs Bear Classifier", layout="wide")
17
+
18
+ # -----------------------------
19
+ # Sidebar Navigation
20
+ # -----------------------------
21
+ st.sidebar.title("Navigation")
22
+ menu = [
23
+ "Introduction",
24
+ "Problem Statement",
25
+ "Data Collection",
26
+ "EDA",
27
+ "Feature Engineering",
28
+ "Model Building",
29
+ "Deployment"
30
+ ]
31
+ choice = st.sidebar.radio("Go to", menu)
32
+
33
+ # -----------------------------
34
+ # Introduction
35
+ # -----------------------------
36
+ if choice == "Introduction":
37
+ st.title("Panda vs Bear Image Classification")
38
+ st.write("""
39
+ Wildlife researchers collect thousands of images through camera traps
40
+ to monitor endangered species like pandas and track other animals like bears.
41
+
42
+ Manually reviewing each photo is **slow, repetitive, and error-prone**.
43
+
44
+ This project was created to show how image classification can **automate animal identification**,
45
+ helping conservation teams save time and focus on decision-making.
46
+ """)
47
+
48
+ # -----------------------------
49
+ # Problem Statement
50
+ # -----------------------------
51
+ elif choice == "Problem Statement":
52
+ st.title("Problem Statement")
53
+ st.write("""
54
+ Key challenges in wildlife image monitoring:
55
+
56
+ - Large volume of photos that require sorting
57
+ - High chance of **human errors** during manual review
58
+ - **Delays in reporting** which affect timely conservation efforts
59
+
60
+ The goal of this project is to build a system that can
61
+ **automatically classify images as panda or bear**,
62
+ enabling faster and more consistent monitoring.
63
+ """)
64
+
65
+ # -----------------------------
66
+ # Data Collection
67
+ # -----------------------------
68
+ elif choice == "Data Collection":
69
+ st.title("Data Collection")
70
+ st.write("""
71
+ - Collected labeled images of two categories: **Pandas** and **Bears**
72
+ - Ensured balanced representation from both classes
73
+ - Standardized all images to a common size and format
74
+ - Split into training and testing sets for building and evaluation
75
+
76
+ This created a structured and reliable dataset to train the system.
77
+ """)
78
+
79
+ # -----------------------------
80
+ # EDA
81
+ # -----------------------------
82
+ elif choice == "EDA":
83
+ st.title("Exploratory Data Analysis (EDA)")
84
+ st.write("""
85
+ Before building the system, the dataset was explored to understand:
86
+
87
+ - **Class distribution** — to ensure balance
88
+ - **Visual patterns** — checking sample images from both classes
89
+ - **Image quality** — to confirm consistency
90
+
91
+ These insights helped verify the dataset’s readiness for modeling.
92
+ """)
93
+
94
+ st.subheader("Sample Images (Random)")
95
+ fig, ax = plt.subplots(1, 2, figsize=(6, 3))
96
+ for i, animal in enumerate(["Panda", "Bear"]):
97
+ ax[i].imshow(np.random.rand(64, 64, 3))
98
+ ax[i].set_title(animal)
99
+ ax[i].axis("off")
100
+ st.pyplot(fig)
101
+
102
+ # -----------------------------
103
+ # Feature Engineering
104
+ # -----------------------------
105
+ elif choice == "Feature Engineering":
106
+ st.title("Feature Engineering")
107
+ st.write("""
108
+ To prepare the data for model development, several steps were performed:
109
+
110
+ - Converted images into numerical arrays (pixels)
111
+ - Standardized dimensions for all images
112
+ - Extracted the most important patterns for learning
113
+ - Created clean structured input ready for modeling
114
+
115
+ These steps made the data usable for the classification system.
116
+ """)
117
+
118
+ # -----------------------------
119
+ # Model Building
120
+ # -----------------------------
121
+ elif choice == "Model Building":
122
+ st.title("Model Building")
123
+ st.write("""
124
+ Using the prepared data, we built a classification system that can:
125
+
126
+ - Learn patterns that distinguish pandas from bears
127
+ - Identify the correct class of unseen images
128
+ - Produce consistent predictions in real time
129
+
130
+ The model was tested on new data to validate its performance
131
+ before deployment as an interactive web application.
132
+ """)
133
+
134
+ # -----------------------------
135
+ # Deployment
136
+ # -----------------------------
137
+ elif choice == "Deployment":
138
+ st.title("Deployment")
139
+ st.write("Upload an image to see if it is classified as a **Panda** or a **Bear**:")
140
+
141
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
142
+
143
+ if uploaded_file is not None:
144
+ image = Image.open(uploaded_file).convert("RGB")
145
+ st.image(image, caption="Uploaded Image", use_column_width=True)
146
+
147
+ # Preprocess image (resize -> flatten -> scale handled by pipeline)
148
+ img_resized = image.resize((64, 64))
149
+ img_array = np.array(img_resized).flatten().reshape(1, -1)
150
+
151
+ prediction = model.predict(img_array)[0]
152
+ st.success(f"Predicted Class: **{prediction}** ✅")