sugarme / gotch

Go binding for Pytorch C++ API (libtorch)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how can i convert gocv.Mat image data to Tensor ?

zombie-k opened this issue · comments

i read image use gocv.IMRead, it's a gocv.Mat, after some steps to process the gocv.Mat data, how can i convert (gocv.Mat) to (ts.Tensor) ?

@zombie-k ,

I don't know what kind of data gocv.Mat is but you can create a ts.Tensor using API ts.OfSlice(data []T) where data is backing slice and reshape it to original shape. There also other API ts.NewTensorFromData() where you can specify shape and dtype.

Hope that helps.

close for now. If you still have issue, please provide further detail.