evaliisah commited on
Commit
27e2011
·
verified ·
1 Parent(s): cd25f10

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -19
app.py CHANGED
@@ -1,25 +1,22 @@
 
 
1
  import gradio as gr
 
2
  from transformers import pipeline
3
 
4
- # Load your model or pipeline
5
- recipe_generator = pipeline("text-generation", model="toit")
6
-
7
- def generate_recipe(ingredients):
8
- prompt = f"Ingredients: {ingredients}\nRecipe:"
9
- recipe = recipe_generator(prompt, max_length=200)[0]['generated_text']
10
- # Dummy values for calories and sugars
11
- calories = "200 kcal"
12
- sugars = "10g"
13
- return recipe, calories, sugars
14
-
15
- # Create the Gradio interface
16
- iface = gr.Interface(
17
- fn=generate_recipe,
18
- inputs=gr.inputs.Textbox(lines=2, placeholder="Enter ingredients here..."),
19
- outputs=["text", "text", "text"],
20
- title="Recipe Generator",
21
- description="Enter ingredients to get a recipe suggestion along with calories and sugars."
22
  )
23
 
 
 
 
24
  # Launch the interface
25
- iface.launch()
 
1
+
2
+
3
  import gradio as gr
4
+
5
  from transformers import pipeline
6
 
7
+ pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-es")
8
+
9
+ def predict(text):
10
+ return pipe(text)[0]["translation_text"]
11
+
12
+ demo = gr.Interface(
13
+ fn=predict,
14
+ inputs='text',
15
+ outputs='text',
 
 
 
 
 
 
 
 
 
16
  )
17
 
18
+ demo.launch()
19
+
20
+
21
  # Launch the interface
22
+ #iface.launch()