Spaces:
Sleeping
Sleeping
Commit ·
a9f80b5
0
Parent(s):
Initial Streamlit recipe app
Browse files- .gitignore +3 -0
- app.py +28 -0
- requirements.txt +3 -0
.gitignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__pycache__/
|
| 2 |
+
*.pyc
|
| 3 |
+
.streamlit/
|
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
st.set_page_config(page_title="Recipe Generator", layout="centered")
|
| 5 |
+
|
| 6 |
+
st.title("🍳 AI Recipe Generator")
|
| 7 |
+
st.write("Enter ingredients and get a recipe suggestion!")
|
| 8 |
+
|
| 9 |
+
# Load the model (runs once, cached)
|
| 10 |
+
@st.cache_resource
|
| 11 |
+
def load_model():
|
| 12 |
+
return pipeline('text-generation', model='mistralai/Mistral-7B-Instruct-v0.1')
|
| 13 |
+
|
| 14 |
+
model = load_model()
|
| 15 |
+
|
| 16 |
+
# Input
|
| 17 |
+
ingredients = st.text_input("Enter ingredients (comma-separated):", placeholder="eggs, cheese, spinach")
|
| 18 |
+
|
| 19 |
+
# Generate button
|
| 20 |
+
if st.button("Generate Recipe"):
|
| 21 |
+
if ingredients:
|
| 22 |
+
with st.spinner("Thinking..."):
|
| 23 |
+
prompt = f"Suggest one simple recipe using: {ingredients}. Provide only the recipe name and steps."
|
| 24 |
+
result = model(prompt, max_length=200, do_sample=True)
|
| 25 |
+
recipe = result[0]['generated_text']
|
| 26 |
+
st.success(recipe)
|
| 27 |
+
else:
|
| 28 |
+
st.warning("Please enter some ingredients!")
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit>=1.28.0
|
| 2 |
+
transformers>=4.35.0
|
| 3 |
+
torch>=2.6.0
|