ranges for lint
This commit is contained in:
parent
47705b5168
commit
39ee6d2bd0
@ -245,7 +245,7 @@ func (m *VisionModel) Forward(ctx ml.Context, pixelValues ml.Tensor, grid *Grid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hiddenStates = m.PatchMerger.Forward(ctx, hiddenStates, m.VisionModelOptions)
|
hiddenStates = m.PatchMerger.Forward(ctx, hiddenStates, m.VisionModelOptions)
|
||||||
reverseWindowIndex := windowIndex.Argsort(ctx)
|
reverseWindowIndex := windowIndex.Argsort(ctx)
|
||||||
return hiddenStates.Rows(ctx, reverseWindowIndex)
|
return hiddenStates.Rows(ctx, reverseWindowIndex)
|
||||||
}
|
}
|
||||||
|
@ -131,22 +131,22 @@ func (p *ImageProcessor) createPatches(pixels []float32, height, width int, grid
|
|||||||
// in the format expected by the forward pass
|
// in the format expected by the forward pass
|
||||||
patchIndex := 0
|
patchIndex := 0
|
||||||
|
|
||||||
for t := 0; t < grid.Temporal; t++ {
|
for range grid.Temporal {
|
||||||
// For each patch in the grid
|
// For each patch in the grid
|
||||||
for h := 0; h < grid.Height; h += mergeSize {
|
for h := 0; h < grid.Height; h += mergeSize {
|
||||||
for w := 0; w < grid.Width; w += mergeSize {
|
for w := 0; w < grid.Width; w += mergeSize {
|
||||||
// Handle the 2x2 merged patches
|
// Handle the 2x2 merged patches
|
||||||
for mh := 0; mh < mergeSize; mh++ {
|
for mh := range mergeSize {
|
||||||
for mw := 0; mw < mergeSize; mw++ {
|
for mw := range mergeSize {
|
||||||
// For each pixel in the patch
|
// For each pixel in the patch
|
||||||
for py := 0; py < patchSize; py++ {
|
for py := range patchSize {
|
||||||
for px := 0; px < patchSize; px++ {
|
for px := range patchSize {
|
||||||
// Calculate source coordinates
|
// Calculate source coordinates
|
||||||
y := (h+mh)*patchSize + py
|
y := (h+mh)*patchSize + py
|
||||||
x := (w+mw)*patchSize + px
|
x := (w+mw)*patchSize + px
|
||||||
|
|
||||||
// For each channel
|
// For each channel
|
||||||
for c := 0; c < channels; c++ {
|
for c := range channels {
|
||||||
// Channel-first format (CHW)
|
// Channel-first format (CHW)
|
||||||
srcIdx := c*height*width + y*width + x
|
srcIdx := c*height*width + y*width + x
|
||||||
|
|
||||||
@ -167,9 +167,9 @@ func (p *ImageProcessor) createPatches(pixels []float32, height, width int, grid
|
|||||||
|
|
||||||
// Handle temporal dimension padding (if needed)
|
// Handle temporal dimension padding (if needed)
|
||||||
for tp := 1; tp < temporalPatchSize; tp++ {
|
for tp := 1; tp < temporalPatchSize; tp++ {
|
||||||
for py := 0; py < patchSize; py++ {
|
for py := range patchSize {
|
||||||
for px := 0; px < patchSize; px++ {
|
for px := range patchSize {
|
||||||
for c := 0; c < channels; c++ {
|
for c := range channels {
|
||||||
srcIdx := patchIndex*patchDim +
|
srcIdx := patchIndex*patchDim +
|
||||||
(c * temporalPatchSize * patchSize * patchSize) +
|
(c * temporalPatchSize * patchSize * patchSize) +
|
||||||
(0 * patchSize * patchSize) + // first temporal frame
|
(0 * patchSize * patchSize) + // first temporal frame
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
DefaultFactor = 28
|
DefaultFactor = 28
|
||||||
DefaultMinPixels = 56 * 56
|
DefaultMinPixels = 56 * 56
|
||||||
DefaultMaxPixels = 14 * 14 * 4 * 1280 // TODO: might need to change
|
DefaultMaxPixels = 14 * 14 * 4 * 1280
|
||||||
)
|
)
|
||||||
|
|
||||||
// smartResize calculates the size of the image to resize to based on the
|
// smartResize calculates the size of the image to resize to based on the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user