Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -49,23 +49,64 @@ def explain_image_with_vlm(image):
|
|
49 |
return f"Error: {response.status_code} - {response.text}"
|
50 |
|
51 |
# Streamlit UI
|
52 |
-
st.
|
53 |
-
st.subheader("Capture an image and let the AI explain it!")
|
54 |
|
55 |
-
#
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
if img_file_buffer:
|
59 |
# Display captured image
|
60 |
image = Image.open(img_file_buffer)
|
|
|
61 |
st.image(image, caption="Captured Image", use_column_width=True)
|
62 |
|
63 |
-
st.
|
64 |
-
with st.spinner("
|
65 |
explanation = explain_image_with_vlm(image)
|
66 |
-
st.success("Analysis Complete!")
|
67 |
-
st.write(f"**
|
68 |
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
)
|
|
|
49 |
return f"Error: {response.status_code} - {response.text}"
|
50 |
|
51 |
# Streamlit UI
|
52 |
+
st.set_page_config(page_title="๐ฎ AI Vision: Image Insights", layout="wide")
|
|
|
53 |
|
54 |
+
# Header section with futuristic visuals
|
55 |
+
st.markdown(
|
56 |
+
"""
|
57 |
+
<style>
|
58 |
+
.main-header {
|
59 |
+
text-align: center;
|
60 |
+
font-size: 2.5rem;
|
61 |
+
color: #00FFFF;
|
62 |
+
font-family: 'Courier New', monospace;
|
63 |
+
text-shadow: 0px 0px 8px #00FFFF;
|
64 |
+
margin-bottom: 20px;
|
65 |
+
}
|
66 |
+
.sub-header {
|
67 |
+
text-align: center;
|
68 |
+
font-size: 1.5rem;
|
69 |
+
color: #FFD700;
|
70 |
+
font-family: 'Courier New', monospace;
|
71 |
+
margin-bottom: 40px;
|
72 |
+
}
|
73 |
+
</style>
|
74 |
+
<div class="main-header">๐ฎ Welcome to AI Vision: The Future of Image Insights</div>
|
75 |
+
<div class="sub-header">Where Images Come to Life with AI-Powered Explanations</div>
|
76 |
+
""",
|
77 |
+
unsafe_allow_html=True
|
78 |
+
)
|
79 |
+
|
80 |
+
# Sidebar for additional futuristic customization
|
81 |
+
st.sidebar.title("๐ง Settings")
|
82 |
+
image_format = st.sidebar.radio("Select Image Format:", ["PNG", "JPEG"], index=0)
|
83 |
+
explanation_length = st.sidebar.slider("Explanation Length (words):", min_value=5, max_value=20, value=10)
|
84 |
+
|
85 |
+
def styled_header(header_text):
|
86 |
+
return f"<h3 style='color:#7FFF00;'>{header_text}</h3>"
|
87 |
+
|
88 |
+
# Main Camera Input Section
|
89 |
+
img_file_buffer = st.camera_input("๐ Capture Your Image Here")
|
90 |
|
91 |
if img_file_buffer:
|
92 |
# Display captured image
|
93 |
image = Image.open(img_file_buffer)
|
94 |
+
st.markdown(styled_header("๐ธ Your Captured Image:"), unsafe_allow_html=True)
|
95 |
st.image(image, caption="Captured Image", use_column_width=True)
|
96 |
|
97 |
+
st.markdown(styled_header("๐ค Image Analysis:"), unsafe_allow_html=True)
|
98 |
+
with st.spinner("๐ The AI is analyzing your image. Please wait..."):
|
99 |
explanation = explain_image_with_vlm(image)
|
100 |
+
st.success("โจ Analysis Complete!")
|
101 |
+
st.write(f"**AI Insight:** {explanation}")
|
102 |
|
103 |
+
# Footer
|
104 |
+
st.markdown(
|
105 |
+
"""
|
106 |
+
<footer style="text-align: center; margin-top: 50px;">
|
107 |
+
<hr style="border: 1px solid #00FFFF;">
|
108 |
+
<p style="font-family: 'Courier New', monospace; color: #AAAAAA;">Developed by: <b>DataScienceProF</b> | <i>Empowering the Future</i></p>
|
109 |
+
</footer>
|
110 |
+
""",
|
111 |
+
unsafe_allow_html=True
|
112 |
)
|