Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,10 +43,8 @@ def image_to_base64(image_path):
|
|
| 43 |
with open(image_path, "rb") as img_file:
|
| 44 |
return base64.b64encode(img_file.read()).decode('utf-8')
|
| 45 |
|
| 46 |
-
# --- UPDATED IMAGES HERE ---
|
| 47 |
logo_b64 = image_to_base64("cookbook logo.png")
|
| 48 |
profile_b64 = image_to_base64("chef.avif")
|
| 49 |
-
# NEW: Load the process preview image
|
| 50 |
process_b64 = image_to_base64("preview of process.jpg")
|
| 51 |
|
| 52 |
# ==========================================
|
|
@@ -71,7 +69,7 @@ def find_similar_recipes_list(query_text):
|
|
| 71 |
row = df_recipes.iloc[idx]
|
| 72 |
title = row['Title']
|
| 73 |
desc = str(row['Raw_Output'])
|
| 74 |
-
score_display = f"{score:.
|
| 75 |
|
| 76 |
card_content = (
|
| 77 |
f"### π {title}\n"
|
|
@@ -226,6 +224,45 @@ body, .gradio-container { background-color: #f0f2f5; }
|
|
| 226 |
}
|
| 227 |
.trend-box:hover { background: #f0f2f5; cursor: pointer; }
|
| 228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
.gap-fix { gap: 25px !important; }
|
| 230 |
|
| 231 |
.gradio-examples {
|
|
@@ -250,18 +287,17 @@ button.gallery-item:hover {
|
|
| 250 |
# ==========================================
|
| 251 |
# 5. LAYOUT CONSTRUCTION
|
| 252 |
# ==========================================
|
| 253 |
-
# --- UPDATED APP NAME IN TITLE ---
|
| 254 |
with gr.Blocks(title="CookBook AI") as demo:
|
| 255 |
|
| 256 |
# --- HEADER ---
|
| 257 |
-
# ---
|
| 258 |
gr.HTML(f"""
|
| 259 |
<div class="custom-header">
|
| 260 |
<div class="logo-area">
|
| 261 |
<img src="data:image/jpeg;base64,{logo_b64}" class="logo-img">
|
| 262 |
<div class="text-area">
|
| 263 |
<span class="app-name">CookBook AI</span>
|
| 264 |
-
<span class="app-slogan">Turning Handwritten
|
| 265 |
</div>
|
| 266 |
</div>
|
| 267 |
<div style="color: #65676b; font-weight: 600;">v4.4</div>
|
|
@@ -380,10 +416,34 @@ with gr.Blocks(title="CookBook AI") as demo:
|
|
| 380 |
|
| 381 |
# --- RIGHT COLUMN ---
|
| 382 |
with gr.Column(scale=1, min_width=200):
|
|
|
|
| 383 |
gr.Markdown("### Trending Recipes")
|
| 384 |
def trend_box(title, likes):
|
| 385 |
return f"<div class='trend-box'><b>{title}</b><br><span style='color:gray; font-size:12px;'>{likes} likes</span></div>"
|
| 386 |
gr.HTML(trend_box("π Ramen Hack", "12k") + trend_box("πͺ Best Cookies", "8k") + trend_box("π° Cheese Cake", "15k") + trend_box("πͺ Nana's Tahini Cookies", "9k"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
|
| 388 |
# ==========================================
|
| 389 |
# 6. JAVASCRIPT LOGIC
|
|
|
|
| 43 |
with open(image_path, "rb") as img_file:
|
| 44 |
return base64.b64encode(img_file.read()).decode('utf-8')
|
| 45 |
|
|
|
|
| 46 |
logo_b64 = image_to_base64("cookbook logo.png")
|
| 47 |
profile_b64 = image_to_base64("chef.avif")
|
|
|
|
| 48 |
process_b64 = image_to_base64("preview of process.jpg")
|
| 49 |
|
| 50 |
# ==========================================
|
|
|
|
| 69 |
row = df_recipes.iloc[idx]
|
| 70 |
title = row['Title']
|
| 71 |
desc = str(row['Raw_Output'])
|
| 72 |
+
score_display = f"{score:.3%}"
|
| 73 |
|
| 74 |
card_content = (
|
| 75 |
f"### π {title}\n"
|
|
|
|
| 224 |
}
|
| 225 |
.trend-box:hover { background: #f0f2f5; cursor: pointer; }
|
| 226 |
|
| 227 |
+
/* Contact List Styling */
|
| 228 |
+
.contact-item {
|
| 229 |
+
display: flex;
|
| 230 |
+
align-items: center;
|
| 231 |
+
padding: 10px;
|
| 232 |
+
background: white;
|
| 233 |
+
border-radius: 8px;
|
| 234 |
+
margin-bottom: 8px;
|
| 235 |
+
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
| 236 |
+
cursor: pointer;
|
| 237 |
+
transition: 0.2s;
|
| 238 |
+
}
|
| 239 |
+
.contact-item:hover { background: #f0f2f5; }
|
| 240 |
+
|
| 241 |
+
.avatar-circle {
|
| 242 |
+
width: 36px; height: 36px;
|
| 243 |
+
background: #e4e6eb;
|
| 244 |
+
border-radius: 50%;
|
| 245 |
+
display: flex;
|
| 246 |
+
align-items: center;
|
| 247 |
+
justify-content: center;
|
| 248 |
+
font-weight: 700;
|
| 249 |
+
color: #050505;
|
| 250 |
+
margin-right: 12px;
|
| 251 |
+
position: relative;
|
| 252 |
+
font-size: 13px;
|
| 253 |
+
border: 1px solid #ddd;
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
.status-badge {
|
| 257 |
+
width: 12px; height: 12px;
|
| 258 |
+
border-radius: 50%;
|
| 259 |
+
border: 2px solid white;
|
| 260 |
+
position: absolute;
|
| 261 |
+
bottom: -1px; right: -2px;
|
| 262 |
+
}
|
| 263 |
+
.status-green { background-color: #31a24c; }
|
| 264 |
+
.status-red { background-color: #f02849; }
|
| 265 |
+
|
| 266 |
.gap-fix { gap: 25px !important; }
|
| 267 |
|
| 268 |
.gradio-examples {
|
|
|
|
| 287 |
# ==========================================
|
| 288 |
# 5. LAYOUT CONSTRUCTION
|
| 289 |
# ==========================================
|
|
|
|
| 290 |
with gr.Blocks(title="CookBook AI") as demo:
|
| 291 |
|
| 292 |
# --- HEADER ---
|
| 293 |
+
# --- CHANGED HERE: SLOGAN TEXT UPDATED ---
|
| 294 |
gr.HTML(f"""
|
| 295 |
<div class="custom-header">
|
| 296 |
<div class="logo-area">
|
| 297 |
<img src="data:image/jpeg;base64,{logo_b64}" class="logo-img">
|
| 298 |
<div class="text-area">
|
| 299 |
<span class="app-name">CookBook AI</span>
|
| 300 |
+
<span class="app-slogan">Turning Handwritten Recipes into a Digital Recipe.</span>
|
| 301 |
</div>
|
| 302 |
</div>
|
| 303 |
<div style="color: #65676b; font-weight: 600;">v4.4</div>
|
|
|
|
| 416 |
|
| 417 |
# --- RIGHT COLUMN ---
|
| 418 |
with gr.Column(scale=1, min_width=200):
|
| 419 |
+
# 1. Trending
|
| 420 |
gr.Markdown("### Trending Recipes")
|
| 421 |
def trend_box(title, likes):
|
| 422 |
return f"<div class='trend-box'><b>{title}</b><br><span style='color:gray; font-size:12px;'>{likes} likes</span></div>"
|
| 423 |
gr.HTML(trend_box("π Ramen Hack", "12k") + trend_box("πͺ Best Cookies", "8k") + trend_box("π° Cheese Cake", "15k") + trend_box("πͺ Nana's Tahini Cookies", "9k"))
|
| 424 |
+
|
| 425 |
+
# 2. Contacts
|
| 426 |
+
gr.HTML("<div style='height: 20px;'></div>")
|
| 427 |
+
gr.Markdown("### Quick Contacts")
|
| 428 |
+
|
| 429 |
+
def contact_box(name, initials, status_color):
|
| 430 |
+
return f"""
|
| 431 |
+
<div class='contact-item'>
|
| 432 |
+
<div class='avatar-circle'>
|
| 433 |
+
{initials}
|
| 434 |
+
<div class='status-badge status-{status_color}'></div>
|
| 435 |
+
</div>
|
| 436 |
+
<div style='font-weight:600; font-size:14px; color:#050505;'>{name}</div>
|
| 437 |
+
</div>
|
| 438 |
+
"""
|
| 439 |
+
|
| 440 |
+
contact_html = (
|
| 441 |
+
contact_box("Elon Musk", "EM", "green") +
|
| 442 |
+
contact_box("Gordon Ramsay", "GR", "red") +
|
| 443 |
+
contact_box("Guy Fieri", "GF", "green") +
|
| 444 |
+
contact_box("Bobby Flay", "BF", "red")
|
| 445 |
+
)
|
| 446 |
+
gr.HTML(contact_html)
|
| 447 |
|
| 448 |
# ==========================================
|
| 449 |
# 6. JAVASCRIPT LOGIC
|