PB Unity
commited on
Upload RunBlazeFace.cs
Browse files- RunBlazeFace.cs +12 -14
RunBlazeFace.cs
CHANGED
|
@@ -55,8 +55,8 @@ public class RunBlazeFace : MonoBehaviour
|
|
| 55 |
|
| 56 |
IWorker worker;
|
| 57 |
|
| 58 |
-
//Holds image size
|
| 59 |
-
int size;
|
| 60 |
|
| 61 |
Ops ops;
|
| 62 |
ITensorAllocator allocator;
|
|
@@ -181,14 +181,14 @@ public class RunBlazeFace : MonoBehaviour
|
|
| 181 |
int n = 0;
|
| 182 |
for (int j = 0; j < 2 * 16 * 16; j++)
|
| 183 |
{
|
| 184 |
-
offsets[n++] = (j / 2) % 16 - 7.5f;
|
| 185 |
-
offsets[n++] = (j / 2 / 16) - 7.5f;
|
| 186 |
n += 2;
|
| 187 |
}
|
| 188 |
for (int j = 0; j < 6 * 8 * 8; j++)
|
| 189 |
{
|
| 190 |
-
offsets[n++] =
|
| 191 |
-
offsets[n++] =
|
| 192 |
n += 2;
|
| 193 |
}
|
| 194 |
return offsets;
|
|
@@ -212,12 +212,10 @@ public class RunBlazeFace : MonoBehaviour
|
|
| 212 |
|
| 213 |
model.AddLayer(new Lays.Transpose("scores", "classificators", new int[] { 0, 2, 1 }));
|
| 214 |
|
| 215 |
-
model.AddConstant(new Lays.Constant("eighth", new float[] { 1 / 8f }));
|
| 216 |
model.AddConstant(new Lays.Constant("offsets",
|
| 217 |
new TensorFloat(new TensorShape(1, 896, 4), offsets)
|
| 218 |
));
|
| 219 |
-
model.AddLayer(new Lays.
|
| 220 |
-
model.AddLayer(new Lays.Add("boxCoords", "boxes1scaled", "offsets"));
|
| 221 |
model.AddOutput("boxCoords");
|
| 222 |
|
| 223 |
model.AddConstant(new Lays.Constant("maxOutputBoxes", new int[] { maxOutputBoxes }));
|
|
@@ -256,10 +254,10 @@ public class RunBlazeFace : MonoBehaviour
|
|
| 256 |
{
|
| 257 |
var marker = new BoundingBox
|
| 258 |
{
|
| 259 |
-
centerX = box.centerX + (regressors[0, n, 4 + j * 2] - regressors[0, n, 0]) * scale.x
|
| 260 |
-
centerY = box.centerY + (regressors[0, n, 4 + j * 2 + 1] - regressors[0, n, 1]) * scale.y
|
| 261 |
-
width =
|
| 262 |
-
height =
|
| 263 |
};
|
| 264 |
DrawBox(marker, j < markerTextures.Length ? markerTextures[j] : faceTexture);
|
| 265 |
}
|
|
@@ -294,7 +292,7 @@ public class RunBlazeFace : MonoBehaviour
|
|
| 294 |
|
| 295 |
ClearAnnotations();
|
| 296 |
|
| 297 |
-
Vector2 markerScale = previewUI.rectTransform.rect.size/
|
| 298 |
|
| 299 |
DrawFaces(output, markersOutput, output.shape[0], markerScale);
|
| 300 |
|
|
|
|
| 55 |
|
| 56 |
IWorker worker;
|
| 57 |
|
| 58 |
+
//Holds input image size
|
| 59 |
+
int size = 128;
|
| 60 |
|
| 61 |
Ops ops;
|
| 62 |
ITensorAllocator allocator;
|
|
|
|
| 181 |
int n = 0;
|
| 182 |
for (int j = 0; j < 2 * 16 * 16; j++)
|
| 183 |
{
|
| 184 |
+
offsets[n++] = 8 * ((j / 2) % 16 - 7.5f);
|
| 185 |
+
offsets[n++] = 8 * ((j / 2 / 16) - 7.5f);
|
| 186 |
n += 2;
|
| 187 |
}
|
| 188 |
for (int j = 0; j < 6 * 8 * 8; j++)
|
| 189 |
{
|
| 190 |
+
offsets[n++] = 16 * ((j / 6) % 8 - 7f);
|
| 191 |
+
offsets[n++] = 16 * ((j / 6 / 8) - 7f);
|
| 192 |
n += 2;
|
| 193 |
}
|
| 194 |
return offsets;
|
|
|
|
| 212 |
|
| 213 |
model.AddLayer(new Lays.Transpose("scores", "classificators", new int[] { 0, 2, 1 }));
|
| 214 |
|
|
|
|
| 215 |
model.AddConstant(new Lays.Constant("offsets",
|
| 216 |
new TensorFloat(new TensorShape(1, 896, 4), offsets)
|
| 217 |
));
|
| 218 |
+
model.AddLayer(new Lays.Add("boxCoords", "boxes1", "offsets"));
|
|
|
|
| 219 |
model.AddOutput("boxCoords");
|
| 220 |
|
| 221 |
model.AddConstant(new Lays.Constant("maxOutputBoxes", new int[] { maxOutputBoxes }));
|
|
|
|
| 254 |
{
|
| 255 |
var marker = new BoundingBox
|
| 256 |
{
|
| 257 |
+
centerX = box.centerX + (regressors[0, n, 4 + j * 2] - regressors[0, n, 0]) * scale.x,
|
| 258 |
+
centerY = box.centerY + (regressors[0, n, 4 + j * 2 + 1] - regressors[0, n, 1]) * scale.y,
|
| 259 |
+
width = 8.0f * scale.x,
|
| 260 |
+
height = 8.0f * scale.y,
|
| 261 |
};
|
| 262 |
DrawBox(marker, j < markerTextures.Length ? markerTextures[j] : faceTexture);
|
| 263 |
}
|
|
|
|
| 292 |
|
| 293 |
ClearAnnotations();
|
| 294 |
|
| 295 |
+
Vector2 markerScale = previewUI.rectTransform.rect.size / size;
|
| 296 |
|
| 297 |
DrawFaces(output, markersOutput, output.shape[0], markerScale);
|
| 298 |
|