Spaces:
Sleeping
Sleeping
LuckyHappyFish
commited on
Commit
·
b1f272d
1
Parent(s):
1bec4ea
Initial Commit
Browse files
app.py
CHANGED
@@ -7,8 +7,8 @@ from gradio_client import Client
|
|
7 |
|
8 |
# Set page configuration
|
9 |
st.set_page_config(
|
10 |
-
page_title="
|
11 |
-
page_icon="
|
12 |
layout="centered",
|
13 |
initial_sidebar_state="expanded",
|
14 |
)
|
@@ -47,24 +47,27 @@ def local_css():
|
|
47 |
color: white;
|
48 |
}
|
49 |
/* File uploader styling */
|
50 |
-
.
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
55 |
}
|
56 |
-
|
57 |
-
|
58 |
-
color:
|
59 |
}
|
60 |
/* Button styling */
|
61 |
.stButton>button {
|
62 |
background-color: #ff4b4b;
|
63 |
color: white;
|
64 |
border: none;
|
65 |
-
padding: 0.5rem
|
66 |
border-radius: 5px;
|
67 |
-
font-size: 1rem;
|
68 |
font-weight: bold;
|
69 |
margin-top: 10px;
|
70 |
}
|
@@ -90,8 +93,15 @@ def local_css():
|
|
90 |
footer {
|
91 |
visibility: hidden;
|
92 |
}
|
93 |
-
/*
|
94 |
@media only screen and (max-width: 600px) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
.title h1 {
|
96 |
font-size: 2rem;
|
97 |
}
|
@@ -99,6 +109,24 @@ def local_css():
|
|
99 |
width: 100%;
|
100 |
}
|
101 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
</style>
|
103 |
""",
|
104 |
unsafe_allow_html=True
|
@@ -147,12 +175,12 @@ def get_ingredients_qwen(food_name):
|
|
147 |
return f"Error generating ingredients: {e}"
|
148 |
|
149 |
# Main content
|
150 |
-
st.markdown('<div class="title"><h1>
|
151 |
|
152 |
# Add banner image
|
153 |
-
st.image("IR_IMAGE.png",
|
154 |
|
155 |
-
# Sidebar for model information
|
156 |
with st.sidebar:
|
157 |
st.title("Model Information")
|
158 |
st.write("**Image Classification Model**")
|
@@ -162,13 +190,34 @@ with st.sidebar:
|
|
162 |
st.markdown("---")
|
163 |
st.markdown("<p style='text-align: center;'>Developed by Muhammad Hassan Butt.</p>", unsafe_allow_html=True)
|
164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
# File uploader
|
166 |
-
|
|
|
167 |
|
168 |
-
if uploaded_file is not None:
|
169 |
# Display the uploaded image
|
170 |
-
|
171 |
-
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
# Classification button
|
174 |
if st.button("Classify"):
|
@@ -198,3 +247,6 @@ if uploaded_file is not None:
|
|
198 |
st.write(result)
|
199 |
except Exception as e:
|
200 |
st.error(f"Unable to contact RAG: {e}")
|
|
|
|
|
|
|
|
7 |
|
8 |
# Set page configuration
|
9 |
st.set_page_config(
|
10 |
+
page_title="DelishAI - Your Culinary Assistant",
|
11 |
+
page_icon="🍽️",
|
12 |
layout="centered",
|
13 |
initial_sidebar_state="expanded",
|
14 |
)
|
|
|
47 |
color: white;
|
48 |
}
|
49 |
/* File uploader styling */
|
50 |
+
.stFileUploader {
|
51 |
+
border: 2px dashed #ff4b4b;
|
52 |
+
border-radius: 10px;
|
53 |
+
padding: 20px;
|
54 |
+
text-align: center;
|
55 |
+
color: #ff4b4b;
|
56 |
+
background-color: #ffffff;
|
57 |
+
font-weight: bold;
|
58 |
}
|
59 |
+
/* File uploader hover effect */
|
60 |
+
.stFileUploader:hover {
|
61 |
+
background-color: #ffe5e5;
|
62 |
}
|
63 |
/* Button styling */
|
64 |
.stButton>button {
|
65 |
background-color: #ff4b4b;
|
66 |
color: white;
|
67 |
border: none;
|
68 |
+
padding: 0.7rem 1.5rem;
|
69 |
border-radius: 5px;
|
70 |
+
font-size: 1.1rem;
|
71 |
font-weight: bold;
|
72 |
margin-top: 10px;
|
73 |
}
|
|
|
93 |
footer {
|
94 |
visibility: hidden;
|
95 |
}
|
96 |
+
/* Hide sidebar on small screens */
|
97 |
@media only screen and (max-width: 600px) {
|
98 |
+
[data-testid="stSidebar"] {
|
99 |
+
display: none;
|
100 |
+
}
|
101 |
+
.main .block-container {
|
102 |
+
padding-left: 1rem;
|
103 |
+
padding-right: 1rem;
|
104 |
+
}
|
105 |
.title h1 {
|
106 |
font-size: 2rem;
|
107 |
}
|
|
|
109 |
width: 100%;
|
110 |
}
|
111 |
}
|
112 |
+
/* Sample images grid */
|
113 |
+
.sample-images {
|
114 |
+
display: flex;
|
115 |
+
justify-content: center;
|
116 |
+
flex-wrap: wrap;
|
117 |
+
gap: 10px;
|
118 |
+
}
|
119 |
+
.sample-images img {
|
120 |
+
width: 150px;
|
121 |
+
height: 150px;
|
122 |
+
object-fit: cover;
|
123 |
+
border-radius: 10px;
|
124 |
+
cursor: pointer;
|
125 |
+
border: 2px solid transparent;
|
126 |
+
}
|
127 |
+
.sample-images img:hover {
|
128 |
+
border: 2px solid #ff4b4b;
|
129 |
+
}
|
130 |
</style>
|
131 |
""",
|
132 |
unsafe_allow_html=True
|
|
|
175 |
return f"Error generating ingredients: {e}"
|
176 |
|
177 |
# Main content
|
178 |
+
st.markdown('<div class="title"><h1>DelishAI - Your Culinary Assistant</h1></div>', unsafe_allow_html=True)
|
179 |
|
180 |
# Add banner image
|
181 |
+
st.image("IR_IMAGE.png", use_container_width=True)
|
182 |
|
183 |
+
# Sidebar for model information (hidden on small screens)
|
184 |
with st.sidebar:
|
185 |
st.title("Model Information")
|
186 |
st.write("**Image Classification Model**")
|
|
|
190 |
st.markdown("---")
|
191 |
st.markdown("<p style='text-align: center;'>Developed by Muhammad Hassan Butt.</p>", unsafe_allow_html=True)
|
192 |
|
193 |
+
# Sample images
|
194 |
+
st.subheader("Or try one of these sample images:")
|
195 |
+
sample_images = {
|
196 |
+
"Burger": "sample_images/burger.jpg",
|
197 |
+
"Pizza": "sample_images/pizza.jpg",
|
198 |
+
"Sushi": "sample_images/sushi.jpg",
|
199 |
+
"Salad": "sample_images/salad.jpg"
|
200 |
+
}
|
201 |
+
|
202 |
+
cols = st.columns(len(sample_images))
|
203 |
+
for idx, (name, file_path) in enumerate(sample_images.items()):
|
204 |
+
with cols[idx]:
|
205 |
+
if st.button(f"{name}", key=name):
|
206 |
+
uploaded_file = file_path
|
207 |
+
|
208 |
# File uploader
|
209 |
+
st.subheader("Upload a food image:")
|
210 |
+
uploaded_file = st.file_uploader("", type=["jpg", "png", "jpeg"])
|
211 |
|
212 |
+
if 'uploaded_file' in locals() and uploaded_file is not None:
|
213 |
# Display the uploaded image
|
214 |
+
if isinstance(uploaded_file, str):
|
215 |
+
# Sample image selected
|
216 |
+
image = Image.open(uploaded_file)
|
217 |
+
else:
|
218 |
+
# User uploaded image
|
219 |
+
image = Image.open(uploaded_file)
|
220 |
+
st.image(image, caption="Uploaded Image", use_container_width=True)
|
221 |
|
222 |
# Classification button
|
223 |
if st.button("Classify"):
|
|
|
247 |
st.write(result)
|
248 |
except Exception as e:
|
249 |
st.error(f"Unable to contact RAG: {e}")
|
250 |
+
else:
|
251 |
+
st.info("Please select or upload an image to get started.")
|
252 |
+
|