Loading...
Loading...
Compare original and translation side by side
exec(open('skills/image-portrait/generate_portrait.py').read())
result = generate_portrait(
image_path="path/to/user/photo.jpg",
style="professional",
)exec(open('skills/image-portrait/generate_portrait.py').read())
result = generate_portrait(
image_path="path/to/user/photo.jpg",
style="professional",
)
The script reads the local file, base64-encodes it, and sends it to fal.ai as a data URI — no manual URL publishing needed.
该脚本会读取本地文件,将其base64编码后以数据URI形式发送至fal.ai——无需手动发布URL。exec(open('skills/image-portrait/generate_portrait.py').read())
result = generate_portrait(
face_image_url="https://example.com/photo.jpg",
style="anime",
)exec(open('skills/image-portrait/generate_portrait.py').read())
result = generate_portrait(
face_image_url="https://example.com/photo.jpg",
style="anime",
)exec(open('skills/image-portrait/generate_portrait.py').read())
result = generate_portrait(
prompt="a young woman in cyberpunk armor, neon city background, rain",
model="nanopro",
)image_pathface_image_url/editexec(open('skills/image-portrait/generate_portrait.py').read())
result = generate_portrait(
prompt="a young woman in cyberpunk armor, neon city background, rain",
model="nanopro",
)image_pathface_image_url/editlocal_pathoutput/images/xxx.pngoutput/images/send_to_telegram(file_path="output/images/...", message_type="image")send_to_wechat(file_path="output/images/...", message_type="image")local_pathoutput/images/xxx.pngoutput/images/send_to_telegram(file_path="output/images/...", message_type="image")send_to_wechat(file_path="output/images/...", message_type="image")| Parameter | Required | Default | Description |
|---|---|---|---|
| no | — | Local workspace file path to the user's face photo |
| no | — | Public HTTPS URL of the user's face photo |
| no | | Preset style key (see §5) |
| no | | Custom scene description (appended to style prompt) |
| no | | Fully custom prompt — overrides style+scene when set |
| no | | Model: |
| no | | Number of images to generate (1–8) |
| no | | Output ratio: |
image_pathface_image_urlimage_pathpromptstyle + scenestyleprofessional| 参数名 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|
| 否 | — | 用户面部照片在工作区的本地文件路径 |
| 否 | — | 用户面部照片的公开HTTPS URL |
| 否 | | 预设风格键(见第5节) |
| 否 | | 自定义场景描述(会追加到风格提示词后) |
| 否 | | 完全自定义提示词——设置后会覆盖style+scene的组合 |
| 否 | | 模型选项: |
| 否 | | 生成图像数量(1–8张) |
| 否 | | 输出比例: |
image_pathface_image_urlimage_pathpromptstyle + scenestyleprofessional| Style | Key | Best for |
|---|---|---|
| Professional headshot | | LinkedIn, resume, corporate |
| Artistic portrait | | Creative portfolio, gallery |
| Anime | | Social media, fun avatar |
| Cyberpunk | | Gaming profile, sci-fi fan |
| Oil painting | | Art gift, classical look |
| Watercolor | | Soft artistic portrait |
| Vintage | | Retro aesthetic, nostalgia |
| Casual lifestyle | | Social media, personal blog |
| 风格 | 键值 | 适用场景 |
|---|---|---|
| 专业证件照 | | LinkedIn、简历、企业场景 |
| 艺术肖像 | | 创意作品集、画廊展示 |
| 动漫风格 | | 社交媒体、趣味头像 |
| 赛博朋克风格 | | 游戏资料、科幻爱好者 |
| 油画风格 | | 艺术礼品、古典风格 |
| 水彩风格 | | 柔和艺术肖像 |
| 复古风格 | | 复古美学、怀旧场景 |
| 休闲生活风格 | | 社交媒体、个人博客 |
| Style | Key | Best for |
|---|---|---|
| Dating — cafe | | Dating app, warm vibe |
| Dating — beach | | Dating app, summer vibe |
| Dating — city | | Dating app, urban vibe |
| Dating — restaurant | | Dating app, elegant vibe |
| Travel — Europe | | Travel blog, social media |
| Travel — Japan | | Travel blog, cultural |
| Travel — tropical | | Vacation, resort |
| Sports — gym | | Fitness profile |
| Sports — running | | Athletic profile |
| Social media | | Instagram, TikTok |
| Professional networking | |
| Personal brand | | Entrepreneur, creator |
| 风格 | 键值 | 适用场景 |
|---|---|---|
| 约会——咖啡馆 | | 约会应用、温暖氛围 |
| 约会——海滩 | | 约会应用、夏日氛围 |
| 约会——都市 | | 约会应用、都市氛围 |
| 约会——餐厅 | | 约会应用、优雅氛围 |
| 旅行——欧洲 | | 旅行博客、社交媒体 |
| 旅行——日本 | | 旅行博客、文化场景 |
| 旅行——热带 | | 度假、度假村场景 |
| 运动——健身房 | | 健身资料 |
| 运动——跑步 | | 运动资料 |
| 社交媒体风格 | | Instagram、TikTok |
| LinkedIn风格 | | 职业社交场景 |
| 个人品牌风格 | | 创业者、内容创作者 |
| Style | Key | Best for |
|---|---|---|
| Christmas | | Holiday greeting, social |
| Halloween | | Holiday fun |
| Graduation | | Milestone celebration |
| Wedding | | Wedding planning, save-the-date |
| Business speech | | Speaker profile |
| Musician | | Music promotion |
| Chef | | Food blog, restaurant |
| Outdoor adventure | | Adventure blog |
| Pet together | | Pet lover profile |
| Reading | | Book club, literary |
| Night city | | Urban lifestyle |
| Hanfu (Chinese traditional) | | Cultural, cosplay |
| 风格 | 键值 | 适用场景 |
|---|---|---|
| 圣诞主题 | | 节日问候、社交场景 |
| 万圣节主题 | | 节日趣味场景 |
| 毕业主题 | | 里程碑纪念 |
| 婚礼主题 | | 婚礼筹备、日期预告 |
| 商务演讲场景 | | 演讲者资料 |
| 音乐人场景 | | 音乐推广 |
| 厨师场景 | | 美食博客、餐厅宣传 |
| 户外探险场景 | | 探险博客 |
| 与宠物同框 | | 宠物爱好者资料 |
| 阅读场景 | | 读书俱乐部、文学场景 |
| 都市夜景 | | 都市生活风格 |
| 汉服(中国传统服饰) | | 文化场景、Cosplay |
| Style | Key | Best for |
|---|---|---|
| 3D cartoon | | Social avatar, Pixar style |
| Gaming avatar | | Game profile, RPG |
| VTuber | | Streaming, VTuber |
| 风格 | 键值 | 适用场景 |
|---|---|---|
| 3D卡通头像 | | 社交头像、皮克斯风格 |
| 游戏头像 | | 游戏资料、RPG角色 |
| VTuber头像 | | 直播场景、虚拟主播 |
| Style | Key | Best for |
|---|---|---|
| Child portrait | | Family keepsake |
| Family photo | | Family portrait |
| 风格 | 键值 | 适用场景 |
|---|---|---|
| 儿童肖像 | | 家庭纪念 |
| 家庭合照 | | 家庭肖像 |
| Style | Key | Best for |
|---|---|---|
| ID photo (white bg) | | Passport, driver's license |
| ID photo (blue bg) | | Visa, work permit |
| 风格 | 键值 | 适用场景 |
|---|---|---|
| 身份证件照(白底) | | 护照、驾照 |
| 身份证件照(蓝底) | | 签证、工作许可 |
| Model | Key | Speed | Quality | Best for |
|---|---|---|---|---|
| Nano Banana 2 | | ~15s | Good | Quick drafts, fast iteration, bulk generation. |
| NanoPro | | ~25s | Better | Default for all requests. Balanced speed and quality. |
| GPT Image 2 | | ~150s | Best | When user explicitly asks for "highest quality" or "best quality". Complex scenes. |
nanopronano2gptundefined| 模型 | 键值 | 速度 | 质量 | 适用场景 |
|---|---|---|---|---|
| Nano Banana 2 | | ~15秒 | 良好 | 快速草稿、快速迭代、批量生成 |
| NanoPro | | ~25秒 | 更优 | 所有请求的默认选项,平衡速度与质量 |
| GPT Image 2 | | ~150秒 | 最佳 | 用户明确要求“最高质量”或场景复杂包含大量细节时 |
nanopronano2gptundefined
---
---undefinedundefined
---
---promptpromptavatar_3davatar_gamingavatar_vtuberavatar_3davatar_gamingavatar_vtuber[subject], [outfit/attire], [pose/action], [expression], [background/setting], [lighting], [style/quality modifiers][主体], [服装/着装], [姿势/动作], [表情], [背景/场景], [光线], [风格/质量修饰词]result = generate_portrait(
image_path="uploads/photo.jpg",
prompt=(
"fantasy wizard portrait, wearing mystical purple robes with glowing runes, "
"ancient wooden staff with crystal orb, wise powerful expression, "
"enchanted forest background with bioluminescent plants and floating particles, "
"dramatic magical lighting with ethereal glow, "
"high fantasy art style, detailed digital painting quality"
),
)result = generate_portrait(
image_path="uploads/photo.jpg",
prompt=(
"fantasy wizard portrait, wearing mystical purple robes with glowing runes, "
"ancient wooden staff with crystal orb, wise powerful expression, "
"enchanted forest background with bioluminescent plants and floating particles, "
"dramatic magical lighting with ethereal glow, "
"high fantasy art style, detailed digital painting quality"
),
)undefinedundefinedresult = generate_portrait(
image_path="uploads/photo.jpg",
prompt=(
"retro 16-bit pixel art portrait, visible pixels with clean lines, "
"rich colors, consistent shading, stylized but maintains individual features, "
"warm sunset cityscape background in matching pixel art style, "
"head and shoulders, square format"
),
)result = generate_portrait(
image_path="uploads/photo.jpg",
prompt=(
"retro 16-bit pixel art portrait, visible pixels with clean lines, "
"rich colors, consistent shading, stylized but maintains individual features, "
"warm sunset cityscape background in matching pixel art style, "
"head and shoulders, square format"
),
)exec(open('skills/image-portrait/generate_portrait.py').read())
result = generate_series(
image_path="uploads/my_photo.jpg",
series=[
{"style": "professional"},
{"style": "casual", "scene": "at a rooftop bar, sunset"},
{"style": "anime"},
{"prompt": "portrait as a superhero, cape flowing, city skyline"},
],
)exec(open('skills/image-portrait/generate_portrait.py').read())
result = generate_series(
image_path="uploads/my_photo.jpg",
series=[
{"style": "professional"},
{"style": "casual", "scene": "at a rooftop bar, sunset"},
{"style": "anime"},
{"prompt": "portrait as a superhero, cape flowing, city skyline"},
],
)
Each item in the list is a dict with optional keys:
- `style` — any style key from §7 (e.g. `"professional"`, `"anime"`, `"cyberpunk"`)
- `scene` — override the scene description (combined with the style template)
- `prompt` — fully custom prompt (ignores style/scene)
---
列表中的每个元素是一个字典,包含可选键:
- `style` — 第7节中的任意风格键(例如`"professional"`、`"anime"`、`"cyberpunk"`)
- `scene` — 覆盖场景描述(与风格模板结合)
- `prompt` — 完全自定义提示词(忽略style/scene)
---| User says | Style | Notes |
|---|---|---|
| "professional photo", "headshot", "LinkedIn photo" | | |
| "dating photo", "dating app", "Tinder photo" | | Ask which vibe |
| "anime me", "anime version", "cartoon me" | | |
| "cyberpunk", "sci-fi portrait" | | |
| "oil painting", "classical portrait" | | |
| "watercolor portrait" | | |
| "vintage photo", "retro" | | |
| "casual photo", "lifestyle" | | |
| "travel photo in Paris/Europe" | | |
| "travel photo in Japan/Tokyo/Kyoto" | | |
| "beach photo", "tropical" | | |
| "gym photo", "fitness" | | |
| "Christmas photo" | | |
| "Halloween photo" | | |
| "graduation photo" | | |
| "wedding photo" | | |
| "chef photo", "cooking" | | |
| "musician", "on stage" | | |
| "with my dog/pet" | | |
| "reading", "bookish" | | |
| "night city", "urban night" | | |
| "hanfu", "Chinese traditional" | | |
| "3D avatar", "Pixar style" | | |
| "gaming avatar", "RPG character" | | |
| "VTuber avatar" | | |
| "kid photo", "children's portrait" | | |
| "family photo" | | |
| "passport photo", "ID photo" | | White bg default |
| "visa photo" | | Blue bg |
| "photo series", "set of photos" | Use | Assemble custom list from styles |
| "highest quality", "best quality" | Any style + | |
| Custom scene not in presets | Use |
| 用户表述 | 风格键值 | 备注 |
|---|---|---|
| "专业照片"、"证件照"、"LinkedIn照片" | | |
| "约会照"、"约会应用"、"Tinder照片" | | 询问用户偏好的氛围 |
| "把我做成动漫风格"、"动漫版的我"、"卡通头像" | | |
| "赛博朋克"、"科幻肖像" | | |
| "油画风格"、"古典肖像" | | |
| "水彩肖像" | | |
| "复古照片"、"怀旧风格" | | |
| "休闲照片"、"生活风格" | | |
| "欧洲/巴黎旅行照" | | |
| "日本/东京/京都旅行照" | | |
| "海滩照"、"热带风格" | | |
| "健身房照片"、"健身风格" | | |
| "圣诞照片" | | |
| "万圣节照片" | | |
| "毕业照" | | |
| "婚礼照片" | | |
| "厨师照片"、"烹饪风格" | | |
| "音乐人"、"舞台场景" | | |
| "和我的狗/宠物一起" | | |
| "阅读风格"、"书呆子风格" | | |
| "都市夜景"、"城市夜生活" | | |
| "汉服"、"中国传统服饰" | | |
| "3D头像"、"皮克斯风格" | | |
| "游戏头像"、"RPG角色" | | |
| "VTuber头像" | | |
| "儿童照片"、"儿童肖像" | | |
| "家庭合照" | | |
| "护照照片"、"身份证件照" | | 默认白底 |
| "签证照片" | | 蓝底 |
| "照片系列"、"一组照片" | 使用 | 根据风格组装自定义列表 |
| "最高质量"、"最佳质量" | 任意风格 + | |
| 预设中没有的自定义场景 | 使用 |
| File | Purpose |
|---|---|
| Core script: submit → poll → download. Handles local files (base64) and URLs, all styles, custom scenes, three models (nano2/nanopro/gpt). |
| Re-exports |
| Cost tracking helper — records per-call costs via sc-proxy headers. |
| 文件 | 用途 |
|---|---|
| 核心脚本:提交→轮询→下载。支持本地文件(base64)和URL、所有风格、自定义场景、三种模型(nano2/nanopro/gpt)。 |
| 重新导出 |
| 成本跟踪辅助工具——通过sc-proxy头记录每次调用的成本。 |
FAL_KEYundefinedFAL_KEYundefined
---
---| Problem | Fix |
|---|---|
| Check the workspace path; the file must exist |
| Use |
| Resize to under 10 MB before uploading |
| Use |
| Top up balance; cost is pre-charged on submit |
| sc-proxy only allows approved fal endpoints; contact admin |
Generation | Simplify prompt, ensure face photo is clear and well-lit, retry |
Job stuck | Save |
| Poor face consistency | Use a clear, front-facing photo with good lighting; avoid group photos |
| Switch to |
| 问题 | 解决方法 |
|---|---|
| 检查工作区路径;文件必须存在 |
| 使用 |
| 上传前将图片调整至10 MB以下 |
| 本地文件使用 |
| 充值余额;提交请求时会预扣费 |
| sc-proxy仅允许已批准的fal端点;联系管理员 |
上游生成 | 简化提示词,确保面部照片清晰且光线良好,重试 |
任务长时间处于 | 保存 |
| 面部一致性差 | 使用清晰、正面、光线良好的照片;避免集体照 |
| 切换为 |
sc-proxyqueue.fal.run/{model}Authorization: Key fake-falai-key-12345FAL_KEYhttps://*.fal.media/..._cost_track.pyX-Credits-Usedsc-proxyqueue.fal.run/{model}Authorization: Key fake-falai-key-12345FAL_KEYhttps://*.fal.media/..._cost_track.pyX-Credits-Used| Model | Edit (with ref image) | Generate (text only) |
|---|---|---|
| nano2 | | |
| nanopro | | |
| gpt | | |
| 模型 | 编辑模式(带参考图像) | 生成模式(仅文本) |
|---|---|---|
| nano2 | | |
| nanopro | | |
| gpt | | |