@imgly/background-removal-node
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -7,2 +7,8 @@ # Changelog | ||
## [Unreleased] | ||
### Changed | ||
- Typescript bindings are generated with tsc | ||
## [1.4.0] | ||
@@ -9,0 +15,0 @@ |
@@ -1,162 +0,31 @@ | ||
declare module '@imgly/background-removal-node/src/codecs' { | ||
export { imageEncode, imageDecode, MimeType }; | ||
import { NdArray } from 'ndarray'; | ||
function imageDecode(blob: Blob): Promise<NdArray<Uint8Array>>; | ||
function imageEncode(imageTensor: NdArray<Uint8Array>, quality?: number, type?: string): Promise<Blob>; | ||
class MimeType { | ||
type: string; | ||
params: Record<string, string>; | ||
private constructor(); | ||
toString(): string; | ||
static create(type: any, params: Record<string, string>): MimeType; | ||
isIdentical(other: MimeType): Boolean; | ||
isEqual(other: MimeType): Boolean; | ||
static fromString(mimeType: string): MimeType; | ||
} | ||
} | ||
declare module '@imgly/background-removal-node/src/index' { | ||
export default removeBackground; | ||
export { removeBackground, removeForeground, segmentForeground, applySegmentationMask }; | ||
export type { Config, ImageSource }; | ||
import { Config } from '@imgly/background-removal-node/src/schema'; | ||
import { ImageSource } from '@imgly/background-removal-node/src/utils'; | ||
/** | ||
* Removes the background from an image. | ||
* | ||
* @param image - The image to remove the background from. | ||
* @param configuration - Optional configuration for the background removal process. | ||
* @returns A Promise that resolves to the resulting image with the background removed. | ||
*/ | ||
function removeBackground(image: ImageSource, configuration?: Config): Promise<Blob>; | ||
/** | ||
* Removes the foreground from an image. | ||
* | ||
* @param image - The image to remove the foreground from. | ||
* @param configuration - Optional configuration for the foreground removal process. | ||
* @returns A Promise that resolves to the resulting image with the foreground removed. | ||
*/ | ||
function removeForeground(image: ImageSource, configuration?: Config): Promise<Blob>; | ||
/** | ||
* Segments the foreground of an image using a given configuration. | ||
* | ||
* @param image - The image source to segment. | ||
* @param configuration - The optional configuration for the segmentation. | ||
* @returns A Promise that resolves to the segmented foreground as a Blob. | ||
*/ | ||
function segmentForeground(image: ImageSource, configuration?: Config): Promise<Blob>; | ||
function applySegmentationMask(image: any, mask: any, config?: Config): Promise<Blob>; | ||
} | ||
declare module '@imgly/background-removal-node/src/inference' { | ||
export { initInference, runInference }; | ||
import { Config } from '@imgly/background-removal-node/src/schema'; | ||
import { NdArray } from 'ndarray'; | ||
function initInference(config?: Config): Promise<{ | ||
config: { | ||
publicPath?: string; | ||
debug?: boolean; | ||
proxyToWorker?: boolean; | ||
fetchArgs?: any; | ||
progress?: (args_0: string, args_1: number, args_2: number, ...args_3: unknown[]) => void; | ||
model?: "small" | "medium" | "large"; | ||
output?: { | ||
format?: "image/x-alpha8" | "image/x-rgba8" | "image/png" | "image/jpeg" | "image/webp"; | ||
quality?: number; | ||
}; | ||
}; | ||
session: import("onnxruntime-common").InferenceSession; | ||
}>; | ||
function runInference(imageTensor: NdArray<Uint8Array>, config: Config, session: any): Promise<NdArray<Uint8Array>>; | ||
} | ||
declare module '@imgly/background-removal-node/src/onnx' { | ||
export { createOnnxSession, runOnnxSession }; | ||
import { NdArray } from 'ndarray'; | ||
import * as ort from 'onnxruntime-node'; | ||
import { Config } from '@imgly/background-removal-node/src/schema'; | ||
function createOnnxSession(model: any, config: Config): Promise<ort.InferenceSession>; | ||
function runOnnxSession(session: any, inputs: [string, NdArray<Float32Array>][], outputs: [string]): Promise<NdArray<Float32Array>[]>; | ||
} | ||
declare module '@imgly/background-removal-node/src/resource' { | ||
export { loadAsBlob, loadAsUrl, loadFromURI }; | ||
import { Config } from '@imgly/background-removal-node/src/schema'; | ||
function loadAsUrl(url: string, config: Config): Promise<string>; | ||
function loadFromURI(uri: URL, config?: { | ||
headers: { | ||
'Content-Type': string; | ||
}; | ||
}): Promise<Response>; | ||
function loadAsBlob(key: string, config: Config): Promise<Blob>; | ||
} | ||
declare module '@imgly/background-removal-node/src/schema' { | ||
export { ConfigSchema, Config, validateConfig }; | ||
import { z } from 'zod'; | ||
const ConfigSchema: z.ZodDefault<z.ZodObject<{ | ||
publicPath: z.ZodEffects<z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, string, string>, string, string>; | ||
debug: z.ZodDefault<z.ZodBoolean>; | ||
proxyToWorker: z.ZodDefault<z.ZodBoolean>; | ||
fetchArgs: z.ZodDefault<z.ZodAny>; | ||
progress: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodNumber, z.ZodNumber], z.ZodUnknown>, z.ZodVoid>>; | ||
model: z.ZodDefault<z.ZodEnum<["small", "medium", "large"]>>; | ||
output: z.ZodDefault<z.ZodObject<{ | ||
format: z.ZodDefault<z.ZodEnum<["image/png", "image/jpeg", "image/webp", "image/x-rgba8", "image/x-alpha8"]>>; | ||
quality: z.ZodDefault<z.ZodNumber>; | ||
}, "strip", z.ZodTypeAny, { | ||
format?: "image/x-alpha8" | "image/x-rgba8" | "image/png" | "image/jpeg" | "image/webp"; | ||
quality?: number; | ||
}, { | ||
format?: "image/x-alpha8" | "image/x-rgba8" | "image/png" | "image/jpeg" | "image/webp"; | ||
quality?: number; | ||
}>>; | ||
}, "strip", z.ZodTypeAny, { | ||
publicPath?: string; | ||
debug?: boolean; | ||
proxyToWorker?: boolean; | ||
fetchArgs?: any; | ||
progress?: (args_0: string, args_1: number, args_2: number, ...args_3: unknown[]) => void; | ||
model?: "small" | "medium" | "large"; | ||
output?: { | ||
format?: "image/x-alpha8" | "image/x-rgba8" | "image/png" | "image/jpeg" | "image/webp"; | ||
quality?: number; | ||
}; | ||
}, { | ||
publicPath?: string; | ||
debug?: boolean; | ||
proxyToWorker?: boolean; | ||
fetchArgs?: any; | ||
progress?: (args_0: string, args_1: number, args_2: number, ...args_3: unknown[]) => void; | ||
model?: "small" | "medium" | "large"; | ||
output?: { | ||
format?: "image/x-alpha8" | "image/x-rgba8" | "image/png" | "image/jpeg" | "image/webp"; | ||
quality?: number; | ||
}; | ||
}>>; | ||
type Config = z.infer<typeof ConfigSchema>; | ||
function validateConfig(configuration?: Config): Config; | ||
} | ||
declare module '@imgly/background-removal-node/src/url' { | ||
export { ensureAbsoluteURI }; | ||
function ensureAbsoluteURI(url: string, baseUrl: string): URL; | ||
} | ||
declare module '@imgly/background-removal-node/src/utils' { | ||
export { imageDecode, imageEncode, tensorResizeBilinear, tensorHWCtoBCHW, calculateProportionalSize, imageSourceToImageData, ImageSource, convertFloat32ToUint8 }; | ||
import { Config } from '@imgly/background-removal-node/src/schema'; | ||
import { NdArray } from 'ndarray'; | ||
import { imageDecode, imageEncode } from '@imgly/background-removal-node/src/codecs'; | ||
type ImageSource = ArrayBuffer | Uint8Array | Blob | URL | string; | ||
function tensorResizeBilinear(imageTensor: NdArray<Uint8Array>, newWidth: number, newHeight: number): NdArray<Uint8Array>; | ||
function tensorHWCtoBCHW(imageTensor: NdArray<Uint32Array>, mean?: number[], std?: number[]): NdArray<Float32Array>; | ||
function calculateProportionalSize(originalWidth: number, originalHeight: number, maxWidth: number, maxHeight: number): [number, number]; | ||
function imageSourceToImageData(image: ImageSource, _: Config): Promise<NdArray<Uint8Array>>; | ||
function convertFloat32ToUint8(float32Array: NdArray<Float32Array>): NdArray<Uint8Array>; | ||
} | ||
declare module '@imgly/background-removal-node' { | ||
import main = require('@imgly/background-removal-node/src/index'); | ||
export = main; | ||
} | ||
export default removeBackground; | ||
export { removeBackground, removeForeground, segmentForeground, applySegmentationMask }; | ||
export type { Config, ImageSource }; | ||
import { Config } from './schema'; | ||
import { ImageSource } from './utils'; | ||
/** | ||
* Removes the background from an image. | ||
* | ||
* @param image - The image to remove the background from. | ||
* @param configuration - Optional configuration for the background removal process. | ||
* @returns A Promise that resolves to the resulting image with the background removed. | ||
*/ | ||
declare function removeBackground(image: ImageSource, configuration?: Config): Promise<Blob>; | ||
/** | ||
* Removes the foreground from an image. | ||
* | ||
* @param image - The image to remove the foreground from. | ||
* @param configuration - Optional configuration for the foreground removal process. | ||
* @returns A Promise that resolves to the resulting image with the foreground removed. | ||
*/ | ||
declare function removeForeground(image: ImageSource, configuration?: Config): Promise<Blob>; | ||
/** | ||
* Segments the foreground of an image using a given configuration. | ||
* | ||
* @param image - The image source to segment. | ||
* @param configuration - The optional configuration for the segmentation. | ||
* @returns A Promise that resolves to the segmented foreground as a Blob. | ||
*/ | ||
declare function segmentForeground(image: ImageSource, configuration?: Config): Promise<Blob>; | ||
declare function applySegmentationMask(image: any, mask: any, config?: Config): Promise<Blob>; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@imgly/background-removal-node", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Background Removal in NodeJS", | ||
@@ -52,6 +52,9 @@ "resources": "@imgly/background-removal-node", | ||
"changelog:generate": "node ../../scripts/changelog/changelog-generate.mjs", | ||
"build": "npm run clean && npm run resources && npm run changelog:generate && node scripts/build.mjs", | ||
"build": "npm run clean && npm run resources && npm run types && npm run changelog:generate && node scripts/build.mjs", | ||
"types": " npx tsc --declaration --emitDeclarationOnly --declarationDir dist --declarationMap", | ||
"watch": "npm run clean && npm run resources && npm run changelog:generate && node scripts/watch.mjs", | ||
"publish": "npm run build && npm publish --access public", | ||
"lint": "npx prettier --write ." | ||
"lint": "npx prettier --write .", | ||
"publish:latest": "npm run build && npm publish --tag latest --access public", | ||
"publish:next": "npm run build && npm publish --tag next --access public", | ||
"package:pack": "npm run build && npm pack . --pack-destination ../../releases" | ||
}, | ||
@@ -82,2 +85,2 @@ "dependencies": { | ||
} | ||
} | ||
} |
@@ -28,3 +28,3 @@ # Background Removal in NodeJs | ||
The Neural Network ([ONNX model](https://onnx.ai/)) are hosted on [UNPKG](https://www.unpkg.com/), making it readily available for download to all users of the library. See the section Custom Asset Serving if you want to host data on your own servers. | ||
The Neural Network model files ([ONNX model](https://onnx.ai/)) are hosted by [IMG.LY](https://img.ly/), making it readily available for download to all users of the library. See the section Custom Asset Serving if you want to host data on your own servers. | ||
@@ -94,3 +94,3 @@ ## Installation | ||
Currently, the wasm and onnx neural networks are served via unpkg. For production use, we advise you to host them yourself. Therefore, copy all .wasm and .onnx files to your public path `$PUBLIC_PATH` and reconfigure the library. | ||
The wasm and onnx neural networks are hosted by IMG.LY by default. For production use, we advise you to host them yourself. Therefore, copy all .wasm and .onnx files to your public path `$PUBLIC_PATH` and reconfigure the library. | ||
@@ -97,0 +97,0 @@ ```shell |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
132672297
57
1490