Spaces:
Running on Zero
Running on Zero
FredinVázquez commited on
Commit ·
ba424d1
1
Parent(s): 80fc666
adding dynamic image
Browse files- app.py +1 -1
- src/agents/mise_en_place.py +3 -2
app.py
CHANGED
|
@@ -26,7 +26,7 @@ from src.ui.theme import CSS, theme
|
|
| 26 |
def on_propose(fridge_image: Image.Image | None, state: dict | None) -> tuple[str, str, list[str], dict]:
|
| 27 |
"""Photo → ingredients → 3 dish options."""
|
| 28 |
state = state or {}
|
| 29 |
-
ingredients = identify_ingredients()
|
| 30 |
# options = propose_dishes(ingredients)
|
| 31 |
|
| 32 |
# state.update({
|
|
|
|
| 26 |
def on_propose(fridge_image: Image.Image | None, state: dict | None) -> tuple[str, str, list[str], dict]:
|
| 27 |
"""Photo → ingredients → 3 dish options."""
|
| 28 |
state = state or {}
|
| 29 |
+
ingredients = identify_ingredients(fridge_image)
|
| 30 |
# options = propose_dishes(ingredients)
|
| 31 |
|
| 32 |
# state.update({
|
src/agents/mise_en_place.py
CHANGED
|
@@ -35,9 +35,10 @@ _prompt = "Describe the given image in detail. Be honest, do not say liers."
|
|
| 35 |
|
| 36 |
|
| 37 |
@spaces.GPU(duration=30)
|
| 38 |
-
def identify_ingredients() -> list[str]:
|
| 39 |
try:
|
| 40 |
-
|
|
|
|
| 41 |
|
| 42 |
# Procesamiento de tokens
|
| 43 |
inputs = processor.apply_chat_template(
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
@spaces.GPU(duration=30)
|
| 38 |
+
def identify_ingredients(image: Optional[Image.Image]) -> list[str]:
|
| 39 |
try:
|
| 40 |
+
img = image.convert("RGB")
|
| 41 |
+
messages = [{"role": "user", "content": [{"type": "image", "image": img}, {"type": "text", "text": _prompt}]}]
|
| 42 |
|
| 43 |
# Procesamiento de tokens
|
| 44 |
inputs = processor.apply_chat_template(
|