Make it compatible without extra config on Transformers.js
Browse fileshi
@OriLib
, this file is need on transformers.js , with it on the repo, it makes is super simple to load it without passing extra params
after
```js
import { AutoModel, AutoProcessor, RawImage } from '@xenova/transformers';
// Load model and processor
const model = await AutoModel.from_pretrained('briaai/RMBG-1.4', { quantized: false });
const processor = await AutoProcessor.from_pretrained('briaai/RMBG-1.4');
```
before
```js
const model = AutoModel.from_pretrained("briaai/RMBG-1.4", {
// Do not require config.json to be present in the repository
config: { model_type: "custom" },
quantized: device === Devices.webgpu ? false : quantized,
device: device,
});
console.log("RUNNING WIHTT", device);
const processor = await AutoProcessor.from_pretrained("briaai/RMBG-1.4", {
// Do not require config.json to be present in the repository
config: {
do_normalize: true,
do_pad: false,
do_rescale: true,
do_resize: true,
image_mean: [0.5, 0.5, 0.5],
feature_extractor_type: "ImageFeatureExtractor",
image_std: [1, 1, 1],
resample: 2,
rescale_factor: 0.00392156862745098,
size: { width: 1024, height: 1024 },
},
});
````
- preprocessor_config.json +25 -0
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"config": {
|
| 3 |
+
"do_normalize": true,
|
| 4 |
+
"do_pad": false,
|
| 5 |
+
"do_rescale": true,
|
| 6 |
+
"do_resize": true,
|
| 7 |
+
"image_mean": [
|
| 8 |
+
0.5,
|
| 9 |
+
0.5,
|
| 10 |
+
0.5
|
| 11 |
+
],
|
| 12 |
+
"feature_extractor_type": "ImageFeatureExtractor",
|
| 13 |
+
"image_std": [
|
| 14 |
+
1,
|
| 15 |
+
1,
|
| 16 |
+
1
|
| 17 |
+
],
|
| 18 |
+
"resample": 2,
|
| 19 |
+
"rescale_factor": 0.00392156862745098,
|
| 20 |
+
"size": {
|
| 21 |
+
"width": 1024,
|
| 22 |
+
"height": 1024
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
}
|