Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,13 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import
|
3 |
|
4 |
-
# Initialize
|
5 |
-
|
6 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
-
model = AutoModelForCausalLM.from_pretrained(model_name)
|
8 |
|
9 |
def generate_recipe(dish_name):
|
10 |
-
#
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
# Decode generated text
|
15 |
-
recipe = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
16 |
-
return recipe
|
17 |
|
18 |
# Streamlit app
|
19 |
st.title("Cooking Recipe Generator")
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Initialize the text generation pipeline with the GPT-2 fine-tuned recipe model
|
5 |
+
pipe = pipeline("text-generation", model="mrm8488/gpt2-finetuned-recipes-cooking_v2")
|
|
|
|
|
6 |
|
7 |
def generate_recipe(dish_name):
|
8 |
+
# Generate recipe using the text-generation pipeline
|
9 |
+
recipe = pipe(f"Recipe for {dish_name}:", max_length=300, num_return_sequences=1)
|
10 |
+
return recipe[0]['generated_text']
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# Streamlit app
|
13 |
st.title("Cooking Recipe Generator")
|