Spaces:
Running
Running
David Chuan-En Lin
commited on
Commit
·
b5c4f59
1
Parent(s):
9b7fe1b
Third iteration
Browse files- .DS_Store +0 -0
- foodnet.py +36 -15
.DS_Store
CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
|
|
foodnet.py
CHANGED
@@ -287,23 +287,44 @@ if add_selectbox == "FoodNet Recommender":
|
|
287 |
names = [o[0] for o in out]
|
288 |
probs = [o[1] for o in out]
|
289 |
|
290 |
-
if 'probs' not in st.session_state:
|
291 |
-
|
292 |
|
293 |
-
if st.session_state.probs:
|
294 |
-
|
295 |
-
else:
|
296 |
-
|
297 |
|
298 |
-
st.checkbox(label="Show model scores", value=False, key="probs")
|
299 |
-
## Plot Results ##
|
300 |
-
st.checkbox(label="Show results bar chart", value=False, key="plot")
|
301 |
-
if st.session_state.plot:
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
|
308 |
elif add_selectbox == "Food Donation Resources":
|
309 |
st.title('Food Donation Resources')
|
|
|
287 |
names = [o[0] for o in out]
|
288 |
probs = [o[1] for o in out]
|
289 |
|
290 |
+
# if 'probs' not in st.session_state:
|
291 |
+
# st.session_state['probs'] = False
|
292 |
|
293 |
+
# if st.session_state.probs:
|
294 |
+
# st.table(data=out)
|
295 |
+
# else:
|
296 |
+
# st.table(data=names)
|
297 |
|
298 |
+
# st.checkbox(label="Show model scores", value=False, key="probs")
|
299 |
+
# ## Plot Results ##
|
300 |
+
# st.checkbox(label="Show results bar chart", value=False, key="plot")
|
301 |
+
# if st.session_state.plot:
|
302 |
+
# fig = plot_results(names, probs, st.session_state.top_n)
|
303 |
+
|
304 |
+
# ## Show Plot ##
|
305 |
+
# st.pyplot(fig)
|
306 |
+
st.selectbox(label="Select dietary restriction", options=('None', 'Kosher', 'Vegetarian'), key="diet")
|
307 |
+
if st.session_state.diet != 'None':
|
308 |
+
if st.session_state.diet == 'Vegetarian':
|
309 |
+
out = [o for o in out if not any(ignore in o[0] for ignore in blacklists.vegitarian)]
|
310 |
+
if st.session_state.diet == 'Kosher':
|
311 |
+
out = [o for o in out if not any(ignore in o[0] for ignore in blacklists.kosher)]
|
312 |
+
names = [o[0] for o in out]
|
313 |
+
probs = [o[1] for o in out]
|
314 |
+
|
315 |
+
col1, col2, col3 = st.columns(3)
|
316 |
+
|
317 |
+
for i, name in enumerate(names):
|
318 |
+
search = py_un.search(type_='photos', query=name)
|
319 |
+
for photo in search.entries:
|
320 |
+
col_id = i % 3
|
321 |
+
if col_id == 0:
|
322 |
+
col1.image(photo.link_download, caption=name, use_column_width=True)
|
323 |
+
elif col_id == 1:
|
324 |
+
col2.image(photo.link_download, caption=name, use_column_width=True)
|
325 |
+
elif col_id == 2:
|
326 |
+
col3.image(photo.link_download, caption=name, use_column_width=True)
|
327 |
+
break
|
328 |
|
329 |
elif add_selectbox == "Food Donation Resources":
|
330 |
st.title('Food Donation Resources')
|