daniescamilla commited on
Commit
e2663ed
verified
1 Parent(s): 021e335

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -13,9 +13,14 @@ image_to_text = pipeline("image-to-text", model="Salesforce/blip-image-captionin
13
  def generate_recipe(description):
14
  url = "https://api-inference.huggingface.co/models/Qwen/Qwen2.5-72B-Instruct"
15
  headers = {"Authorization": f"Bearer {hf_token}"}
 
 
 
 
 
16
  payload = {
17
- "inputs": f"Give me a list of ingredients and a step-by-step recipe for a dish described as: {description}",
18
- "parameters": {"max_length": 4000} # Increase max_length for a more detailed response
19
  }
20
 
21
  response = requests.post(url, headers=headers, json=payload)
@@ -26,7 +31,7 @@ def generate_recipe(description):
26
  return "Error generating recipe: " + response_data["error"]
27
 
28
  # Return only the generated text, without the input prompt
29
- return response_data[0]["generated_text"].replace(payload["inputs"], "").strip() if response_data else "No recipe generated."
30
 
31
  # Paso 3: Define la funci贸n principal para procesar la imagen y generar la receta
32
  def process_image(image):
 
13
  def generate_recipe(description):
14
  url = "https://api-inference.huggingface.co/models/Qwen/Qwen2.5-72B-Instruct"
15
  headers = {"Authorization": f"Bearer {hf_token}"}
16
+ # Reformulamos el prompt para que sea m谩s espec铆fico
17
+ prompt = (
18
+ f"Provide a full recipe for a dish described as: {description}. "
19
+ "Include a list of ingredients and detailed step-by-step instructions."
20
+ )
21
  payload = {
22
+ "inputs": prompt,
23
+ "parameters": {"max_length": 5000} # Increase max_length for a more detailed response
24
  }
25
 
26
  response = requests.post(url, headers=headers, json=payload)
 
31
  return "Error generating recipe: " + response_data["error"]
32
 
33
  # Return only the generated text, without the input prompt
34
+ return response_data[0]["generated_text"].replace(prompt, "").strip() if response_data else "No recipe generated."
35
 
36
  # Paso 3: Define la funci贸n principal para procesar la imagen y generar la receta
37
  def process_image(image):