Photo to 3D Model
Two-step pipeline that converts any photo into a 3D model:
- 1. Gemini preprocess — Transform photo into a clean white-background 45° isometric view
- Tripo3D generate — Convert the isometric image into a .glb 3D model
Requirements
- -
GEMINI_API_KEY — Get from https://aistudio.google.com/apikey - INLINECODE1 — Get from https://platform.tripo3d.ai/
Usage
CODEBLOCK0
Output
- -
output/{name}_isometric.png — Gemini-generated isometric view - INLINECODE3 — Final 3D model file
Default Gemini Prompt
The built-in prompt generates a 45° isometric "3D-printed model" style render with PBR materials on a pure white background. Override with --prompt for custom styles (e.g., game assets, architectural models, product renders).
Notes
- - Supported input: .jpg, .jpeg, .png, .webp
- Tripo3D generation takes ~1-3 minutes depending on complexity
- For higher quality, preprocess source images with upscayl before running
- Output .glb files can be converted to .usdz for Apple AR using INLINECODE5
照片转3D模型
将任意照片转换为3D模型的两步流程:
- 1. Gemini预处理 — 将照片转换为纯白背景的45°等轴测视图
- Tripo3D生成 — 将等轴测图像转换为.glb格式的3D模型
环境要求
- - GEMINIAPIKEY — 从 https://aistudio.google.com/apikey 获取
- TRIPOAPIKEY — 从 https://platform.tripo3d.ai/ 获取
使用方法
bash
完整流程:照片 → 等轴测视图 → 3D模型
python3 scripts/photo
to3d.py <图片路径>
自定义Gemini预处理提示词
python3 scripts/photo
to3d.py <图片路径> --prompt 您的自定义提示词
跳过预处理(图片已是干净的等轴测视图)
python3 scripts/photo
to3d.py <图片路径> --skip-preprocess
自定义输出目录
python3 scripts/photo
to3d.py <图片路径> --output-dir ./my_output
输出文件
- - output/{名称}isometric.png — Gemini生成的等轴测视图
- output/{名称}model.glb — 最终3D模型文件
默认Gemini提示词
内置提示词会在纯白背景上生成带有PBR材质的45°等轴测3D打印模型风格渲染图。可通过--prompt参数覆盖默认提示词以实现自定义风格(例如游戏资产、建筑模型、产品渲染等)。
注意事项
- - 支持的输入格式:.jpg、.jpeg、.png、.webp
- Tripo3D生成时间约1-3分钟,具体取决于模型复杂度
- 如需更高质量,建议先使用upscayl对源图像进行预处理
- 输出的.glb文件可使用usdzconvert工具转换为适用于Apple AR的.usdz格式