-
Notifications
You must be signed in to change notification settings - Fork 0
/
mega.patch
297 lines (291 loc) · 11.1 KB
/
mega.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
diff --git a/mediapipe/tasks/BUILD b/mediapipe/tasks/BUILD
index 582fc4c..ce5a3bd 100644
--- a/mediapipe/tasks/BUILD
+++ b/mediapipe/tasks/BUILD
@@ -17,7 +17,7 @@ package(default_visibility = ["//visibility:public"])
package_group(
name = "internal",
packages = [
- "//mediapipe/python/...",
+# "//mediapipe/python/...",
"//mediapipe/tasks/...",
],
)
diff --git a/mediapipe/tasks/web/package.json b/mediapipe/tasks/web/package.json
index 50b0766..7cea65c 100644
--- a/mediapipe/tasks/web/package.json
+++ b/mediapipe/tasks/web/package.json
@@ -1,13 +1,12 @@
{
- "name": "@mediapipe/tasks-__NAME__",
- "version": "__VERSION__",
+ "name": "@mediapipe/mega-tasks-__NAME__",
+ "version": "1.0",
"description": "__DESCRIPTION__",
- "main": "__NAME___bundle.cjs",
+ "main": "__NAME___bundle.mjs",
"browser": "__NAME___bundle.mjs",
"module": "__NAME___bundle.mjs",
"exports": {
"import": "./__NAME___bundle.mjs",
- "require": "./__NAME___bundle.cjs",
"default": "./__NAME___bundle.mjs",
"types": "./__TYPES__"
},
diff --git a/mediapipe/tasks/web/rollup.config.mjs b/mediapipe/tasks/web/rollup.config.mjs
index 3b51195..e5106bb 100644
--- a/mediapipe/tasks/web/rollup.config.mjs
+++ b/mediapipe/tasks/web/rollup.config.mjs
@@ -6,6 +6,6 @@ export default {
plugins: [
resolve(),
commonjs(),
- terser()
+// terser()
]
}
diff --git a/mediapipe/tasks/web/vision/BUILD b/mediapipe/tasks/web/vision/BUILD
index 384891f..2a089da 100644
--- a/mediapipe/tasks/web/vision/BUILD
+++ b/mediapipe/tasks/web/vision/BUILD
@@ -13,8 +13,8 @@ package(default_visibility = ["//mediapipe/tasks:internal"])
mediapipe_files(srcs = [
"wasm/vision_wasm_internal.js",
"wasm/vision_wasm_internal.wasm",
- "wasm/vision_wasm_nosimd_internal.js",
- "wasm/vision_wasm_nosimd_internal.wasm",
+# "wasm/vision_wasm_nosimd_internal.js",
+# "wasm/vision_wasm_nosimd_internal.wasm",
])
VISION_LIBS = [
@@ -23,17 +23,17 @@ VISION_LIBS = [
"//mediapipe/tasks/web/vision/core:image",
"//mediapipe/tasks/web/vision/core:mask",
"//mediapipe/tasks/web/vision/face_detector",
- "//mediapipe/tasks/web/vision/face_landmarker",
- "//mediapipe/tasks/web/vision/face_stylizer",
- "//mediapipe/tasks/web/vision/gesture_recognizer",
- "//mediapipe/tasks/web/vision/hand_landmarker",
- "//mediapipe/tasks/web/vision/holistic_landmarker",
- "//mediapipe/tasks/web/vision/image_classifier",
- "//mediapipe/tasks/web/vision/image_embedder",
+# "//mediapipe/tasks/web/vision/face_landmarker",
+# "//mediapipe/tasks/web/vision/face_stylizer",
+# "//mediapipe/tasks/web/vision/gesture_recognizer",
+# "//mediapipe/tasks/web/vision/hand_landmarker",
+# "//mediapipe/tasks/web/vision/holistic_landmarker",
+# "//mediapipe/tasks/web/vision/image_classifier",
+# "//mediapipe/tasks/web/vision/image_embedder",
"//mediapipe/tasks/web/vision/image_segmenter",
- "//mediapipe/tasks/web/vision/interactive_segmenter",
- "//mediapipe/tasks/web/vision/object_detector",
- "//mediapipe/tasks/web/vision/pose_landmarker",
+# "//mediapipe/tasks/web/vision/interactive_segmenter",
+# "//mediapipe/tasks/web/vision/object_detector",
+# "//mediapipe/tasks/web/vision/pose_landmarker",
]
mediapipe_ts_library(
@@ -65,32 +65,32 @@ rollup_bundle(
"@npm//google-protobuf",
],
)
-
-rollup_bundle(
- name = "vision_bundle_cjs",
- config_file = "//mediapipe/tasks/web:rollup.config.mjs",
- entry_point = "index.ts",
- format = "cjs",
- output_dir = False,
- sourcemap = "true",
- deps = [
- ":vision_lib",
- "@npm//@rollup/plugin-commonjs",
- "@npm//@rollup/plugin-node-resolve",
- "@npm//@rollup/plugin-terser",
- "@npm//google-protobuf",
- ],
-)
+#
+#rollup_bundle(
+# name = "vision_bundle_cjs",
+# config_file = "//mediapipe/tasks/web:rollup.config.mjs",
+# entry_point = "index.ts",
+# format = "cjs",
+# output_dir = False,
+# sourcemap = "true",
+# deps = [
+# ":vision_lib",
+# "@npm//@rollup/plugin-commonjs",
+# "@npm//@rollup/plugin-node-resolve",
+# "@npm//@rollup/plugin-terser",
+# "@npm//google-protobuf",
+# ],
+#)
genrule(
name = "vision_sources",
srcs = [
- ":vision_bundle_cjs",
+ # ":vision_bundle_cjs",
":vision_bundle_mjs",
],
outs = [
- "vision_bundle.cjs",
- "vision_bundle.cjs.map",
+# "vision_bundle.cjs",
+# "vision_bundle.cjs.map",
"vision_bundle.mjs",
"vision_bundle.mjs.map",
],
@@ -125,8 +125,8 @@ pkg_npm(
deps = [
"wasm/vision_wasm_internal.js",
"wasm/vision_wasm_internal.wasm",
- "wasm/vision_wasm_nosimd_internal.js",
- "wasm/vision_wasm_nosimd_internal.wasm",
+# "wasm/vision_wasm_nosimd_internal.js",
+# "wasm/vision_wasm_nosimd_internal.wasm",
":package_json",
":vision_sources",
],
diff --git a/mediapipe/tasks/web/vision/core/image_shader_context.ts b/mediapipe/tasks/web/vision/core/image_shader_context.ts
index 68fd4c0..c6bd9a3 100644
--- a/mediapipe/tasks/web/vision/core/image_shader_context.ts
+++ b/mediapipe/tasks/web/vision/core/image_shader_context.ts
@@ -29,6 +29,7 @@ const FRAGMENT_SHADER = `
uniform sampler2D inputTexture;
void main() {
gl_FragColor = texture2D(inputTexture, vTex);
+ gl_FragColor.a = gl_FragColor.r;
}
`;
diff --git a/mediapipe/tasks/web/vision/image_segmenter/image_segmenter.ts b/mediapipe/tasks/web/vision/image_segmenter/image_segmenter.ts
index 13a0dc6..b20cd85 100644
--- a/mediapipe/tasks/web/vision/image_segmenter/image_segmenter.ts
+++ b/mediapipe/tasks/web/vision/image_segmenter/image_segmenter.ts
@@ -23,6 +23,7 @@ import {SegmenterOptions as SegmenterOptionsProto} from '../../../../tasks/cc/vi
import {WasmFileset} from '../../../../tasks/web/core/wasm_fileset';
import {ImageProcessingOptions} from '../../../../tasks/web/vision/core/image_processing_options';
import {MPMask} from '../../../../tasks/web/vision/core/mask';
+import {MPImage} from '../../../../tasks/web/vision/core/image';
import {
VisionGraphRunner,
VisionTaskRunner,
@@ -67,7 +68,7 @@ export type ImageSegmenterCallback = (result: ImageSegmenterResult) => void;
/** Performs image segmentation on images. */
export class ImageSegmenter extends VisionTaskRunner {
private categoryMask?: MPMask;
- private confidenceMasks?: MPMask[];
+ private confidenceMasks?: MPImage[];
private qualityScores?: number[];
private labels: string[] = [];
private userCallback?: ImageSegmenterCallback;
@@ -471,9 +472,9 @@ export class ImageSegmenter extends VisionTaskRunner {
CONFIDENCE_MASKS_STREAM,
(masks, timestamp) => {
this.confidenceMasks = masks.map((wasmImage) =>
- this.convertToMPMask(
+ this.convertToMPImage(
wasmImage,
- /* interpolateValues= */ true,
+ // /* interpolateValues= */ true,
/* shouldCopyData= */ !this.userCallback,
),
);
diff --git a/mediapipe/tasks/web/vision/image_segmenter/image_segmenter_result.ts b/mediapipe/tasks/web/vision/image_segmenter/image_segmenter_result.ts
index dc29979..79c52b3 100644
--- a/mediapipe/tasks/web/vision/image_segmenter/image_segmenter_result.ts
+++ b/mediapipe/tasks/web/vision/image_segmenter/image_segmenter_result.ts
@@ -15,6 +15,7 @@
*/
import {MPMask} from '../../../../tasks/web/vision/core/mask';
+import {MPImage} from '../../../../tasks/web/vision/core/image';
/** The output result of ImageSegmenter. */
export class ImageSegmenterResult {
@@ -25,7 +26,7 @@ export class ImageSegmenterResult {
* confidence, usually in the [0, 1] range.
* @export
*/
- readonly confidenceMasks?: MPMask[],
+ readonly confidenceMasks?: MPImage[],
/**
* A category mask represented as a `Uint8ClampedArray` or
* `WebGLTexture`-backed `MPImage` where each pixel represents the class
diff --git a/mediapipe/tasks/web/vision/index.ts b/mediapipe/tasks/web/vision/index.ts
index a07b7e9..b6c80b3 100644
--- a/mediapipe/tasks/web/vision/index.ts
+++ b/mediapipe/tasks/web/vision/index.ts
@@ -18,6 +18,7 @@ import {FilesetResolver as FilesetResolverImpl} from '../../../tasks/web/core/fi
import {DrawingUtils as DrawingUtilsImpl} from '../../../tasks/web/vision/core/drawing_utils';
import {MPImage as MPImageImpl} from '../../../tasks/web/vision/core/image';
import {MPMask as MPMaskImpl} from '../../../tasks/web/vision/core/mask';
+/*
import {FaceDetector as FaceDetectorImpl} from '../../../tasks/web/vision/face_detector/face_detector';
import {FaceLandmarker as FaceLandmarkerImpl} from '../../../tasks/web/vision/face_landmarker/face_landmarker';
import {FaceStylizer as FaceStylizerImpl} from '../../../tasks/web/vision/face_stylizer/face_stylizer';
@@ -26,17 +27,20 @@ import {HandLandmarker as HandLandmarkerImpl} from '../../../tasks/web/vision/ha
import {HolisticLandmarker as HolisticLandmarkerImpl} from '../../../tasks/web/vision/holistic_landmarker/holistic_landmarker';
import {ImageClassifier as ImageClassifierImpl} from '../../../tasks/web/vision/image_classifier/image_classifier';
import {ImageEmbedder as ImageEmbedderImpl} from '../../../tasks/web/vision/image_embedder/image_embedder';
+*/
import {ImageSegmenter as ImageSegementerImpl} from '../../../tasks/web/vision/image_segmenter/image_segmenter';
+/*
import {InteractiveSegmenter as InteractiveSegmenterImpl} from '../../../tasks/web/vision/interactive_segmenter/interactive_segmenter';
import {ObjectDetector as ObjectDetectorImpl} from '../../../tasks/web/vision/object_detector/object_detector';
import {PoseLandmarker as PoseLandmarkerImpl} from '../../../tasks/web/vision/pose_landmarker/pose_landmarker';
-
+*/
// Declare the variables locally so that Rollup in OSS includes them explicitly
// as exports.
const DrawingUtils = DrawingUtilsImpl;
const FilesetResolver = FilesetResolverImpl;
const MPImage = MPImageImpl;
const MPMask = MPMaskImpl;
+/*
const FaceDetector = FaceDetectorImpl;
const FaceLandmarker = FaceLandmarkerImpl;
const FaceStylizer = FaceStylizerImpl;
@@ -45,16 +49,19 @@ const HandLandmarker = HandLandmarkerImpl;
const HolisticLandmarker = HolisticLandmarkerImpl;
const ImageClassifier = ImageClassifierImpl;
const ImageEmbedder = ImageEmbedderImpl;
+*/
const ImageSegmenter = ImageSegementerImpl;
+/*
const InteractiveSegmenter = InteractiveSegmenterImpl;
const ObjectDetector = ObjectDetectorImpl;
const PoseLandmarker = PoseLandmarkerImpl;
-
+*/
export {
DrawingUtils,
FilesetResolver,
MPImage,
MPMask,
+/*
FaceDetector,
FaceLandmarker,
FaceStylizer,
@@ -63,8 +70,11 @@ export {
HolisticLandmarker,
ImageClassifier,
ImageEmbedder,
+*/
ImageSegmenter,
+/*
InteractiveSegmenter,
ObjectDetector,
PoseLandmarker
+*/
};
diff --git a/tsconfig.json b/tsconfig.json
index 8074aed..94ff558 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,6 +1,6 @@
{
"compilerOptions": {
- "target": "es2017",
+ "target": "es2020",
"module": "commonjs",
"lib": ["ES2021", "dom"],
"declaration": true,