Liori25 commited on
Commit
318e870
·
verified ·
1 Parent(s): 34ad6b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -24
app.py CHANGED
@@ -25,7 +25,6 @@ try:
25
  if isinstance(data, dict):
26
  stored_embeddings = np.array(data['embeddings'])
27
  elif isinstance(data, pd.DataFrame):
28
- # Fallback for dataframe format
29
  target_col = next((c for c in ['embedding', 'embeddings', 'vectors'] if c in data.columns), None)
30
  stored_embeddings = np.vstack(data[target_col].values) if target_col else data
31
  else:
@@ -45,7 +44,6 @@ def image_to_base64(image_path):
45
  with open(image_path, "rb") as img_file:
46
  return base64.b64encode(img_file.read()).decode('utf-8')
47
 
48
- # Pre-load the logo
49
  logo_b64 = image_to_base64("logo.jpg")
50
 
51
  # ==========================================
@@ -97,10 +95,11 @@ def magic_pipeline(image_path):
97
  fb_css = """
98
  body {background-color: #f0f2f5 !important; font-family: Helvetica, Arial, sans-serif;}
99
 
 
100
  .fb-header {
101
  background-color: #ffffff;
102
  color: #1877f2;
103
- padding: 12px 20px;
104
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
105
  border-bottom: 1px solid #ddd;
106
  margin-bottom: 20px;
@@ -109,11 +108,12 @@ body {background-color: #f0f2f5 !important; font-family: Helvetica, Arial, sans-
109
  }
110
 
111
  .logo-img {
112
- height: 40px;
113
- width: 40px;
114
  object-fit: cover;
115
- margin-right: 15px;
116
- border-radius: 5px;
 
117
  }
118
 
119
  .header-text-col {
@@ -122,32 +122,35 @@ body {background-color: #f0f2f5 !important; font-family: Helvetica, Arial, sans-
122
  justify-content: center;
123
  }
124
 
125
- .app-title {
126
- font-size: 24px;
127
- font-weight: 900;
128
- line-height: 1.1;
129
- }
130
-
131
- .app-slogan {
132
- font-size: 14px;
133
- font-weight: normal;
134
- color: #606770;
135
- }
136
 
 
137
  .sidebar-btn {
138
  background-color: transparent !important;
139
  color: #050505 !important;
 
 
140
  text-align: left !important;
 
 
 
 
141
  border: none !important;
142
  font-weight: 600 !important;
143
- padding: 12px !important;
144
  font-size: 16px !important;
145
  box-shadow: none !important;
146
  width: 100% !important;
147
  border-radius: 8px !important;
 
 
 
 
148
  }
149
  .sidebar-btn:hover { background-color: #e4e6eb !important; }
150
 
 
151
  .fb-card {
152
  background: white;
153
  border-radius: 8px;
@@ -186,12 +189,10 @@ with gr.Blocks(css=fb_css, title="Legacy Kitchen") as demo:
186
 
187
  # --- LEFT SIDEBAR ---
188
  with gr.Column(scale=1, min_width=250):
189
- gr.HTML('<div style="display:flex; align-items:center; margin-bottom:20px;"><div class="avatar">👤</div><b>My Profile</b></div>')
190
 
191
  nav_feed = gr.Button("📰 Feed", elem_classes=["sidebar-btn"])
192
  nav_digital = gr.Button("📸 Digitizer", elem_classes=["sidebar-btn"])
193
-
194
- # --- UPDATED BUTTON ---
195
  nav_about = gr.Button("ℹ️ About Us", elem_classes=["sidebar-btn"])
196
 
197
  gr.Markdown("---")
@@ -248,7 +249,7 @@ with gr.Blocks(css=fb_css, title="Legacy Kitchen") as demo:
248
 
249
  magic_btn.click(magic_pipeline, input_img, [out_text, out_sim])
250
 
251
- # VIEW 3: ABOUT US (Updated View)
252
  with gr.Group(visible=False) as about_view:
253
  gr.Markdown("### ℹ️ About Us", elem_classes=["fb-card"])
254
  with gr.Group(elem_classes=["fb-card"]):
@@ -263,7 +264,7 @@ with gr.Blocks(css=fb_css, title="Legacy Kitchen") as demo:
263
  *Preserving the Past, Cooking for the Future.*
264
  """)
265
 
266
- # Nav Logic (Updated for About Us)
267
  nav_feed.click(lambda: (gr.update(visible=True), gr.update(visible=False), gr.update(visible=False)), None, [feed_view, digitalizer_view, about_view])
268
  nav_digital.click(lambda: (gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)), None, [feed_view, digitalizer_view, about_view])
269
  nav_about.click(lambda: (gr.update(visible=False), gr.update(visible=False), gr.update(visible=True)), None, [feed_view, digitalizer_view, about_view])
 
25
  if isinstance(data, dict):
26
  stored_embeddings = np.array(data['embeddings'])
27
  elif isinstance(data, pd.DataFrame):
 
28
  target_col = next((c for c in ['embedding', 'embeddings', 'vectors'] if c in data.columns), None)
29
  stored_embeddings = np.vstack(data[target_col].values) if target_col else data
30
  else:
 
44
  with open(image_path, "rb") as img_file:
45
  return base64.b64encode(img_file.read()).decode('utf-8')
46
 
 
47
  logo_b64 = image_to_base64("logo.jpg")
48
 
49
  # ==========================================
 
95
  fb_css = """
96
  body {background-color: #f0f2f5 !important; font-family: Helvetica, Arial, sans-serif;}
97
 
98
+ /* --- HEADER --- */
99
  .fb-header {
100
  background-color: #ffffff;
101
  color: #1877f2;
102
+ padding: 15px 20px;
103
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
104
  border-bottom: 1px solid #ddd;
105
  margin-bottom: 20px;
 
108
  }
109
 
110
  .logo-img {
111
+ height: 80px; /* UPDATED SIZE */
112
+ width: 80px; /* UPDATED SIZE */
113
  object-fit: cover;
114
+ margin-right: 20px;
115
+ border-radius: 8px;
116
+ border: 1px solid #eee;
117
  }
118
 
119
  .header-text-col {
 
122
  justify-content: center;
123
  }
124
 
125
+ .app-title { font-size: 28px; font-weight: 900; line-height: 1.1; }
126
+ .app-slogan { font-size: 16px; font-weight: normal; color: #606770; }
 
 
 
 
 
 
 
 
 
127
 
128
+ /* --- SIDEBAR NAV --- */
129
  .sidebar-btn {
130
  background-color: transparent !important;
131
  color: #050505 !important;
132
+
133
+ /* ALIGNMENT FIXES */
134
  text-align: left !important;
135
+ justify-content: flex-start !important;
136
+ display: flex !important;
137
+ align-items: center !important;
138
+
139
  border: none !important;
140
  font-weight: 600 !important;
141
+ padding: 15px 10px !important;
142
  font-size: 16px !important;
143
  box-shadow: none !important;
144
  width: 100% !important;
145
  border-radius: 8px !important;
146
+
147
+ /* SEPARATION EFFECT */
148
+ border-bottom: 1px solid #e4e6eb !important;
149
+ margin-bottom: 8px !important;
150
  }
151
  .sidebar-btn:hover { background-color: #e4e6eb !important; }
152
 
153
+ /* --- CARDS --- */
154
  .fb-card {
155
  background: white;
156
  border-radius: 8px;
 
189
 
190
  # --- LEFT SIDEBAR ---
191
  with gr.Column(scale=1, min_width=250):
192
+ gr.HTML('<div style="display:flex; align-items:center; margin-bottom:20px; padding-left:10px;"><div class="avatar">👤</div><b>My Profile</b></div>')
193
 
194
  nav_feed = gr.Button("📰 Feed", elem_classes=["sidebar-btn"])
195
  nav_digital = gr.Button("📸 Digitizer", elem_classes=["sidebar-btn"])
 
 
196
  nav_about = gr.Button("ℹ️ About Us", elem_classes=["sidebar-btn"])
197
 
198
  gr.Markdown("---")
 
249
 
250
  magic_btn.click(magic_pipeline, input_img, [out_text, out_sim])
251
 
252
+ # VIEW 3: ABOUT US
253
  with gr.Group(visible=False) as about_view:
254
  gr.Markdown("### ℹ️ About Us", elem_classes=["fb-card"])
255
  with gr.Group(elem_classes=["fb-card"]):
 
264
  *Preserving the Past, Cooking for the Future.*
265
  """)
266
 
267
+ # Nav Logic
268
  nav_feed.click(lambda: (gr.update(visible=True), gr.update(visible=False), gr.update(visible=False)), None, [feed_view, digitalizer_view, about_view])
269
  nav_digital.click(lambda: (gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)), None, [feed_view, digitalizer_view, about_view])
270
  nav_about.click(lambda: (gr.update(visible=False), gr.update(visible=False), gr.update(visible=True)), None, [feed_view, digitalizer_view, about_view])