Skip to content

Commit caa4d0d

Browse files
committed
Add vid loading working with MPS./VidStreamer nil 0
1 parent c93a047 commit caa4d0d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

demos/video/cvutil.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@ cv::Mat to_mat(torch::Tensor &tensor) {
8686

8787
int height = tensor.size(2);
8888
int width = tensor.size(3);
89-
auto t = tensor.squeeze()
89+
auto t = tensor
90+
.mul(255)
91+
.squeeze()
9092
.detach()
9193
.permute({1, 2, 0})
9294
.contiguous()
9395
.to(torch::kUInt8)
94-
.mul(255)
9596
// .clamp(0, 255)
9697
.clone()
9798
.to(torch::kCPU);
@@ -113,7 +114,7 @@ cv::Mat to_mat(torch::Tensor &tensor) {
113114

114115
torch::Device get_default_device() {
115116
if (torch::mps::is_available()) {
116-
// default_device = torch::Device(torch::kMPS);
117+
default_device = torch::Device(torch::kMPS);
117118
std::cout << "[INFO] Running on MPS" << std::endl;
118119
} else {
119120
std::cout << "[INFO] MPS not available, falling back to CPU" << std::endl;

0 commit comments

Comments
 (0)