Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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":
|
18 |
-
"parameters": {"max_length":
|
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(
|
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):
|