Skip to content

Commit b135f5b

Browse files
committed
fix: toSize4 + sequential
1 parent 359210d commit b135f5b

File tree

12 files changed

+15
-24
lines changed

12 files changed

+15
-24
lines changed

lib/augmenters/additive-gaussian-noise.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ class AdditiveGaussianNoiseAugmenter extends AbstractAugmenter {
3333
context: 'colorPixel'
3434
});
3535

36-
const perChannelRef = h.reference({
37-
source: this.perChannel,
38-
context: 'image'
39-
});
4036
return h.object({
4137
noise: h.matrix({
4238
shape: h.array([

lib/augmenters/additive-poisson-noise.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ class AdditivePoissonNoiseAugmenter extends AbstractAugmenter {
3030
context: 'colorPixel'
3131
});
3232

33-
const perChannelRef = h.reference({
34-
source: this.perChannel,
35-
context: 'image'
36-
});
3733
return h.object({
3834
noise: h.matrix({
3935
shape: h.array([

lib/augmenters/affine-transform.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ class AffineTransformAugmenter extends AbstractAugmenter {
5757

5858
const a2Base = (translatePercent[0] * width);
5959

60-
const a2 = a2Base - a0 * centerX - a1 * centerY + centerX;
60+
const a2 = a2Base - (a0 * centerX) - (a1 * centerY) + centerX;
6161

6262
const b0 = scale[0] * Math.sin(rot);
6363
const b1 = scale[1] * Math.cos(rot + shr);
6464

6565
const b2Base = (translatePercent[1] * height);
66-
const b2 = b2Base - b0 * centerY - b1 * centerX + centerY;
66+
const b2 = b2Base - (b0 * centerY) - (b1 * centerX) + centerY;
6767
return this.backend.floatMatrix([[a0, a1, a2], [b0, b1, b2]]);
6868
}
6969

lib/augmenters/crop.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class CropAugmenter extends AbstractAugmenter {
2929
getRect({width, height, percent}) {
3030
return {
3131
x: Math.round(percent[0] * width),
32-
y: Math.round(percent[2] * height),
33-
w: width - Math.round(percent[1] * width) - Math.round(percent[0] * width),
34-
h: height - Math.round(percent[2] * height) - Math.round(percent[3] * height)
32+
y: Math.round(percent[1] * height),
33+
w: width - Math.round(percent[2] * width) - Math.round(percent[0] * width),
34+
h: height - Math.round(percent[3] * height) - Math.round(percent[1] * height)
3535
};
3636
}
3737

lib/augmenters/sequential.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
const hasard = require('hasard');
2+
const AbstractAugmenter = require('./abstract');
23

3-
class Sequential {
4+
class Sequential extends AbstractAugmenter {
45
constructor(opts) {
6+
super(opts);
57
if (Array.isArray(opts) || hasard.isHasard(opts)) {
68
this.steps = opts;
79
} else {
810
this.steps = opts.steps;
911
}
1012
}
1113

12-
run({img, points = [], boxes = []}) {
14+
runOnce({img, points = [], boxes = []}) {
1315
let steps;
1416
if (hasard.isHasard(this.steps)) {
1517
steps = this.steps.runOnce();
@@ -24,17 +26,13 @@ class Sequential {
2426
const width = img.cols;
2527
const height = img.rows;
2628

27-
let promise = Promise.resolve({img, points, width, height, boxes});
29+
let res = {img, points, width, height, boxes};
2830

2931
steps.forEach(step => {
30-
const newPromise = promise.then(o => {
31-
return step.runOnce(o);
32-
});
33-
34-
promise = newPromise;
32+
res = step.runOnce(res);
3533
});
3634

37-
return promise;
35+
return res;
3836
}
3937
}
4038
module.exports = Sequential;

lib/backend/opencv-backend.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class OpenCVBackend {
134134
img2 = img;
135135
}
136136

137-
const res = img2.copyMakeBorder(borders[2], borders[3], borders[0], borders[1], borderCopyMode, borderCopyValue);
137+
const res = img2.copyMakeBorder(borders[1], borders[3], borders[0], borders[2], borderCopyMode, borderCopyValue);
138138
return res;
139139
}
140140

test/augmenters/sequential.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const path = require('path');
22
const test = require('ava');
33
const Sequential = require('../../lib/augmenters/sequential');
44
const Blur = require('../../lib/augmenters/blur');
5-
const Resize = require('../../lib/augmenters/blur');
5+
const Resize = require('../../lib/augmenters/resize');
66

77
const macroAugmenter = require('../macros/augmenter');
88

test/data/lenna-crop-10x30x0x5.png

9.74 KB
Loading

test/data/lenna-pad-10x30.png

-756 Bytes
Loading

test/data/lenna-pad-10x30x0x5.png

-4.75 KB
Loading

0 commit comments

Comments
 (0)