web/removebg: fix types (remove garbage)
Some checks are pending
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
Run tests / check lockfile correctness (push) Waiting to run
Run tests / web sanity check (push) Waiting to run
Run tests / api sanity check (push) Waiting to run

This commit is contained in:
wukko 2025-01-14 18:30:33 +06:00
parent d649a00718
commit 2f2d39dc4c
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2

View file

@ -4,20 +4,10 @@ const models = {
light: {
id: "briaai/RMBG-1.4",
input: "input",
modelConfig: {
device: "wasm",
dtype: "fp32",
},
processorConfig: {},
},
heavy: {
id: "onnx-community/BiRefNet_lite",
input: "input_image",
modelConfig: {
device: "webgpu",
dtype: "fp16",
},
processorConfig: {},
}
}
@ -25,9 +15,12 @@ export const removeImageBackground = async (file: File) => {
const image = await RawImage.fromBlob(new Blob([file]));
const model_type = "light";
const model = await AutoModel.from_pretrained(models[model_type].id, models[model_type].modelConfig);
const model = await AutoModel.from_pretrained(models[model_type].id, {
device: "wasm",
dtype: "fp32",
});
const processor = await AutoProcessor.from_pretrained(models[model_type].id, models[model_type].processorConfig);
const processor = await AutoProcessor.from_pretrained(models[model_type].id, {});
if (model && processor) {
const { pixel_values } = await processor(image);