Skip to content

Commit 11b7a32

Browse files
authored
Implement fused SSIM (#30)
* Implement fused ssim * Remove Flux * Update tests & cleanup deps
1 parent 0797bfe commit 11b7a32

File tree

12 files changed

+638
-252
lines changed

12 files changed

+638
-252
lines changed

LocalPreferences.toml

Lines changed: 0 additions & 9 deletions
This file was deleted.

Project.toml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ authors = ["Anton Smirnov <[email protected]>"]
66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
88
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
9-
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
109
CImGui = "5d785b6c-b76f-510e-a07c-3070796c7e87"
1110
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
1211
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
1312
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
1413
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
15-
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
1614
GLFW = "f7f18e0c-5ee9-5ccd-a5bf-e8befd85ed98"
1715
GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
1816
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
@@ -29,7 +27,6 @@ NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce"
2927
NerfUtils = "99c1d5ce-7c61-4a25-a107-a5ade2e2a8e4"
3028
NeuralGraphicsGL = "263f7e6d-e369-49af-a86e-c85638573b76"
3129
PlyIO = "42171d58-473b-503a-8d5f-782019eb09ec"
32-
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
3330
Quaternions = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0"
3431
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
3532
Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc"
@@ -42,23 +39,20 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
4239
[weakdeps]
4340
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
4441
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
45-
cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd"
4642

4743
[extensions]
4844
GaussianSplattingAMDGPUExt = "AMDGPU"
49-
GaussianSplattingCUDAExt = ["CUDA", "cuDNN"]
45+
GaussianSplattingCUDAExt = "CUDA"
5046

5147
[compat]
5248
AMDGPU = "2"
5349
Adapt = "4"
5450
BSON = "0.3"
55-
BenchmarkTools = "1"
5651
CImGui = "6"
5752
CUDA = "5"
5853
ChainRulesCore = "1"
5954
Distributions = "0.25"
6055
FileIO = "1.16"
61-
Flux = "0.16.2"
6256
GLFW = "3.4"
6357
GPUArrays = "11.2.1"
6458
GPUArraysCore = "0.2"
@@ -74,12 +68,10 @@ NearestNeighbors = "0.4"
7468
NerfUtils = "0.2"
7569
NeuralGraphicsGL = "0.5"
7670
PlyIO = "1.2"
77-
Preferences = "1.4"
7871
Quaternions = "0.7"
7972
Rotations = "1.7"
8073
SIMD = "3.6"
8174
StaticArrays = "1.9"
8275
VideoIO = "1.1"
8376
Zygote = "=0.7.3"
84-
cuDNN = "1.3"
8577
julia = "1.10"

docs/src/index.md

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@ GaussianSplatting.jl comes with a GUI application to train & view the gaussians.
2525
1. Add necessary packages:
2626
```julia
2727
] add AMDGPU # for AMD GPU
28-
] add CUDA, cuDNN # for Nvidia GPU
29-
] add Flux
28+
] add CUDA # for Nvidia GPU
3029
```
3130

3231
2. Run:
3332
```julia
34-
julia> using AMDGPU # for AMD GPU
35-
julia> using CUDA, cuDNN # for Nvidia GPU
36-
julia> using Flux, GaussianSplatting
37-
38-
julia> GaussianSplatting.gui("path-to-colmap-dataset-directory"; scale=1)
33+
julia> using AMDGPU; kab = ROCBackend() # for AMD GPU
34+
julia> using CUDA; kab = CUDABackend() # for Nvidia GPU
35+
julia> GaussianSplatting.gui(kab, "path-to-colmap-dataset-directory"; scale=1)
3936
```
4037

4138
## Viewer mode
@@ -44,27 +41,12 @@ Once you've trained a model and saved it to `.bson` file you can open it
4441
in a viewer-only mode by providing its path.
4542

4643
```julia
47-
julia> GaussianSplatting.gui("path-to-checkpoint.bson")
44+
julia> GaussianSplatting.gui(kab, "path-to-checkpoint.bson")
4845
```
4946

5047
Alternative, you can load a checkpoint
5148
in a training mode (see **Usage** section) using "Save/Load" tab.
5249

53-
## GPU selection
54-
55-
This is required only the first time per the environment.
56-
After selecting GPU backend, restart Julia REPL.
57-
58-
- AMD GPU:
59-
```julia
60-
julia> Flux.gpu_backend!("AMDGPU")
61-
```
62-
63-
- Nvidia GPU:
64-
```julia
65-
julia> Flux.gpu_backend!("CUDA")
66-
```
67-
6850
## References
6951

7052
- 3D Gaussian Splatting for Real-Time Radiance Field Rendering: <https://arxiv.org/abs/2308.04079>

ext/GaussianSplattingCUDAExt/GaussianSplattingCUDAExt.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module GaussianSplattingCUDAExt
22

33
# using Adapt
44
using CUDA
5-
# using cuDNN
65
# using KernelAbstractions
76
using GaussianSplatting
87
# using PrecompileTools

src/GaussianSplatting.jl

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ using Random
1717
using Rotations
1818
using StaticArrays
1919
using Statistics
20-
using Preferences
2120
using ImageCore
2221
using ImageIO
2322
using ImageTransformations
@@ -33,8 +32,8 @@ using GLFW
3332
import CImGui.lib as iglib
3433

3534
import BSON
35+
import ChainRulesCore as CRC
3636
import NNlib
37-
import Flux
3837
import ImageFiltering
3938
import KernelAbstractions as KA
4039
import NerfUtils as NU
@@ -56,7 +55,7 @@ _as_T(T, x) = reinterpret(T, reshape(x, :))
5655

5756
include("simd.jl")
5857
include("utils.jl")
59-
include("metrics.jl")
58+
include("fused_ssim.jl")
6059
include("camera.jl")
6160
include("camera_opt.jl")
6261
include("dataset.jl")
@@ -67,9 +66,6 @@ include("rasterization/rasterizer.jl")
6766
include("training.jl")
6867
include("gui/gui.jl")
6968

70-
# Hacky way to get KA.Backend.
71-
gpu_backend() = get_backend(Flux.gpu(Array{Int}(undef, 0)))
72-
7369
base_array_type(backend) = error("Not implemented for backend: `$backend`.")
7470

7571
allocate_pinned(kab, T, shape) = error("Pinned memory not supported for `$kab`.")
@@ -78,8 +74,7 @@ unpin_memory(x) = error("Unpinning memory is not supported for `$(typeof(x))`.")
7874

7975
use_ak(kab) = false
8076

81-
function main(dataset_path::String; scale::Int, save_path::Maybe{String} = nothing)
82-
kab = gpu_backend()
77+
function main(kab, dataset_path::String; scale::Int, save_path::Maybe{String} = nothing)
8378
@info "Using `$kab` GPU backend."
8479

8580
dataset = ColmapDataset(kab, dataset_path;
@@ -151,7 +146,7 @@ function main(dataset_path::String; scale::Int, save_path::Maybe{String} = nothi
151146
return
152147
end
153148

154-
function gui(path::String; scale::Maybe{Int} = nothing, fullscreen::Bool = false)
149+
function gui(kab, path::String; scale::Maybe{Int} = nothing, fullscreen::Bool = false)
155150
ispath(path) || error("Path does not exist: `$path`.")
156151

157152
viewer_mode = endswith(path, ".bson") || endswith(path, ".ply")
@@ -166,7 +161,6 @@ function gui(path::String; scale::Maybe{Int} = nothing, fullscreen::Bool = false
166161
(1024, 1024, true)
167162

168163
gui = if viewer_mode
169-
kab = gpu_backend()
170164
if endswith(path, ".bson")
171165
θ = BSON.load(path)
172166
gaussians = GaussianModel(kab)
@@ -179,9 +173,9 @@ function gui(path::String; scale::Maybe{Int} = nothing, fullscreen::Bool = false
179173
camera = Camera(; fx=fov, fy=fov, width, height=width)
180174
end
181175

182-
GSGUI(gaussians, camera; width, height, fullscreen, resizable)
176+
GSGUI(kab, gaussians, camera; width, height, fullscreen, resizable)
183177
else
184-
GSGUI(path, scale; width, height, fullscreen, resizable)
178+
GSGUI(kab, path, scale; width, height, fullscreen, resizable)
185179
end
186180
gui |> launch!
187181
return

0 commit comments

Comments
 (0)