Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PrecompileTools #18

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
Next Next commit
Add PrecompileTools
vchuravy committed Jun 28, 2024
commit 3da141f7fb84448e633a43357e8ab4f3d9c18da5
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ JpegTurbo = "b835a17e-a41a-41e7-81f0-2f016b05efe0"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NerfUtils = "99c1d5ce-7c61-4a25-a107-a5ade2e2a8e4"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Quaternions = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0"
Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc"
@@ -41,6 +42,7 @@ JSON = "0.21"
JpegTurbo = "0.1"
KernelAbstractions = "0.9"
NerfUtils = "0.1.5"
PrecompileTools = "1.2.1"
Preferences = "1.4"
Quaternions = "0.7"
Rotations = "1.6"
20 changes: 20 additions & 0 deletions src/Nerf.jl
Original file line number Diff line number Diff line change
@@ -115,4 +115,24 @@ function main()
return
end

using PrecompileTools

@setup_workload let
# TODO: KA.functional(Backend)
config_file = joinpath(pkgdir(Nerf), "data", "raccoon_sofa2", "transforms.json")
dataset = Dataset(Backend; config_file)
model = BasicModel(BasicField(Backend))
trainer = Trainer(model, dataset; n_rays=4)

camera = Camera(MMatrix{3, 4, Float32}(I), dataset.intrinsics)
renderer = Renderer(Backend, camera, trainer.bbox, trainer.cone)

loss = step!(trainer)
pose_idx = clamp(round(Int, rand() * length(dataset)), 1, length(dataset))
NU.set_projection!(camera, get_pose(dataset, pose_idx)...)
render!(renderer, trainer.occupancy, trainer.bbox) do points, directions
model(points, directions)
end
end

end