Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,5 @@ cython_debug/
.DS_STORE
*.pt
.aider*
src/tmp/results/*
tmp/results/*
92 changes: 92 additions & 0 deletions README_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# SHARP:不到一秒的单目视图合成

[![项目页面](https://img.shields.io/badge/Project-Page-green)](https://apple.github.io/ml-sharp/)
[![arXiv](https://img.shields.io/badge/arXiv-2512.10685-b31b1b.svg)](https://arxiv.org/abs/2512.10685)

本软件项目是研究论文《Sharp Monocular View Synthesis in Less Than a Second》的配套代码,作者为:_Lars Mescheder, Wei Dong, Shiwei Li, Xuyang Bai, Marcel Santos, Peiyun Hu, Bruno Lecouat, Mingmin Zhen, Amaël Delaunoy, Tian Fang, Yanghai Tsin, Stephan Richter and Vladlen Koltun_。

![](data/teaser.jpg)

我们提出了SHARP,一种从单张图像生成逼真视图合成的方法。给定一张照片,SHARP通过神经网络的单次前向传递,在标准GPU上不到一秒的时间内回归出所描绘场景的3D高斯表示。然后,可以实时渲染SHARP生成的3D高斯表示,为附近视图生成高分辨率逼真图像。该表示是度量的,具有绝对尺度,支持度量相机运动。实验结果表明,SHARP在多个数据集上表现出稳健的零样本泛化能力。与最佳现有模型相比,它在多个数据集上建立了新的技术水平,将LPIPS降低了25–34%,DISTS降低了21–43%,同时将合成时间降低了三个数量级。

## 快速开始

我们建议首先创建一个Python环境:

```
conda create -n sharp python=3.13
```

然后,您可以使用以下命令安装项目:

```
pip install -r requirements.txt
```

要测试安装是否成功,运行:

```
sharp --help
```

## 使用命令行界面

要运行预测:

```
sharp predict -i /path/to/input/images -o /path/to/output/gaussians
```

模型检查点将在首次运行时自动下载并缓存在本地路径 `~/.cache/torch/hub/checkpoints/`。

或者,您可以直接下载模型:

```
wget https://ml-site.cdn-apple.com/models/sharp/sharp_2572gikvuh.pt
```

要使用手动下载的检查点,请使用 `-c` 参数指定:

```
sharp predict -i /path/to/input/images -o /path/to/output/gaussians -c sharp_2572gikvuh.pt
```

结果将是输出文件夹中的3D高斯图元(3DGS)。3DGS `.ply` 文件兼容各种公共3DGS渲染器。我们遵循OpenCV坐标约定(x向右,y向下,z向前)。3DGS场景中心大致在 (0, 0, +z)。使用第三方渲染器时,请相应地缩放和旋转以重新定位场景中心。

### 渲染轨迹(仅支持CUDA GPU)

此外,您还可以使用相机轨迹渲染视频。虽然高斯预测适用于所有CPU、CUDA和MPS,但通过 `--render` 选项渲染视频目前需要CUDA GPU。gsplat渲染器在首次启动时需要一段时间初始化。

```
sharp predict -i /path/to/input/images -o /path/to/output/gaussians --render

# 或者从中间高斯结果渲染:
sharp render -i /path/to/output/gaussians -o /path/to/output/renderings
```

## 评估

有关定量和定性评估,请参阅论文。此外,您可以查看此[定性示例页面](https://apple.github.io/ml-sharp/),其中包含与相关工作的多个视频比较。

## 引用

如果您发现我们的工作有用,请引用以下论文:

```bibtex
@inproceedings{Sharp2025:arxiv,
title = {Sharp Monocular View Synthesis in Less Than a Second},
author = {Lars Mescheder and Wei Dong and Shiwei Li and Xuyang Bai and Marcel Santos and Peiyun Hu and Bruno Lecouat and Mingmin Zhen and Ama"{e}l Delaunoy and Tian Fang and Yanghai Tsin and Stephan R. Richter and Vladlen Koltun},
journal = {arXiv preprint arXiv:2512.10685},
year = {2025},
url = {https://arxiv.org/abs/2512.10685},
}
```

## 致谢

我们的代码库基于多个开源贡献构建,请查看[ACKNOWLEDGEMENTS](ACKNOWLEDGEMENTS)了解更多详细信息。

## 许可证

在使用提供的代码之前,请查看仓库中的[LICENSE](LICENSE)文件,
对于发布的模型,请查看[LICENSE_MODEL](LICENSE_MODEL)文件。
139 changes: 139 additions & 0 deletions UV_INSTALLATION_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# SHARP 项目 UV 快速安装指南

本指南提供了使用 UV 包管理器快速安装和设置 SHARP 项目的详细步骤。UV 是一个高性能的 Python 包管理器,能够加速依赖安装过程。

## 项目介绍

SHARP 是一个用于从单张图像生成逼真视图合成的方法。它通过神经网络的单次前向传递,在不到一秒的时间内回归出场景的 3D 高斯表示,然后可以实时渲染附近视图的高分辨率逼真图像。

## 前提条件

- 操作系统:Windows、Linux 或 macOS
- Python 3.13(建议使用)
- CUDA GPU(用于渲染轨迹,预测功能支持 CPU、CUDA 和 MPS)

## 1. 安装 UV

### Windows

在 PowerShell 中运行以下命令:

```powershell
(Invoke-WebRequest -Uri https://astral.sh/uv/install.ps1 -UseBasicParsing).Content | PowerShell -
```

### Linux/macOS

在终端中运行以下命令:

```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

## 2. 克隆仓库

```bash
git clone https://github.com/apple/ml-sharp.git
cd ml-sharp
```

## 3. 创建虚拟环境

使用 UV 创建一个 Python 3.13 虚拟环境:

```bash
uv venv --python 3.13 venv
```

## 4. 激活虚拟环境

### Windows

```powershell
venv\Scripts\activate
```

### Linux/macOS

```bash
source venv/bin/activate
```

## 5. 安装依赖

使用 UV 安装项目依赖:

```bash
uv pip install -r requirements.txt
```

## 6. 验证安装

运行以下命令验证安装是否成功:

```bash
sharp --help
```

如果安装成功,您将看到类似以下输出:

```
Usage: sharp [OPTIONS] COMMAND [ARGS]...

Run inference for SHARP model.

Options:
--help Show this message and exit.

Commands:
predict Predict Gaussians from input images.
render Predict Gaussians from input images.
```

## 使用示例

### 预测 3D 高斯表示

```bash
sharp predict -i /path/to/input/images -o /path/to/output/gaussians
```

### 渲染轨迹视频(需要 CUDA GPU)

```bash
# 从输入图像预测并渲染
sharp predict -i /path/to/input/images -o /path/to/output/gaussians --render

# 从已有的高斯表示渲染
sharp render -i /path/to/output/gaussians -o /path/to/output/renderings
```

## 故障排除

### UV 安装失败

- 确保您的网络连接正常
- 尝试使用管理员权限运行安装命令
- 检查系统防火墙设置,确保允许 UV 下载依赖

### 依赖安装失败

- 确保您使用的是推荐的 Python 3.13 版本
- 尝试清理 UV 缓存:`uv cache clean`
- 检查 `requirements.txt` 文件是否存在且完整

### 运行 `sharp --help` 失败

- 确保虚拟环境已正确激活
- 检查是否所有依赖都已成功安装
- 尝试重新安装项目:`uv pip install -e .`

## 相关链接

- [项目主页](https://apple.github.io/ml-sharp/)
- [UV 官方文档](https://docs.astral.sh/uv/)
- [SHARP 论文](https://arxiv.org/abs/2512.10685)

## 许可证

请查看仓库中的 [LICENSE](LICENSE) 和 [LICENSE_MODEL](LICENSE_MODEL) 文件了解许可证信息。
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ description = "Inference/Network/Model code for SHARP view synthesis model."
readme = "README.md"
dependencies = [
"click",
"fastapi",
"gradio",
"gsplat",
"imageio[ffmpeg]",
"matplotlib",
"pillow-heif",
"plyfile",
"pydantic",
"python-multipart",
"requests",
"scipy",
"timm",
"torch",
"torchvision",
"uvicorn[standard]",
]

[project.scripts]
Expand Down
Empty file added src/api/__init__.py
Empty file.
Loading