bgcut 0.1.0-beta.0 → 0.1.0-beta.1

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/README.md CHANGED
@@ -69,6 +69,8 @@ bgcut photo.jpg -o portrait.png
69
69
 
70
70
  From a source checkout, `bun run cli -- ...` runs the same entrypoint without installing the package binary.
71
71
 
72
+ Input decoding is content-based rather than extension-based. JPEG, PNG, WebP, and AVIF are supported through Sharp, so an AVIF payload still works even if its filename incorrectly ends in `.jpg`.
73
+
72
74
  The format itself is the option; there is deliberately no `--format png` syntax. PNG is the default. WebP is encoded losslessly. JPG/JPEG is supported, but because JPEG has no alpha channel it is flattened onto white.
73
75
 
74
76
  The CLI uses the same validated ONNX model and shared normalization/matte functions. It tries native ONNX Runtime WebGPU in automatic mode and falls back to native CPU execution if WebGPU session creation is unavailable. Use `-gpu`/`--gpu` or `-cpu`/`--cpu` to require one engine while validating the native path. The selected engine is printed after each run.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bgcut",
3
- "version": "0.1.0-beta.0",
3
+ "version": "0.1.0-beta.1",
4
4
  "description": "Local background removal CLI with native WebGPU and CPU fallback.",
5
5
  "type": "module",
6
6
  "packageManager": "bun@1.4.2",
@@ -22,11 +22,11 @@
22
22
  ],
23
23
  "repository": {
24
24
  "type": "git",
25
- "url": "git+https://github.com/jhomra21/bgremove.git"
25
+ "url": "git+https://github.com/jhomra21/bgcut.git"
26
26
  },
27
- "homepage": "https://github.com/jhomra21/bgremove#readme",
27
+ "homepage": "https://github.com/jhomra21/bgcut#readme",
28
28
  "bugs": {
29
- "url": "https://github.com/jhomra21/bgremove/issues"
29
+ "url": "https://github.com/jhomra21/bgcut/issues"
30
30
  },
31
31
  "keywords": [
32
32
  "background-removal",
@@ -64,9 +64,7 @@ type NativeSession = {
64
64
  readonly fallbackReason: string | undefined;
65
65
  };
66
66
 
67
- const supportedSharpFormats = new Set(["jpeg", "png", "webp"]);
68
-
69
- const prepareImage = (inputPath: string): Effect.Effect<PreparedImage, CliImageError> =>
67
+ export const prepareImage = (inputPath: string): Effect.Effect<PreparedImage, CliImageError> =>
70
68
  Effect.tryPromise({
71
69
  try: async () => {
72
70
  const input = Bun.file(inputPath);
@@ -75,12 +73,6 @@ const prepareImage = (inputPath: string): Effect.Effect<PreparedImage, CliImageE
75
73
  throw new Error(`Input file does not exist: ${inputPath}`);
76
74
  }
77
75
 
78
- const metadata = await sharp(inputPath).metadata();
79
-
80
- if (metadata.format === undefined || !supportedSharpFormats.has(metadata.format)) {
81
- throw new Error(`Unsupported image type: ${metadata.format ?? "unknown"}`);
82
- }
83
-
84
76
  const source = await sharp(inputPath)
85
77
  .rotate()
86
78
  .ensureAlpha()
@@ -344,4 +336,4 @@ export const removeBackgroundCli = (
344
336
  encodeMs,
345
337
  },
346
338
  };
347
- });
339
+ });
@@ -5,7 +5,7 @@ import { normalizeRgbaToNchw } from "./preprocess";
5
5
 
6
6
  export const MODEL_INPUT_SIZE = 512;
7
7
 
8
- const supportedImageTypes = new Set(["image/jpeg", "image/png", "image/webp"]);
8
+ const supportedImageTypes = new Set(["image/jpeg", "image/png", "image/webp", "image/avif"]);
9
9
 
10
10
  export const isSupportedImageType = (mimeType: string): boolean => supportedImageTypes.has(mimeType);
11
11
 
@@ -3,7 +3,7 @@ export const MODEL_FILENAME = "birefnet-lite-512-ort-basic-webgpu-v2.onnx";
3
3
  export const MODEL_PUBLIC_PATH = `/models/${MODEL_FILENAME}`;
4
4
 
5
5
  export const MODEL_RELEASE_URL =
6
- `https://github.com/jhomra21/bgremove/releases/download/model-birefnet-lite-512-ort-basic-webgpu-v2/${MODEL_FILENAME}`;
6
+ `https://github.com/jhomra21/bgcut/releases/download/model-birefnet-lite-512-ort-basic-webgpu-v2/${MODEL_FILENAME}`;
7
7
 
8
8
  export const MODEL_REVISION = "4a3c40c36c94093cc1e724d9ea428b8fa4b57dc7";
9
9