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

Package RayIoU #47

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,22 @@ prediction/your_model
├── ...
```

3. Run `ray_metrics.py` to evaluate on the RayIoU:
3. Install `rayiou_metrics` package and use `evaluate_metrics` to evaluate on the RayIoU:

```
python ray_metrics.py --pred-dir prediction/your_model
cd rayiou_metrics
python setup.py install
```

```
# usage example:
from rayiou_metrics.evaluation import evaluate_metrics

gt_dir_root = 'data/nuscenes'
data_type = 'occ3d' # or 'openocc_v2'
pred_dir = prediction/your_model

metrics = evaluate_metrics(gt_dir_root, pred_dir, data_type)
```

## Timing
Expand Down
69 changes: 0 additions & 69 deletions ray_metrics.py

This file was deleted.

71 changes: 71 additions & 0 deletions rayiou_metrics/lib/dvr_cpu/dvr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Acknowledgments: https://github.com/tarashakhurana/4d-occ-forecasting
// Modified by Haisong Liu

#include <string>
#include <torch/extension.h>
#include <vector>

/*
* CUDA forward declarations
*/

std::vector<torch::Tensor> render_forward_cpu(torch::Tensor sigma,
torch::Tensor origin,
torch::Tensor points,
torch::Tensor tindex,
const std::vector<int> grid,
std::string phase_name);

std::vector<torch::Tensor>
render_cpu(torch::Tensor sigma, torch::Tensor origin, torch::Tensor points,
torch::Tensor tindex, std::string loss_name);

torch::Tensor init_cpu(torch::Tensor points, torch::Tensor tindex,
const std::vector<int> grid);

/*
* C++ interface
*/

#define CHECK_CUDA(x) \
TORCH_CHECK(x.type().is_cuda(), #x " must be a CUDA tensor")
#define CHECK_CONTIGUOUS(x) \
TORCH_CHECK(x.is_contiguous(), #x " must be contiguous")
#define CHECK_INPUT(x) \
CHECK_CUDA(x); \
CHECK_CONTIGUOUS(x)

std::vector<torch::Tensor>
render_forward(torch::Tensor sigma, torch::Tensor origin, torch::Tensor points,
torch::Tensor tindex, const std::vector<int> grid,
std::string phase_name) {
CHECK_CONTIGUOUS(sigma);
CHECK_CONTIGUOUS(origin);
CHECK_CONTIGUOUS(points);
CHECK_CONTIGUOUS(tindex);
return render_forward_cpu(sigma, origin, points, tindex, grid, phase_name);
}


std::vector<torch::Tensor> render(torch::Tensor sigma, torch::Tensor origin,
torch::Tensor points, torch::Tensor tindex,
std::string loss_name) {
CHECK_CONTIGUOUS(sigma);
CHECK_CONTIGUOUS(origin);
CHECK_CONTIGUOUS(points);
CHECK_CONTIGUOUS(tindex);
return render_cpu(sigma, origin, points, tindex, loss_name);
}

torch::Tensor init(torch::Tensor points, torch::Tensor tindex,
const std::vector<int> grid) {
CHECK_CONTIGUOUS(points);
CHECK_CONTIGUOUS(tindex);
return init_cpu(points, tindex, grid);
}

PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m.def("init", &init, "Initialize");
m.def("render", &render, "Render");
m.def("render_forward", &render_forward, "Render (forward pass only)");
}
Loading