Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,14 +10,14 @@ import torch
|
|
10 |
# Set page config
|
11 |
st.set_page_config(page_title="Building Detection App", page_icon="π’", layout="wide")
|
12 |
|
13 |
-
# Custom CSS
|
14 |
st.markdown("""
|
15 |
<style>
|
16 |
.reportview-container {
|
17 |
-
background:
|
18 |
}
|
19 |
.main {
|
20 |
-
background-color:
|
21 |
padding: 2rem;
|
22 |
border-radius: 10px;
|
23 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
@@ -41,6 +41,9 @@ st.markdown("""
|
|
41 |
padding: 2rem;
|
42 |
text-align: center;
|
43 |
}
|
|
|
|
|
|
|
44 |
</style>
|
45 |
""", unsafe_allow_html=True)
|
46 |
|
@@ -81,30 +84,30 @@ def process_image(image):
|
|
81 |
return cv2.cvtColor(annotated_image, cv2.COLOR_BGR2RGB)
|
82 |
|
83 |
def main():
|
84 |
-
st.title("
|
85 |
-
st.markdown("Upload an image to detect buildings using our advanced AI model
|
86 |
|
87 |
col1, col2 = st.columns(2)
|
88 |
|
89 |
with col1:
|
90 |
-
st.markdown("
|
91 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
92 |
|
93 |
if uploaded_file is not None:
|
94 |
image = Image.open(uploaded_file)
|
95 |
st.image(image, caption="Uploaded Image", use_column_width=True)
|
96 |
|
97 |
-
if st.button("
|
98 |
with st.spinner("Processing..."):
|
99 |
result_image = process_image(image)
|
100 |
with col2:
|
101 |
-
st.markdown("
|
102 |
st.image(result_image, caption="Processed Image", use_column_width=True)
|
103 |
st.success("Detection completed successfully!")
|
104 |
else:
|
105 |
st.markdown(
|
106 |
"""
|
107 |
-
<div class="upload-box">
|
108 |
<h3>π Upload an image to get started</h3>
|
109 |
<p>Supported formats: JPG, JPEG, PNG</p>
|
110 |
</div>
|
@@ -114,19 +117,21 @@ def main():
|
|
114 |
|
115 |
with col2:
|
116 |
if uploaded_file is None:
|
117 |
-
st.markdown("
|
118 |
st.markdown(
|
119 |
"""
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
Our AI model is trained to identify various types of buildings
|
125 |
-
|
|
|
|
|
126 |
)
|
127 |
|
128 |
st.markdown("---")
|
129 |
-
st.markdown("
|
130 |
|
131 |
if __name__ == "__main__":
|
132 |
main()
|
|
|
10 |
# Set page config
|
11 |
st.set_page_config(page_title="Building Detection App", page_icon="π’", layout="wide")
|
12 |
|
13 |
+
# Custom CSS with theme compatibility
|
14 |
st.markdown("""
|
15 |
<style>
|
16 |
.reportview-container {
|
17 |
+
background: var(--background-color);
|
18 |
}
|
19 |
.main {
|
20 |
+
background-color: var(--background-color);
|
21 |
padding: 2rem;
|
22 |
border-radius: 10px;
|
23 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
|
41 |
padding: 2rem;
|
42 |
text-align: center;
|
43 |
}
|
44 |
+
.theme-text {
|
45 |
+
color: var(--text-color);
|
46 |
+
}
|
47 |
</style>
|
48 |
""", unsafe_allow_html=True)
|
49 |
|
|
|
84 |
return cv2.cvtColor(annotated_image, cv2.COLOR_BGR2RGB)
|
85 |
|
86 |
def main():
|
87 |
+
st.title("Building Detection App")
|
88 |
+
st.markdown('<p class="theme-text">Upload an image to detect buildings using our advanced AI model.</p>', unsafe_allow_html=True)
|
89 |
|
90 |
col1, col2 = st.columns(2)
|
91 |
|
92 |
with col1:
|
93 |
+
st.markdown('<h3 class="theme-text">Upload Image</h3>', unsafe_allow_html=True)
|
94 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
95 |
|
96 |
if uploaded_file is not None:
|
97 |
image = Image.open(uploaded_file)
|
98 |
st.image(image, caption="Uploaded Image", use_column_width=True)
|
99 |
|
100 |
+
if st.button("Detect Buildings"):
|
101 |
with st.spinner("Processing..."):
|
102 |
result_image = process_image(image)
|
103 |
with col2:
|
104 |
+
st.markdown('<h3 class="theme-text">Detection Results</h3>', unsafe_allow_html=True)
|
105 |
st.image(result_image, caption="Processed Image", use_column_width=True)
|
106 |
st.success("Detection completed successfully!")
|
107 |
else:
|
108 |
st.markdown(
|
109 |
"""
|
110 |
+
<div class="upload-box theme-text">
|
111 |
<h3>π Upload an image to get started</h3>
|
112 |
<p>Supported formats: JPG, JPEG, PNG</p>
|
113 |
</div>
|
|
|
117 |
|
118 |
with col2:
|
119 |
if uploaded_file is None:
|
120 |
+
st.markdown('<h3 class="theme-text">How it works</h3>', unsafe_allow_html=True)
|
121 |
st.markdown(
|
122 |
"""
|
123 |
+
<p class="theme-text">
|
124 |
+
1. <strong>Upload</strong> an image using the file uploader on the left.<br>
|
125 |
+
2. Click the <strong>Detect Buildings</strong> button to process the image.<br>
|
126 |
+
3. View the results with bounding boxes around detected buildings.<br><br>
|
127 |
+
Our AI model is trained to identify various types of buildings in different environments.
|
128 |
+
</p>
|
129 |
+
""",
|
130 |
+
unsafe_allow_html=True
|
131 |
)
|
132 |
|
133 |
st.markdown("---")
|
134 |
+
#st.markdown('<p class="theme-text"></p>', unsafe_allow_html=True)
|
135 |
|
136 |
if __name__ == "__main__":
|
137 |
main()
|