← 返回 Skills 市场
yxjsxy

FoodLens

作者 Karl Yang · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
113
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install foodlens
功能描述
AI-powered meal photo recognition and nutrition tracking. Use when a user sends a food/meal photo with keywords like breakfast, lunch, dinner, snack, or "wha...
使用说明 (SKILL.md)

FoodLens — AI Meal Photo & Nutrition Tracker

Trigger Conditions

User sends a meal/food photo with context such as:

  • breakfast / lunch / dinner / snack / supper / 早饭 / 午饭 / 晚饭 / 加餐 / 零食

Configuration

Set these paths for your deployment (defaults shown):

FOODLENS_DIR=~/.openclaw/workspace/skills/foodlens
FOODLENS_DATA=$FOODLENS_DIR/data          # daily JSON logs: YYYY-MM-DD.json
FOODLENS_VENV=$FOODLENS_DIR/venv

Nutrition goals are user-configurable. Defaults (edit foodlens_config.json):

  • Calories: 2000 kcal/day
  • Protein: 80g | Carbs: 250g | Fat: 65g

Core Flow

Step 1 — Analyze Photo (Primary)

Save the inbound photo to a temp path, then run:

cd $FOODLENS_DIR && source venv/bin/activate
python3 analyze_photo.py /path/to/photo.jpg "lunch"

This script:

  1. Calls GPT-4o Vision (fallback: Gemini) to identify foods and estimate portion sizes using container/utensil references
  2. Cross-validates against nutrition_db (778 foods + 197 aliases); if deviation > 30%, trusts the database
  3. Appends the meal to data/YYYY-MM-DD.json
  4. Outputs a formatted nutrition report

Forward the script output directly to the user.


Step 2 — Fallback (API unavailable)

If analyze_photo.py fails, use the image tool:

image(
  image="/path/to/photo.jpg",
  prompt="You are a professional nutritionist. Identify all foods in this meal
  photo. Observe container size and utensils to estimate actual grams per item.
  Reference: standard takeout box 500–800 ml, bowl of rice ~150–200 g,
  stir-fried noodles ~400–500 g. List each food: name, estimated grams,
  kcal per 100 g, protein/carb/fat per 100 g."
)

Then write results via Python:

cd $FOODLENS_DIR && source venv/bin/activate && python3 - \x3C\x3C'EOF'
import json, uuid, sys
sys.path.insert(0, '.')
from foodlens import (ensure_item_nutrition, calc_total,
                      health_score_and_comment, load_day, save_day,
                      today_str, recalc_day_totals)
from datetime import datetime

date_str = today_str()
day = load_day(date_str)

# Replace with image tool results
items = [
    ensure_item_nutrition({'name': 'food name', 'grams': 300, 'source': 'image_tool'}),
]

meal_total = calc_total(items)
score, comment = health_score_and_comment(meal_total, len(items))
meal = {
    'meal_id': f'meal_{uuid.uuid4().hex[:10]}',
    'timestamp': datetime.now().isoformat(),
    'label': 'lunch',
    'items': items,
    'meal_total': meal_total,
    'health_score': score,
    'comment': comment,
}
day['meals'].append(meal)
recalc_day_totals(day)
save_day(date_str, day)
print(json.dumps({'meal': meal, 'daily_total': day['daily_total']}, ensure_ascii=False, indent=2))
EOF

Step 3 — Format Reply

🍽️ [Lunch] Nutrition Analysis

🔍 Identified foods:
  • Stir-fried noodles ~400g (720 kcal)
  • Shrimp ~30g (27 kcal)
  • Chicken slices ~60g (90 kcal)

📊 Meal total:
  • Calories: 837 kcal
  • Protein: 38g | Carbs: 102g | Fat: 29g

⭐ Health score: 7/10
  Comment: ...

📈 Daily total (meal N):
  • Calories: X / [goal] kcal (X%)
  • Protein: X / [goal]g (X%)

Step 4 — User Corrections

If user says "that's not X it's Y" or "only about Xg":

  1. Re-query nutrition_db for the corrected food
  2. Update the JSON entry
  3. Reply with corrected nutrition totals

Step 5 — Duplicate Detection

If the same photo is sent again, alert the user it was already logged and ask whether to record again.


Summaries

Daily summary:

cd $FOODLENS_DIR && source venv/bin/activate
python3 analyze_photo.py --summary today

Weekly trend (last 7 days):

cd $FOODLENS_DIR && source venv/bin/activate
python3 analyze_photo.py --weekly-summary yesterday 7

Data Layout

Path Description
data/YYYY-MM-DD.json Daily meal logs
nutrition_db.py 778 foods + 197 aliases
analyze_photo.py Main entry point
foodlens_config.json User nutrition goals
venv/ Python virtual environment
安全使用建议
This skill appears to do what it says, but it runs local Python code and sends images to LLM vision tools. Before installing or invoking: (1) Inspect the contents of $FOODLENS_DIR (especially analyze_photo.py, nutrition_db.py, and any activation scripts) to ensure they are safe and from a trusted source; (2) Run the code in an isolated environment (dedicated venv or container); (3) Be aware that images will be sent to external model providers (privacy risk) — avoid sending sensitive photos; (4) Back up any data you care about before letting the skill write to data/YYYY-MM-DD.json; (5) If you don’t already have the project code, obtain it from a trustworthy source rather than relying on this instruction-only skill to function automatically.
功能分析
Type: OpenClaw Skill Name: foodlens Version: 1.0.0 The skill instructions in SKILL.md direct the AI agent to execute shell commands and Python scripts using potentially user-controlled inputs (such as meal labels and file paths). This pattern presents a risk of command injection, which is classified as a vulnerability. While the behavior is aligned with the stated purpose of nutrition tracking and no clear evidence of malicious intent or data exfiltration was found, the reliance on unsanitized shell execution is a high-risk practice.
能力评估
Purpose & Capability
Name/description (meal-photo recognition, nutrition tracking) match the actions described: saving photos, running analyze_photo.py, consulting a local nutrition_db, appending JSON logs, and producing summaries. No unrelated credentials, binaries, or services are requested.
Instruction Scope
Instructions explicitly instruct the agent to save photos, activate a virtualenv, run local Python scripts (analyze_photo.py) and import from a local module (foodlens), then write JSON logs under a user directory. This is expected for a local tracker, but it means the skill will execute arbitrary Python code present in $FOODLENS_DIR and will read/write files there. Also the fallback uses an 'image' tool / GPT-4o Vision which will send image data to external model providers.
Install Mechanism
No install spec or third-party downloads are present (instruction-only). That reduces supply-chain risk, but it requires the user to supply the code, venv, and dependencies. The skill assumes local project files exist; nothing is downloaded automatically.
Credentials
The skill declares no required environment variables, credentials, or config paths beyond optional defaults for $FOODLENS_DIR and venv. The only notable external interaction is use of LLM vision/image tools (model/provider usage), which is consistent with image analysis but has privacy implications.
Persistence & Privilege
always:false (no forced global inclusion). The skill writes persistent data (data/YYYY-MM-DD.json) and expects a venv and local files under the specified workspace directory. Writing user-local logs is coherent for the purpose but grants the skill filesystem persistence within that directory.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install foodlens
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /foodlens 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
AI-powered meal photo recognition and nutrition tracking. GPT-4o Vision with 778-food nutrition database cross-validation.
元数据
Slug foodlens
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

FoodLens 是什么?

AI-powered meal photo recognition and nutrition tracking. Use when a user sends a food/meal photo with keywords like breakfast, lunch, dinner, snack, or "wha... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 113 次。

如何安装 FoodLens?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install foodlens」即可一键安装,无需额外配置。

FoodLens 是免费的吗?

是的,FoodLens 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

FoodLens 支持哪些平台?

FoodLens 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 FoodLens?

由 Karl Yang(@yxjsxy)开发并维护,当前版本 v1.0.0。

💬 留言讨论