Spaces:
Running
Running
David Chuan-En Lin
commited on
Commit
·
344a906
1
Parent(s):
2a84e0d
First iteration
Browse files- .DS_Store +0 -0
- __pycache__/blacklists.cpython-38.pyc +0 -0
- foodnet.py +16 -37
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
__pycache__/blacklists.cpython-38.pyc
ADDED
Binary file (358 Bytes). View file
|
|
foodnet.py
CHANGED
@@ -240,7 +240,7 @@ def plot_results(names, probs, n=5):
|
|
240 |
ax.xaxis.labelpad = 10
|
241 |
ax.set_title(f'FoodNet Top {n} Predictions = {st.session_state.leftovers}')
|
242 |
# mpld3.show()
|
243 |
-
plt.xticks(rotation=45, ha='right')
|
244 |
fig = plt.gcf()
|
245 |
|
246 |
return fig
|
@@ -287,44 +287,23 @@ if add_selectbox == "FoodNet Recommender":
|
|
287 |
names = [o[0] for o in out]
|
288 |
probs = [o[1] for o in out]
|
289 |
|
290 |
-
|
291 |
-
|
292 |
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
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')
|
|
|
240 |
ax.xaxis.labelpad = 10
|
241 |
ax.set_title(f'FoodNet Top {n} Predictions = {st.session_state.leftovers}')
|
242 |
# mpld3.show()
|
243 |
+
# plt.xticks(rotation=45, ha='right')
|
244 |
fig = plt.gcf()
|
245 |
|
246 |
return fig
|
|
|
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 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
|
308 |
elif add_selectbox == "Food Donation Resources":
|
309 |
st.title('Food Donation Resources')
|