Skip to content

Commit 1ab0412

Browse files
committed
EdgeAvg implemented on GPU, now fully functional with ndata
1 parent eab59bf commit 1ab0412

22 files changed

+902
-434
lines changed

examples/color_gabor/color_gabor.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,11 @@ type Vis struct { //types:add
139139

140140
v1sIdxs [3]int
141141

142-
fadeOpIdx int
143-
144142
v1sMaxIdx, v1cPoolIdx, v1cMaxPolIdx, v1cPolPoolIdx, v1cLenSumIdx, v1cEndStopIdx int
145143
}
146144

147145
func (vi *Vis) Defaults() {
148-
vi.GPU = true
146+
vi.GPU = false // true
149147
vi.ColorGain = 8
150148
vi.SplitColor = true
151149
vi.ImageFile = core.Filename("car_004_00001.png")
@@ -179,7 +177,8 @@ func (vi *Vis) Config() {
179177
vi.ImageTsr = vi.V1.Images.SubSpace(img, 0).(*tensor.Float32)
180178
vi.ImageLMSTsr = vi.V1.Images.SubSpace(lms, 0).(*tensor.Float32)
181179

182-
vi.fadeOpIdx = vi.V1.NewFadeImage(img, 3, wrap, int(vi.V1sGeom.Border.X), .5, .5, .5, &vi.V1sGeom)
180+
avgIdx := vi.V1.NewEdgeAvg(img, 3, int(vi.V1sGeom.Border.X), &vi.V1sGeom)
181+
vi.V1.NewFadeImage(img, 3, wrap, int(vi.V1sGeom.Border.X), avgIdx, &vi.V1sGeom)
183182
vi.V1.NewLMSOpponents(wrap, lms, vi.ColorGain, &vi.V1sGeom)
184183

185184
nang := vi.V1sGabor.NAngles
@@ -272,13 +271,9 @@ func (vi *Vis) Filter() error { //types:add
272271
if err != nil {
273272
return errors.Log(err)
274273
}
275-
// todo:
276-
// r, g, b := v1vision.EdgeAvg(vi.ImageTsr, int(vi.V1sGeom.Border.X))
277-
// vi.V1.SetFadeRGB(vi.fadeOpIdx, r, g, b)
278-
279274
tmr := timer.Time{}
280275
tmr.Start()
281-
for range 1000 {
276+
for range 1 {
282277
vi.V1.Run()
283278
// vi.V1.Run(v1vision.Values4DVar) // this is sig slower due to sync issues.
284279
// for timing test, run without sync and assume it gets sig better.

v1std/v1c_color.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ type V1cColor struct {
5858
// (0, 45, 90, 135) and the 5 are: 1 length-sum, 2 directions of end-stop,
5959
// and 2 polarities of V1simple.
6060
Output *tensor.Float32 `display:"no-inline"`
61-
62-
fadeOpIdx int
6361
}
6462

6563
func (vi *V1cColor) Defaults() {
@@ -95,7 +93,8 @@ func (vi *V1cColor) Config(ndata int, imageSize image.Point) {
9593
wrap := vi.V1.NewImage(vi.V1sGeom.In.V())
9694
lms := vi.V1.NewImage(vi.V1sGeom.In.V())
9795

98-
vi.fadeOpIdx = vi.V1.NewFadeImage(img, 3, wrap, int(vi.V1sGeom.Border.X), .5, .5, .5, &vi.V1sGeom)
96+
avgIdx := vi.V1.NewEdgeAvg(img, 3, int(vi.V1sGeom.Border.X), &vi.V1sGeom)
97+
vi.V1.NewFadeImage(img, 3, wrap, int(vi.V1sGeom.Border.X), avgIdx, &vi.V1sGeom)
9998
vi.V1.NewLMSOpponents(wrap, lms, vi.ColorGain, &vi.V1sGeom)
10099

101100
nang := vi.V1sGabor.NAngles
@@ -162,10 +161,6 @@ func (vi *V1cColor) RunImages(im *Image, imgs ...image.Image) {
162161
vi.V1.SetAsCurrent()
163162
v1vision.UseGPU = vi.GPU
164163
im.SetImagesRGB(&vi.V1, int(vi.V1sGeom.Border.X), imgs...)
165-
// argh: this is not going to work here:
166-
// need to do this on-chip.
167-
// r, g, b := v1vision.EdgeAvg(im.Tsr, int(vi.V1sGeom.Border.X))
168-
// vi.V1.SetFadeRGB(vi.fadeOpIdx, r, g, b)
169164
vi.V1.Run(v1vision.Values4DVar)
170165
vi.Output = vi.V1.Values4D.SubSpace(0).(*tensor.Float32)
171166
}

v1std/v1c_multi.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,6 @@ type V1cMulti struct {
245245

246246
// Image manages images.
247247
Image Image
248-
249-
fadeOpIdx int
250248
}
251249

252250
func (vi *V1cMulti) Defaults() {
@@ -338,7 +336,8 @@ func (vi *V1cMulti) Config(ndata int) {
338336
lmsBY := vi.V1.NewImage(inSz)
339337
_, _ = lmsRG, lmsBY
340338

341-
vi.fadeOpIdx = vi.V1.NewFadeImage(img, 3, wrap, int(v1sGeom.Border.X), .5, .5, .5, v1sGeom)
339+
avgIdx := vi.V1.NewEdgeAvg(img, 3, int(v1sGeom.Border.X), v1sGeom)
340+
vi.V1.NewFadeImage(img, 3, wrap, int(v1sGeom.Border.X), avgIdx, v1sGeom)
342341
vi.V1.NewLMSOpponents(wrap, lmsOp, vi.ColorGain, v1sGeom)
343342
if len(vi.DoGParams) > 0 {
344343
dogGeom := &vi.DoGParams[0].Geom
@@ -373,9 +372,6 @@ func (vi *V1cMulti) RunImages(imgs ...image.Image) {
373372
v1vision.UseGPU = vi.GPU
374373
v1sGeom := &vi.V1cParams[0].V1sGeom
375374
vi.Image.SetImagesRGB(&vi.V1, int(v1sGeom.Border.X), imgs...)
376-
// todo:
377-
// r, g, b := v1vision.EdgeAvg(vi.Image.Tsr, int(v1sGeom.Border.X))
378-
// vi.V1.SetFadeRGB(vi.fadeOpIdx, r, g, b)
379375
vi.V1.Run(v1vision.Values4DVar)
380376
for _, vp := range vi.V1cParams {
381377
vp.SetOutput(vi)

v1vision/enumgen.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

v1vision/gosl.go

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)