Spaces:
Runtime error
Runtime error
Commit
·
ac69d4a
1
Parent(s):
fbd3ed0
Upload 2 files
Browse files- .gitattributes +1 -0
- app.py +95 -0
- recipes.json +3 -0
.gitattributes
CHANGED
|
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
recipes.json filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import json
|
| 4 |
+
import time
|
| 5 |
+
from urllib.request import urlopen
|
| 6 |
+
from bs4 import BeautifulSoup
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
# import the dataset
|
| 10 |
+
df = pd.read_json('recipes.json')
|
| 11 |
+
df['liststring'] = [','.join(map(str, l)) for l in df['Ingredients']]
|
| 12 |
+
|
| 13 |
+
st.write("#### Was koche ich heute?")
|
| 14 |
+
|
| 15 |
+
## Sidebar
|
| 16 |
+
def user_input_features():
|
| 17 |
+
ingre1 = st.sidebar.text_input("Zutat 1")
|
| 18 |
+
ingre2 = st.sidebar.text_input("Zutat 2", key = "zutat2")
|
| 19 |
+
ingre3 = st.sidebar.text_input("Zutat 3", key = "zutat3")
|
| 20 |
+
list_ingre = [ingre1, ingre2, ingre3]
|
| 21 |
+
return list_ingre
|
| 22 |
+
st.sidebar.write("Was hast du schon im Kühlschrank?")
|
| 23 |
+
ingre = user_input_features()
|
| 24 |
+
results_ingredients = st.sidebar.button("Suchen")
|
| 25 |
+
st.sidebar.write("oder")
|
| 26 |
+
results = st.sidebar.button("Überrasch mich!")
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
# Sort the dataset
|
| 30 |
+
#create a dataframe "new" with all the ingredients that are in the list ingre
|
| 31 |
+
new = df[df['liststring'].apply(lambda x: ingre[0] in x)]
|
| 32 |
+
if ingre[1]:
|
| 33 |
+
new = new[new['liststring'].apply(lambda x: ingre[1] in x)]
|
| 34 |
+
if ingre[2]:
|
| 35 |
+
new = new[new['liststring'].apply(lambda x: ingre[2] in x)]
|
| 36 |
+
#new = df[df['liststring'].apply(lambda x: ingre in x)]
|
| 37 |
+
|
| 38 |
+
col1, col2 = st.columns(2)
|
| 39 |
+
|
| 40 |
+
if not new.empty:
|
| 41 |
+
if results_ingredients:
|
| 42 |
+
bla = new.sample(1)
|
| 43 |
+
|
| 44 |
+
#Opening header images
|
| 45 |
+
url = str(bla["Url"].iloc[0])
|
| 46 |
+
htmldata = urlopen(url)
|
| 47 |
+
soup = BeautifulSoup(htmldata, 'html.parser')
|
| 48 |
+
images = soup.find_all('img')
|
| 49 |
+
image = images[2]['src']
|
| 50 |
+
|
| 51 |
+
#Opening the Rest
|
| 52 |
+
zutaten = bla["Ingredients"].iloc[0]
|
| 53 |
+
instructions = str(bla["Instructions"].iloc[0])
|
| 54 |
+
name = str(bla["Name"].iloc[0])
|
| 55 |
+
with col1:
|
| 56 |
+
st.write("# " + name)
|
| 57 |
+
for i in zutaten:
|
| 58 |
+
st.write("* "+i)
|
| 59 |
+
|
| 60 |
+
with col2:
|
| 61 |
+
st.image(image)
|
| 62 |
+
st.text_area("Anleitung", instructions, height=300)
|
| 63 |
+
else:
|
| 64 |
+
st.write("### Sorry, nichts gefunden...")
|
| 65 |
+
|
| 66 |
+
# Next
|
| 67 |
+
if results:
|
| 68 |
+
new_sample = df.sample(1)
|
| 69 |
+
|
| 70 |
+
#Opening header images
|
| 71 |
+
url = str(new_sample["Url"].iloc[0])
|
| 72 |
+
htmldata = urlopen(url)
|
| 73 |
+
soup = BeautifulSoup(htmldata, 'html.parser')
|
| 74 |
+
images = soup.find_all('img')
|
| 75 |
+
image = images[2]['src']
|
| 76 |
+
|
| 77 |
+
# Rest
|
| 78 |
+
zutaten = new_sample["Ingredients"].iloc[0]
|
| 79 |
+
instructions = str(new_sample["Instructions"].iloc[0])
|
| 80 |
+
name = str(new_sample["Name"].iloc[0])
|
| 81 |
+
with col1:
|
| 82 |
+
st.write("# " + name)
|
| 83 |
+
for i in zutaten:
|
| 84 |
+
st.write("* "+i)
|
| 85 |
+
with col2:
|
| 86 |
+
st.image(image)
|
| 87 |
+
st.text_area("Anleitung", instructions, height=300)
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
|
recipes.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7cf88f3e3c914b37a31fa4606e399cf958e25fa1900c6f597d26072f6719188a
|
| 3 |
+
size 17193424
|