File size: 2,468 Bytes
3d429a8
 
4b05b27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3d429a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import streamlit as st
from PIL import Image
from recipe_model import predict_dish, generate_recipe

st.set_page_config(page_title="AI Recipe Chef", layout="centered", page_icon="🍳")
st.title("πŸ‘¨β€πŸ³ AI Recipe Chef")
st.write("Upload any food image and get a real AI-generated recipe with filters.")
st.markdown(
    "<h1 style='text-align: center; color: #F63366;'>πŸ‘¨β€πŸ³ AI Recipe Chef</h1>",
    unsafe_allow_html=True
)
st.markdown("<p style='text-align: center;'>Upload a food image and get a personalized recipe with filters!</p>", unsafe_allow_html=True)
uploaded_image = st.file_uploader("Upload food image", type=["jpg", "jpeg", "png"])
st.sidebar.title("πŸ”History")
diet = st.selectbox("Dietary Preference", [
    "Any", "Vegetarian", "Non-Vegetarian", "Keto", "Gluten-Free", "Paleo"])

cuisine = st.selectbox("Cuisine", ["Any","Indian", "Chinese", "Italian", "Mexican", "Meditarrean"])
cook_time = st.selectbox("Cook Time", ["Any","<15 mins", "15-30 mins", ">30 mins","1 hour"])

if uploaded_image:
    st.image(uploaded_image, caption="Uploaded Image", use_column_width=True)
    with st.spinner("Detecting dish..."):
        dish = predict_dish(uploaded_image)
    st.success(f"Detected Dish: {dish}")

    with st.spinner("Generating recipe..."):
        import time
        time.sleep(0.8)  
        recipe = generate_recipe(dish, diet, cuisine, cook_time)
        
    st.subheader("πŸ“‹ Ingredients & Instructions")
    st.markdown(recipe, unsafe_allow_html=True)





# ---------- tiny helper to colour the diet tag ----------
def diet_badge(diet: str) -> str:
    colors = {
        "Vegetarian":   "#34c759",   # green
        "Vegan":        "#0a84ff",   # blue
        "Keto":         "#ff9f0a",   # orange
        "Gluten-Free":  "#ff375f",   # pink
        "Any":          "#8e8e93",   # grey
    }
    col = colors.get(diet, "#8e8e93")
    return (
        f"<span style='background:{col};color:white;"
        "border-radius:4px;padding:2px 6px;font-size:0.85rem;'>"
        f"{diet}</span>"
    )
#if file:
 #   img = Image.open(file)
  #  st.image(img, caption="Your Image", use_column_width=True)
   # with st.spinner("Thinking like a chef..."):
    #    dish = predict_dish(img)
     #   st.success(f"Detected Dish: **{dish}**")
      #  recipe = generate_recipe(dish, diet, cuisine, cook_time)
      #  st.subheader("πŸ“ Recipe:")
      #  st.write(recipe)