Skip to content

Commit 11fda0f

Browse files
committed
fix(humanseg): fix nchw shape humaneg
1 parent e22f789 commit 11fda0f

File tree

1 file changed

+4
-43
lines changed
  • packages/paddlejs-models/humanseg/src/customOp

1 file changed

+4
-43
lines changed

packages/paddlejs-models/humanseg/src/customOp/segImg.ts

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
function mainFunc({
66
out
77
}) {
8-
const THRESHHOLD = 0.4;
8+
const THRESHHOLD = 0.2;
99
return `
1010
1111
#define SIGMA SIGMA 3.0
@@ -29,8 +29,7 @@ function mainFunc({
2929
kernel[1] = 0.13298;
3030
kernel[2] = 0.12579369017522166;
3131
32-
33-
float origin_alpha = TEXTURE2D(texture_origin, vec2(outCoord.x, outCoord.y / 2.0 + 0.5)).r;
32+
float origin_alpha = 1.0 - TEXTURE2D(texture_origin, vec2(outCoord.x, outCoord.y) / 2.0).r;
3433
vec4 counter = TEXTURE2D(texture_counter, outCoord.xy);
3534
vec4 res = vec4(0.0);
3635
@@ -58,46 +57,8 @@ function mainFunc({
5857
}
5958
}
6059
else if (type == 1) {
61-
vec4 pixel = vec4(1.0, 1.0, 1.0, 0.0);
62-
if (origin_alpha > ${THRESHHOLD}) {
63-
pixel.a = origin_alpha;
64-
}
65-
else {
66-
pixel = vec4(0.0, 0.0, 0.0, 0.0);
67-
}
68-
vec4 bc = pixel;
69-
vec4 gc = bc;
70-
71-
float alpha = 0.0;
72-
float temp = 0.0;
73-
float gZ = 0.0;
74-
float gfactor;
75-
const int kSize = (MSIZE-1)/2; // 1
76-
77-
//read out the texels
78-
for (int i=-kSize; i <= kSize; ++i) {
79-
for (int j=-kSize; j <= kSize; ++j) {
80-
// color at pixel in the neighborhood
81-
vec2 coord = outCoord.xy + vec2(float(i), float(j))*sourceTexelSize.xy;
82-
float r = TEXTURE2D(texture_origin, vec2(outCoord.x, outCoord.y / 2.0 + 0.5)).r;
83-
temp = r > ${THRESHHOLD} ? r : 0.0;
84-
85-
// compute the gaussian smoothed
86-
gfactor = kernel[kSize+j]*kernel[kSize+i];
87-
gZ += gfactor;
88-
89-
alpha += gfactor*temp;
90-
}
91-
}
92-
93-
gc = vec4(gc.rgb, alpha/gZ);
94-
95-
if (alpha/gZ > 0.1) {
96-
gc = counter;
97-
gc.a = alpha/gZ;
98-
}
99-
res = gc;
100-
// res = vec4(gc.rgb * gc.a + counter.rgb * (1.0 - gc.a), 1.0);
60+
res = counter;
61+
res.a = origin_alpha;
10162
}
10263
else if (type == 2) {
10364
if (origin_alpha > ${THRESHHOLD}) {

0 commit comments

Comments
 (0)