Skip to content

Commit bdbae99

Browse files
voletivVikram Voleti
and
Vikram Voleti
authoredMar 18, 2024
Fixes azimuth, adds simple instruction (#307)
* Fixes azimuth, adds simple instruction * Adds assertts --------- Co-authored-by: Vikram Voleti <vikram@ip-26-0-153-234.us-west-2.compute.internal>
1 parent 2a532db commit bdbae99

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed
 

‎README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ To run SV3D_u on a single image:
1616
- Download `sv3d_u.safetensors` from https://huggingface.co/stabilityai/sv3d to `checkpoints/sv3d_u.safetensors`
1717
- Run `python scripts/sampling/simple_video_sample.py --input_path <path/to/image.png> --version sv3d_u`
1818

19-
Additionally for SV3D_p,
20-
- Specify sequences of 21 elevations and 21 azimuths (in degrees) to `elevations_deg` ([-90, 90]), and `azimuths_deg` [0, 360] in sorted order from 0 to 360. For example:
21-
`python scripts/sampling/simple_video_sample.py --input_path <path/to/image.png> --version sv3d_p --elevations_deg [<list of 21 elevations in degrees>] --azimuths_deg [<list of 21 azimuths in degrees>]`
19+
To run SV3D_u on a single image:
20+
- Download `sv3d_p.safetensors` from https://huggingface.co/stabilityai/sv3d to `checkpoints/sv3d_p.safetensors`
21+
1. Generate static orbit at a specified elevation eg. 10 : `python scripts/sampling/simple_video_sample.py --input_path <path/to/image.png> --version sv3d_p --elevations_deg 10.0`
22+
2. Generate dynamic orbit at a specified elevations and azimuths: specify sequences of 21 elevations (in degrees) to `elevations_deg` ([-90, 90]), and 21 azimuths (in degrees) to `azimuths_deg` [0, 360] in sorted order from 0 to 360. For example: `python scripts/sampling/simple_video_sample.py --input_path <path/to/image.png> --version sv3d_p --elevations_deg [<list of 21 elevations in degrees>] --azimuths_deg [<list of 21 azimuths in degrees>]`
2223

2324
To run SVD or SV3D on a streamlit server:
2425
`streamlit run scripts/demo/video_sampling.py`

‎scripts/sampling/simple_video_sample.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def sample(
3434
device: str = "cuda",
3535
output_folder: Optional[str] = None,
3636
elevations_deg: Optional[float | List[float]] = 10.0, # For SV3D
37-
azimuths_deg: Optional[float | List[float]] = None, # For SV3D
37+
azimuths_deg: Optional[List[float]] = None, # For SV3D
3838
image_frame_ratio: Optional[float] = None,
3939
verbose: Optional[bool] = False,
4040
):
@@ -81,10 +81,17 @@ def sample(
8181
cond_aug = 1e-5
8282
if isinstance(elevations_deg, float) or isinstance(elevations_deg, int):
8383
elevations_deg = [elevations_deg] * num_frames
84+
assert (
85+
len(elevations_deg) == num_frames
86+
), f"Please provide 1 value, or a list of {num_frames} values for elevations_deg! Given {len(elevations_deg)}"
8487
polars_rad = [np.deg2rad(90 - e) for e in elevations_deg]
8588
if azimuths_deg is None:
8689
azimuths_deg = np.linspace(0, 360, num_frames + 1)[1:] % 360
87-
azimuths_rad = [np.deg2rad(a) for a in azimuths_deg]
90+
assert (
91+
len(azimuths_deg) == num_frames
92+
), f"Please provide a list of {num_frames} values for azimuths_deg! Given {len(azimuths_deg)}"
93+
azimuths_rad = [np.deg2rad((a - azimuths_deg[-1]) % 360) for a in azimuths_deg]
94+
azimuths_rad[:-1].sort()
8895
else:
8996
raise ValueError(f"Version {version} does not exist.")
9097

0 commit comments

Comments
 (0)