Documentation ¶
Index ¶
- Constants
- Variables
- func FlattenDim(shape []int64) int
- func GetAndResetLastErr() *C.char
- func Iou(b1, b2 Bbox) (retVal float64)
- func TorchErr() error
- type Bbox
- type ByConfBbox
- type Cmodule
- type Ctensor
- type DeviceType
- type Prediction
- type RGB
- type Tensor
- func (p *Tensor) At(x, y int) color.Color
- func (p *Tensor) Bounds() image.Rectangle
- func (p *Tensor) ColorModel() color.Model
- func (img *Tensor) DrawRect(rect image.Rectangle, col color.Color)
- func (ts *Tensor) Drop() error
- func (img *Tensor) HLine(x1, y, x2 int, col color.Color)
- func (ts *Tensor) Numel() uint
- func (p *Tensor) PixOffset(x, y int) int
- func (p *Tensor) RGBAAt(x, y int) color.RGBA
- func (img *Tensor) Resize(targetSize int) (*Tensor, float64, error)
- func (p *Tensor) Set(x, y int, c color.Color)
- func (ts *Tensor) Size() ([]int64, error)
- func (p *Tensor) ToSquareShape() (*Tensor, int, int, error)
- func (img *Tensor) VLine(x, y1, y2 int, col color.Color)
- type YoloV5
Constants ¶
const ( ClassesOffset = 5 NPreds = 25200 PredSize = 85 NClasses = PredSize - ClassesOffset )
const (
COCO_PERSON = 0
)
Variables ¶
var ColorModel = color.ModelFunc(rgbModel)
ColorModel is RGB color model instance
Functions ¶
func FlattenDim ¶
FlattenDim counts number of elements with given shape
func GetAndResetLastErr ¶
func TorchErr ¶
func TorchErr() error
TorchErr checks and retrieves last error message from C `thread_local` if existing and frees up C memory the C pointer points to.
NOTE: Go language atm does not have generic function something similar to `macro` in Rust language, does it? So we have to wrap this function to any Libtorch C function call to check error instead of doing the other way around. See Go2 proposal: https://github.com/golang/go/issues/32620
Types ¶
type ByConfBbox ¶
type ByConfBbox []Bbox
func (ByConfBbox) Len ¶
func (bb ByConfBbox) Len() int
Implement sort.Interface for []Bbox on Bbox.confidence: =====================================================
func (ByConfBbox) Less ¶
func (bb ByConfBbox) Less(i, j int) bool
func (ByConfBbox) Swap ¶
func (bb ByConfBbox) Swap(i, j int)
type DeviceType ¶
type DeviceType = int32
const ( DeviceCPU DeviceType = -1 DeviceGPU DeviceType = 0 )
func DeviceCudaIfAvailable ¶
func DeviceCudaIfAvailable() DeviceType
type Prediction ¶
type Tensor ¶
type Tensor struct { // Pix holds the image's stream, in R, G, B order. Pix []uint8 // Stride is the Pix stride (in bytes) between vertically adjacent pixels. Stride int // Rect is the image's bounds. Rect image.Rectangle // contains filtered or unexported fields }
Tensor represent image data which has RGB colors. Tensor is compatible with image.RGBA, but does not have alpha channel to reduce using memory.
func NewTensorFromImage ¶
func (*Tensor) ColorModel ¶
ColorModel returns RGB color model.
func (*Tensor) PixOffset ¶
PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).