seg-cam 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seg-cam",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -28,13 +28,13 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@vercel/analytics": "1.3.1",
31
- "autoprefixer": "^10.4.20",
31
+ "autoprefixer": "^10.4.24",
32
32
  "class-variance-authority": "^0.7.1",
33
33
  "clsx": "^2.1.1",
34
34
  "lucide-react": "^0.454.0",
35
35
  "next": "16.0.10",
36
36
  "next-themes": "^0.4.6",
37
- "tailwind-merge": "^3.3.1"
37
+ "tailwind-merge": "^3.4.0"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@tensorflow-models/body-segmentation": "1.0.2",
@@ -43,14 +43,20 @@
43
43
  "react-dom": ">=18"
44
44
  },
45
45
  "devDependencies": {
46
- "@tailwindcss/postcss": "^4.1.9",
47
- "@types/node": "^22",
48
- "@types/react": "^19",
49
- "@types/react-dom": "^19",
50
- "esbuild": "0.27",
51
- "postcss": "^8.5",
52
- "tailwindcss": "^4.1.9",
53
- "tsup": "^8.3.5",
54
- "typescript": "^5"
46
+ "@tailwindcss/postcss": "^4.1.18",
47
+ "@types/node": "^22.19.7",
48
+ "@types/react": "^19.2.10",
49
+ "@types/react-dom": "^19.2.3",
50
+ "esbuild": "~0.27.2",
51
+ "postcss": "^8.5.6",
52
+ "tailwindcss": "^4.1.18",
53
+ "tsup": "^8.5.1",
54
+ "typescript": "^5.9.3"
55
+ },
56
+ "pnpm": {
57
+ "overrides": {
58
+ "rimraf": "^6.0.0",
59
+ "glob": "^11.0.0"
60
+ }
55
61
  }
56
- }
62
+ }
@@ -82270,33 +82270,48 @@ var handleDetect = async (message) => {
82270
82270
  sendDebug("[Worker] No people detected, skipping mask drawing");
82271
82271
  } else {
82272
82272
  sendDebug(`[Worker] Processing ${people.length} people`);
82273
- let allTorsosMask = tf.fill([height, width], false, "bool");
82274
- for (const person of people) {
82275
- const { shirtBitmap, isUpperTorso } = await processSinglePerson(person, originalImageTensor);
82276
- if (!shirtBitmap || !isUpperTorso) continue;
82277
- segmentedImages.push(shirtBitmap);
82278
- const oldMask = allTorsosMask;
82279
- let newTotalMask = allTorsosMask.logicalOr(isUpperTorso);
82280
- isUpperTorso.dispose();
82281
- allTorsosMask = newTotalMask;
82282
- if (oldMask !== newTotalMask) oldMask.dispose();
82283
- }
82284
- const overlayTensor = tf.tidy(() => {
82285
- const whiteRGB = tf.fill([height, width, 3], 255, "int32");
82286
- const backgroundShade = currentConfig?.backgroundShade ?? 0;
82287
- const shirtShade = currentConfig?.shirtShade ?? 170;
82288
- const alphaChannel = tf.where(allTorsosMask, shirtShade, backgroundShade).expandDims(2);
82289
- return tf.concat([whiteRGB, alphaChannel], 2);
82290
- });
82291
- ctx.clearRect(0, 0, width, height);
82292
- const overlayData = await overlayTensor.data();
82293
- const overlayPixels = new Uint8ClampedArray(overlayData);
82294
- const outputImageData = new ImageData(overlayPixels, width, height);
82295
- ctx.putImageData(outputImageData, 0, 0);
82296
- outputBitmap = await createImageBitmap(canvas);
82297
- allTorsosMask.dispose();
82298
- overlayTensor.dispose();
82299
- originalImageTensor.dispose();
82273
+ const imagesToReturn = currentConfig?.imagesToReturn ?? "mask";
82274
+ if (imagesToReturn === "none") {
82275
+ sendDebug("[Worker] imagesToReturn is 'none', skipping visualization");
82276
+ for (const person of people) {
82277
+ const { shirtBitmap, isUpperTorso } = await processSinglePerson(person, originalImageTensor);
82278
+ if (shirtBitmap && isUpperTorso) {
82279
+ segmentedImages.push(shirtBitmap);
82280
+ isUpperTorso.dispose();
82281
+ } else if (isUpperTorso) {
82282
+ isUpperTorso.dispose();
82283
+ }
82284
+ }
82285
+ originalImageTensor.dispose();
82286
+ } else {
82287
+ let allTorsosMask = tf.fill([height, width], false, "bool");
82288
+ for (const person of people) {
82289
+ const { shirtBitmap, isUpperTorso } = await processSinglePerson(person, originalImageTensor);
82290
+ if (!shirtBitmap || !isUpperTorso) continue;
82291
+ segmentedImages.push(shirtBitmap);
82292
+ const oldMask = allTorsosMask;
82293
+ let newTotalMask = allTorsosMask.logicalOr(isUpperTorso);
82294
+ isUpperTorso.dispose();
82295
+ allTorsosMask = newTotalMask;
82296
+ if (oldMask !== newTotalMask) oldMask.dispose();
82297
+ }
82298
+ const overlayTensor = tf.tidy(() => {
82299
+ const whiteRGB = tf.fill([height, width, 3], 255, "int32");
82300
+ const backgroundShade = currentConfig?.backgroundShade ?? 0;
82301
+ const shirtShade = currentConfig?.shirtShade ?? 170;
82302
+ const alphaChannel = tf.where(allTorsosMask, shirtShade, backgroundShade).expandDims(2);
82303
+ return tf.concat([whiteRGB, alphaChannel], 2);
82304
+ });
82305
+ ctx.clearRect(0, 0, width, height);
82306
+ const overlayData = await overlayTensor.data();
82307
+ const overlayPixels = new Uint8ClampedArray(overlayData);
82308
+ const outputImageData = new ImageData(overlayPixels, width, height);
82309
+ ctx.putImageData(outputImageData, 0, 0);
82310
+ outputBitmap = await createImageBitmap(canvas);
82311
+ allTorsosMask.dispose();
82312
+ overlayTensor.dispose();
82313
+ originalImageTensor.dispose();
82314
+ }
82300
82315
  }
82301
82316
  const transferList = [];
82302
82317
  if (outputBitmap) transferList.push(outputBitmap);