'
src_tag = '{}'
src_tag = src_tag.format(source, source)
st.markdown(src_hdr_tag, unsafe_allow_html=True)
st.markdown(src_tag + " ", unsafe_allow_html=True)
return 1
if 'models_loaded' not in st.session_state:
st.session_state['models_loaded'] = False
st.title('WTF - What The Food 🤬')
st.subheader("Image to Recipe - 1.5M foods supported")
st.markdown("Built for fun with 💙 by a quintessential foodie - Prithivi Da, The maker of [Gramformer](https://github.com/PrithivirajDamodaran/Gramformer), [Styleformer](https://github.com/PrithivirajDamodaran/Styleformer) and [Parrot paraphraser](https://github.com/PrithivirajDamodaran/Parrot_Paraphraser) | ✍️ [@prithivida](https://twitter.com/prithivida) |[[GitHub]](https://github.com/PrithivirajDamodaran)", unsafe_allow_html=True)
st.markdown(""" (Read Me: The idea: Food Image => Recipe. So it works on single foods and platters
but May Not perform well on custom combinations or hyper-local foods. (NOT intended for commercial use.)
) """, unsafe_allow_html=True)
if __name__ == '__main__':
if not st.session_state['models_loaded']:
load_models()
random_button = st.button('⚡ Try a Random Food')
st.write("(or)")
st.info('Upload a HD, landscape image')
image_file = st.file_uploader("", type=["jpg","jpeg"])
col1, col2 = st.columns(2)
if random_button:
with st.spinner(text="Detecting food..."):
samples = glob.glob('./samples' + "/*")
shuffle(samples)
random_sample = random.choice(samples)
pil_image = load_image(random_sample)
with col1:
st.image(pil_image, use_column_width='auto')
return_code = run_search(random_sample)
else:
if image_file is not None:
pil_image = load_image(image_file)
with open(image_file.name, 'wb') as f:
pil_image.save(f)
with col1:
st.image(pil_image, use_column_width='auto')
with st.spinner(text="Detecting food..."):
return_code = run_search(image_file.name)
os.system('rm -r "' + image_file.name + '"')