@huggingface/transformers 3.1.1 → 3.1.2

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.
Files changed (119) hide show
  1. package/README.md +6 -3
  2. package/dist/ort-wasm-simd-threaded.jsep.wasm +0 -0
  3. package/dist/transformers.cjs +300 -55
  4. package/dist/transformers.cjs.map +1 -1
  5. package/dist/transformers.js +1468 -1105
  6. package/dist/transformers.js.map +1 -1
  7. package/dist/transformers.min.cjs +1 -358
  8. package/dist/transformers.min.cjs.map +1 -1
  9. package/dist/transformers.min.js +1 -421
  10. package/dist/transformers.min.js.map +1 -1
  11. package/dist/transformers.min.mjs +1 -358
  12. package/dist/transformers.min.mjs.map +1 -1
  13. package/dist/transformers.mjs +311 -54
  14. package/dist/transformers.mjs.map +1 -1
  15. package/package.json +11 -16
  16. package/src/backends/onnx.js +2 -7
  17. package/src/configs.js +1 -0
  18. package/src/env.js +1 -1
  19. package/src/models/paligemma/processing_paligemma.js +82 -0
  20. package/src/models/processors.js +1 -0
  21. package/src/models.js +57 -5
  22. package/src/tokenizers.js +12 -1
  23. package/src/utils/core.js +39 -9
  24. package/src/utils/hub.js +8 -12
  25. package/src/utils/image.js +40 -0
  26. package/types/backends/onnx.d.ts +2 -2
  27. package/types/backends/onnx.d.ts.map +1 -1
  28. package/types/base/feature_extraction_utils.d.ts +1 -1
  29. package/types/base/feature_extraction_utils.d.ts.map +1 -1
  30. package/types/base/image_processors_utils.d.ts +2 -2
  31. package/types/base/image_processors_utils.d.ts.map +1 -1
  32. package/types/base/processing_utils.d.ts +4 -4
  33. package/types/base/processing_utils.d.ts.map +1 -1
  34. package/types/configs.d.ts +7 -7
  35. package/types/configs.d.ts.map +1 -1
  36. package/types/env.d.ts +1 -1
  37. package/types/env.d.ts.map +1 -1
  38. package/types/generation/configuration_utils.d.ts +2 -2
  39. package/types/generation/logits_process.d.ts +2 -2
  40. package/types/generation/logits_process.d.ts.map +1 -1
  41. package/types/generation/logits_sampler.d.ts.map +1 -1
  42. package/types/generation/parameters.d.ts +5 -5
  43. package/types/generation/stopping_criteria.d.ts +1 -1
  44. package/types/generation/stopping_criteria.d.ts.map +1 -1
  45. package/types/generation/streamers.d.ts +2 -2
  46. package/types/generation/streamers.d.ts.map +1 -1
  47. package/types/models/audio_spectrogram_transformer/feature_extraction_audio_spectrogram_transformer.d.ts +1 -1
  48. package/types/models/audio_spectrogram_transformer/feature_extraction_audio_spectrogram_transformer.d.ts.map +1 -1
  49. package/types/models/auto/feature_extraction_auto.d.ts.map +1 -1
  50. package/types/models/auto/image_processing_auto.d.ts.map +1 -1
  51. package/types/models/auto/processing_auto.d.ts +1 -1
  52. package/types/models/auto/processing_auto.d.ts.map +1 -1
  53. package/types/models/clap/feature_extraction_clap.d.ts +1 -1
  54. package/types/models/clap/feature_extraction_clap.d.ts.map +1 -1
  55. package/types/models/detr/image_processing_detr.d.ts +11 -11
  56. package/types/models/detr/image_processing_detr.d.ts.map +1 -1
  57. package/types/models/donut/image_processing_donut.d.ts +1 -1
  58. package/types/models/donut/image_processing_donut.d.ts.map +1 -1
  59. package/types/models/florence2/processing_florence2.d.ts.map +1 -1
  60. package/types/models/idefics3/image_processing_idefics3.d.ts.map +1 -1
  61. package/types/models/idefics3/processing_idefics3.d.ts.map +1 -1
  62. package/types/models/janus/image_processing_janus.d.ts +1 -1
  63. package/types/models/janus/image_processing_janus.d.ts.map +1 -1
  64. package/types/models/janus/processing_janus.d.ts.map +1 -1
  65. package/types/models/maskformer/image_processing_maskformer.d.ts +8 -8
  66. package/types/models/maskformer/image_processing_maskformer.d.ts.map +1 -1
  67. package/types/models/mgp_str/processing_mgp_str.d.ts +2 -2
  68. package/types/models/mgp_str/processing_mgp_str.d.ts.map +1 -1
  69. package/types/models/owlvit/image_processing_owlvit.d.ts.map +1 -1
  70. package/types/models/paligemma/processing_paligemma.d.ts +12 -0
  71. package/types/models/paligemma/processing_paligemma.d.ts.map +1 -0
  72. package/types/models/processors.d.ts +1 -0
  73. package/types/models/pyannote/feature_extraction_pyannote.d.ts.map +1 -1
  74. package/types/models/pyannote/processing_pyannote.d.ts +1 -1
  75. package/types/models/pyannote/processing_pyannote.d.ts.map +1 -1
  76. package/types/models/qwen2_vl/processing_qwen2_vl.d.ts.map +1 -1
  77. package/types/models/rt_detr/image_processing_rt_detr.d.ts.map +1 -1
  78. package/types/models/sam/image_processing_sam.d.ts.map +1 -1
  79. package/types/models/seamless_m4t/feature_extraction_seamless_m4t.d.ts +1 -1
  80. package/types/models/seamless_m4t/feature_extraction_seamless_m4t.d.ts.map +1 -1
  81. package/types/models/segformer/image_processing_segformer.d.ts.map +1 -1
  82. package/types/models/speecht5/processing_speecht5.d.ts.map +1 -1
  83. package/types/models/swin2sr/image_processing_swin2sr.d.ts +1 -1
  84. package/types/models/swin2sr/image_processing_swin2sr.d.ts.map +1 -1
  85. package/types/models/vitmatte/image_processing_vitmatte.d.ts.map +1 -1
  86. package/types/models/vitpose/image_processing_vitpose.d.ts +1 -1
  87. package/types/models/vitpose/image_processing_vitpose.d.ts.map +1 -1
  88. package/types/models/wav2vec2/feature_extraction_wav2vec2.d.ts.map +1 -1
  89. package/types/models/wav2vec2/processing_wav2vec2.d.ts.map +1 -1
  90. package/types/models/wespeaker/feature_extraction_wespeaker.d.ts +1 -1
  91. package/types/models/wespeaker/feature_extraction_wespeaker.d.ts.map +1 -1
  92. package/types/models/whisper/feature_extraction_whisper.d.ts +1 -1
  93. package/types/models/whisper/feature_extraction_whisper.d.ts.map +1 -1
  94. package/types/models/whisper/generation_whisper.d.ts.map +1 -1
  95. package/types/models/whisper/processing_whisper.d.ts.map +1 -1
  96. package/types/models/yolos/image_processing_yolos.d.ts.map +1 -1
  97. package/types/models.d.ts +28 -4
  98. package/types/models.d.ts.map +1 -1
  99. package/types/ops/registry.d.ts.map +1 -1
  100. package/types/pipelines.d.ts +26 -51
  101. package/types/pipelines.d.ts.map +1 -1
  102. package/types/tokenizers.d.ts +10 -6
  103. package/types/tokenizers.d.ts.map +1 -1
  104. package/types/utils/audio.d.ts.map +1 -1
  105. package/types/utils/constants.d.ts.map +1 -1
  106. package/types/utils/core.d.ts +87 -22
  107. package/types/utils/core.d.ts.map +1 -1
  108. package/types/utils/data-structures.d.ts.map +1 -1
  109. package/types/utils/devices.d.ts.map +1 -1
  110. package/types/utils/dtypes.d.ts.map +1 -1
  111. package/types/utils/generic.d.ts.map +1 -1
  112. package/types/utils/hub.d.ts +3 -3
  113. package/types/utils/hub.d.ts.map +1 -1
  114. package/types/utils/image.d.ts +10 -1
  115. package/types/utils/image.d.ts.map +1 -1
  116. package/types/utils/maths.d.ts +10 -10
  117. package/types/utils/maths.d.ts.map +1 -1
  118. package/types/utils/tensor.d.ts +6 -6
  119. package/types/utils/tensor.d.ts.map +1 -1
@@ -56,10 +56,10 @@ module.exports = require("url");
56
56
 
57
57
  /***/ }),
58
58
 
59
- /***/ "?cb4d":
60
- /*!*************************************!*\
61
- !*** #onnxruntime-webgpu (ignored) ***!
62
- \*************************************/
59
+ /***/ "?8b6b":
60
+ /*!*********************************!*\
61
+ !*** onnxruntime-web (ignored) ***!
62
+ \*********************************/
63
63
  /***/ (() => {
64
64
 
65
65
  /* (ignored) */
@@ -3896,7 +3896,7 @@ const version = '1.20.1';
3896
3896
 
3897
3897
  "use strict";
3898
3898
  var onnxruntime_node__WEBPACK_IMPORTED_MODULE_1___namespace_cache;
3899
- var _onnxruntime_webgpu__WEBPACK_IMPORTED_MODULE_2___namespace_cache;
3899
+ var onnxruntime_web__WEBPACK_IMPORTED_MODULE_2___namespace_cache;
3900
3900
  __webpack_require__.r(__webpack_exports__);
3901
3901
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3902
3902
  /* harmony export */ Tensor: () => (/* reexport safe */ onnxruntime_common__WEBPACK_IMPORTED_MODULE_3__.Tensor),
@@ -3907,7 +3907,7 @@ __webpack_require__.r(__webpack_exports__);
3907
3907
  /* harmony export */ });
3908
3908
  /* harmony import */ var _env_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../env.js */ "./src/env.js");
3909
3909
  /* harmony import */ var onnxruntime_node__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! onnxruntime-node */ "onnxruntime-node");
3910
- /* harmony import */ var _onnxruntime_webgpu__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! #onnxruntime-webgpu */ "?cb4d");
3910
+ /* harmony import */ var onnxruntime_web__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! onnxruntime-web */ "?8b6b");
3911
3911
  /* harmony import */ var onnxruntime_common__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! onnxruntime-common */ "./node_modules/onnxruntime-common/dist/esm/index.js");
3912
3912
  /**
3913
3913
  * @file Handler file for choosing the correct version of ONNX Runtime, based on the environment.
@@ -3933,11 +3933,6 @@ __webpack_require__.r(__webpack_exports__);
3933
3933
  // In either case, we select the default export if it exists, otherwise we use the named export.
3934
3934
 
3935
3935
 
3936
- // Use subpath-imports to ensure Node.js and browser interoperability.
3937
- // See package.json and https://nodejs.org/api/packages.html#subpath-imports
3938
- // for more information.
3939
- // @ts-ignore
3940
-
3941
3936
 
3942
3937
 
3943
3938
 
@@ -3979,7 +3974,7 @@ if (ORT_SYMBOL in globalThis) {
3979
3974
  } else if (_env_js__WEBPACK_IMPORTED_MODULE_0__.apis.IS_NODE_ENV) {
3980
3975
  ONNX = onnxruntime_node__WEBPACK_IMPORTED_MODULE_1__ ?? /*#__PURE__*/ (onnxruntime_node__WEBPACK_IMPORTED_MODULE_1___namespace_cache || (onnxruntime_node__WEBPACK_IMPORTED_MODULE_1___namespace_cache = __webpack_require__.t(onnxruntime_node__WEBPACK_IMPORTED_MODULE_1__, 2)));
3981
3976
 
3982
- // Updated as of ONNX Runtime 1.18.0
3977
+ // Updated as of ONNX Runtime 1.20.1
3983
3978
  // The following table lists the supported versions of ONNX Runtime Node.js binding provided with pre-built binaries.
3984
3979
  // | EPs/Platforms | Windows x64 | Windows arm64 | Linux x64 | Linux arm64 | MacOS x64 | MacOS arm64 |
3985
3980
  // | ------------- | ----------- | ------------- | ----------------- | ----------- | --------- | ----------- |
@@ -4002,7 +3997,7 @@ if (ORT_SYMBOL in globalThis) {
4002
3997
  supportedDevices.push('cpu');
4003
3998
  defaultDevices = ['cpu'];
4004
3999
  } else {
4005
- ONNX = /*#__PURE__*/ (_onnxruntime_webgpu__WEBPACK_IMPORTED_MODULE_2___namespace_cache || (_onnxruntime_webgpu__WEBPACK_IMPORTED_MODULE_2___namespace_cache = __webpack_require__.t(_onnxruntime_webgpu__WEBPACK_IMPORTED_MODULE_2__, 2)));
4000
+ ONNX = /*#__PURE__*/ (onnxruntime_web__WEBPACK_IMPORTED_MODULE_2___namespace_cache || (onnxruntime_web__WEBPACK_IMPORTED_MODULE_2___namespace_cache = __webpack_require__.t(onnxruntime_web__WEBPACK_IMPORTED_MODULE_2__, 2)));
4006
4001
 
4007
4002
  if (_env_js__WEBPACK_IMPORTED_MODULE_0__.apis.IS_WEBNN_AVAILABLE) {
4008
4003
  // TODO: Only push supported providers (depending on available hardware)
@@ -5597,6 +5592,7 @@ function getNormalizedConfig(config) {
5597
5592
  break;
5598
5593
  case 'llama':
5599
5594
  case 'olmo':
5595
+ case 'olmo2':
5600
5596
  case 'mobilellm':
5601
5597
  case 'granite':
5602
5598
  case 'cohere':
@@ -5926,7 +5922,7 @@ __webpack_require__.r(__webpack_exports__);
5926
5922
 
5927
5923
 
5928
5924
 
5929
- const VERSION = '3.1.1';
5925
+ const VERSION = '3.1.2';
5930
5926
 
5931
5927
  // Check if various APIs are available (depends on environment)
5932
5928
  const IS_BROWSER_ENV = typeof window !== "undefined" && typeof window.document !== "undefined";
@@ -8068,6 +8064,9 @@ __webpack_require__.r(__webpack_exports__);
8068
8064
  /* harmony export */ HubertForSequenceClassification: () => (/* binding */ HubertForSequenceClassification),
8069
8065
  /* harmony export */ HubertModel: () => (/* binding */ HubertModel),
8070
8066
  /* harmony export */ HubertPreTrainedModel: () => (/* binding */ HubertPreTrainedModel),
8067
+ /* harmony export */ IJepaForImageClassification: () => (/* binding */ IJepaForImageClassification),
8068
+ /* harmony export */ IJepaModel: () => (/* binding */ IJepaModel),
8069
+ /* harmony export */ IJepaPreTrainedModel: () => (/* binding */ IJepaPreTrainedModel),
8071
8070
  /* harmony export */ Idefics3ForConditionalGeneration: () => (/* binding */ Idefics3ForConditionalGeneration),
8072
8071
  /* harmony export */ Idefics3PreTrainedModel: () => (/* binding */ Idefics3PreTrainedModel),
8073
8072
  /* harmony export */ ImageMattingOutput: () => (/* binding */ ImageMattingOutput),
@@ -8159,6 +8158,9 @@ __webpack_require__.r(__webpack_exports__);
8159
8158
  /* harmony export */ OPTForCausalLM: () => (/* binding */ OPTForCausalLM),
8160
8159
  /* harmony export */ OPTModel: () => (/* binding */ OPTModel),
8161
8160
  /* harmony export */ OPTPreTrainedModel: () => (/* binding */ OPTPreTrainedModel),
8161
+ /* harmony export */ Olmo2ForCausalLM: () => (/* binding */ Olmo2ForCausalLM),
8162
+ /* harmony export */ Olmo2Model: () => (/* binding */ Olmo2Model),
8163
+ /* harmony export */ Olmo2PreTrainedModel: () => (/* binding */ Olmo2PreTrainedModel),
8162
8164
  /* harmony export */ OlmoForCausalLM: () => (/* binding */ OlmoForCausalLM),
8163
8165
  /* harmony export */ OlmoModel: () => (/* binding */ OlmoModel),
8164
8166
  /* harmony export */ OlmoPreTrainedModel: () => (/* binding */ OlmoPreTrainedModel),
@@ -8171,6 +8173,8 @@ __webpack_require__.r(__webpack_exports__);
8171
8173
  /* harmony export */ Owlv2ForObjectDetection: () => (/* binding */ Owlv2ForObjectDetection),
8172
8174
  /* harmony export */ Owlv2Model: () => (/* binding */ Owlv2Model),
8173
8175
  /* harmony export */ Owlv2PreTrainedModel: () => (/* binding */ Owlv2PreTrainedModel),
8176
+ /* harmony export */ PaliGemmaForConditionalGeneration: () => (/* binding */ PaliGemmaForConditionalGeneration),
8177
+ /* harmony export */ PaliGemmaPreTrainedModel: () => (/* binding */ PaliGemmaPreTrainedModel),
8174
8178
  /* harmony export */ PatchTSMixerForPrediction: () => (/* binding */ PatchTSMixerForPrediction),
8175
8179
  /* harmony export */ PatchTSMixerModel: () => (/* binding */ PatchTSMixerModel),
8176
8180
  /* harmony export */ PatchTSMixerPreTrainedModel: () => (/* binding */ PatchTSMixerPreTrainedModel),
@@ -8852,7 +8856,9 @@ async function decoderForward(self, model_inputs, is_encoder_decoder = false) {
8852
8856
  new_model_inputs.use_cache_branch = boolTensor(!!past_key_values);
8853
8857
  }
8854
8858
  if (session.inputNames.includes('position_ids') && new_model_inputs.attention_mask && !new_model_inputs.position_ids) {
8855
- new_model_inputs.position_ids = createPositionIds(new_model_inputs, past_key_values);
8859
+ // NOTE: Handle a special case for paligemma models, where positions are 1-indexed
8860
+ const start_index = self.config.model_type === 'paligemma' ? 1 : 0;
8861
+ new_model_inputs.position_ids = createPositionIds(new_model_inputs, past_key_values, start_index);
8856
8862
  }
8857
8863
 
8858
8864
  // Unpack the `past_key_values` object into model inputs
@@ -8988,14 +8994,14 @@ async function imageTextToTextForward(self, {
8988
8994
  * @param {Tensor} attention_mask
8989
8995
  * @returns {{data: BigInt64Array, dims: number[]}}
8990
8996
  */
8991
- function cumsum_masked_fill(attention_mask) {
8997
+ function cumsum_masked_fill(attention_mask, start_index = 0) {
8992
8998
  const [bz, seq_len] = attention_mask.dims;
8993
8999
  const attn_mask_data = attention_mask.data;
8994
9000
 
8995
9001
  const data = new BigInt64Array(attn_mask_data.length);
8996
9002
  for (let i = 0; i < bz; ++i) {
8997
9003
  const start = i * seq_len;
8998
- let sum = BigInt(0);
9004
+ let sum = BigInt(start_index);
8999
9005
  for (let j = 0; j < seq_len; ++j) {
9000
9006
  const index = start + j;
9001
9007
  if (attn_mask_data[index] === 0n) {
@@ -9022,10 +9028,10 @@ function cumsum_masked_fill(attention_mask) {
9022
9028
  * position_ids = position_ids[:, -input_ids.shape[1] :]
9023
9029
  * ```
9024
9030
  */
9025
- function createPositionIds(model_inputs, past_key_values = null) {
9031
+ function createPositionIds(model_inputs, past_key_values = null, start_index = 0) {
9026
9032
  const { input_ids, inputs_embeds, attention_mask } = model_inputs;
9027
9033
 
9028
- const { data, dims } = cumsum_masked_fill(attention_mask);
9034
+ const { data, dims } = cumsum_masked_fill(attention_mask, start_index);
9029
9035
  let position_ids = new _utils_tensor_js__WEBPACK_IMPORTED_MODULE_9__.Tensor('int64', data, dims);
9030
9036
  if (past_key_values) {
9031
9037
  const offset = -(input_ids ?? inputs_embeds).dims.at(1);
@@ -11842,6 +11848,30 @@ class Florence2ForConditionalGeneration extends Florence2PreTrainedModel {
11842
11848
  }
11843
11849
  }
11844
11850
 
11851
+ class PaliGemmaPreTrainedModel extends PreTrainedModel {
11852
+ forward_params = [
11853
+ 'input_ids',
11854
+ // 'inputs_embeds',
11855
+ 'attention_mask',
11856
+ 'pixel_values',
11857
+ 'position_ids',
11858
+ 'past_key_values',
11859
+ ];
11860
+ }
11861
+
11862
+ class PaliGemmaForConditionalGeneration extends PaliGemmaPreTrainedModel {
11863
+ _merge_input_ids_with_image_features(kwargs) {
11864
+ const vision_hidden_size = kwargs.image_features.dims.at(-1);
11865
+ const reshaped_image_hidden_states = kwargs.image_features.view(-1, vision_hidden_size);
11866
+
11867
+ return default_merge_input_ids_with_image_features({
11868
+ // @ts-ignore
11869
+ image_token_id: this.config.image_token_index,
11870
+ ...kwargs,
11871
+ image_features: reshaped_image_hidden_states,
11872
+ })
11873
+ }
11874
+ }
11845
11875
 
11846
11876
  //////////////////////////////////////////////////
11847
11877
  // Idefics3 Models
@@ -12380,6 +12410,13 @@ class OlmoModel extends OlmoPreTrainedModel { }
12380
12410
  class OlmoForCausalLM extends OlmoPreTrainedModel { }
12381
12411
  //////////////////////////////////////////////////
12382
12412
 
12413
+ //////////////////////////////////////////////////
12414
+ // OLMo2 models
12415
+ class Olmo2PreTrainedModel extends PreTrainedModel { }
12416
+ class Olmo2Model extends Olmo2PreTrainedModel { }
12417
+ class Olmo2ForCausalLM extends Olmo2PreTrainedModel { }
12418
+ //////////////////////////////////////////////////
12419
+
12383
12420
 
12384
12421
  //////////////////////////////////////////////////
12385
12422
  // Granite models
@@ -12796,6 +12833,20 @@ class ViTForImageClassification extends ViTPreTrainedModel {
12796
12833
  //////////////////////////////////////////////////
12797
12834
 
12798
12835
 
12836
+ //////////////////////////////////////////////////
12837
+ class IJepaPreTrainedModel extends PreTrainedModel { }
12838
+ class IJepaModel extends IJepaPreTrainedModel { }
12839
+ class IJepaForImageClassification extends IJepaPreTrainedModel {
12840
+ /**
12841
+ * @param {any} model_inputs
12842
+ */
12843
+ async _call(model_inputs) {
12844
+ return new SequenceClassifierOutput(await super._call(model_inputs));
12845
+ }
12846
+ }
12847
+ //////////////////////////////////////////////////
12848
+
12849
+
12799
12850
  //////////////////////////////////////////////////
12800
12851
  class VitPosePreTrainedModel extends PreTrainedModel { }
12801
12852
 
@@ -15066,6 +15117,7 @@ const MODEL_MAPPING_NAMES_ENCODER_ONLY = new Map([
15066
15117
  ['rt_detr', ['RTDetrModel', RTDetrModel]],
15067
15118
  ['table-transformer', ['TableTransformerModel', TableTransformerModel]],
15068
15119
  ['vit', ['ViTModel', ViTModel]],
15120
+ ['ijepa', ['IJepaModel', IJepaModel]],
15069
15121
  ['pvt', ['PvtModel', PvtModel]],
15070
15122
  ['vit_msn', ['ViTMSNModel', ViTMSNModel]],
15071
15123
  ['vit_mae', ['ViTMAEModel', ViTMAEModel]],
@@ -15130,6 +15182,7 @@ const MODEL_MAPPING_NAMES_DECODER_ONLY = new Map([
15130
15182
  ['codegen', ['CodeGenModel', CodeGenModel]],
15131
15183
  ['llama', ['LlamaModel', LlamaModel]],
15132
15184
  ['olmo', ['OlmoModel', OlmoModel]],
15185
+ ['olmo2', ['Olmo2Model', Olmo2Model]],
15133
15186
  ['mobilellm', ['MobileLLMModel', MobileLLMModel]],
15134
15187
  ['granite', ['GraniteModel', GraniteModel]],
15135
15188
  ['cohere', ['CohereModel', CohereModel]],
@@ -15221,6 +15274,7 @@ const MODEL_FOR_CAUSAL_LM_MAPPING_NAMES = new Map([
15221
15274
  ['codegen', ['CodeGenForCausalLM', CodeGenForCausalLM]],
15222
15275
  ['llama', ['LlamaForCausalLM', LlamaForCausalLM]],
15223
15276
  ['olmo', ['OlmoForCausalLM', OlmoForCausalLM]],
15277
+ ['olmo2', ['Olmo2ForCausalLM', Olmo2ForCausalLM]],
15224
15278
  ['mobilellm', ['MobileLLMForCausalLM', MobileLLMForCausalLM]],
15225
15279
  ['granite', ['GraniteForCausalLM', GraniteForCausalLM]],
15226
15280
  ['cohere', ['CohereForCausalLM', CohereForCausalLM]],
@@ -15294,6 +15348,7 @@ const MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES = new Map([
15294
15348
  ['florence2', ['Florence2ForConditionalGeneration', Florence2ForConditionalGeneration]],
15295
15349
  ['qwen2-vl', ['Qwen2VLForConditionalGeneration', Qwen2VLForConditionalGeneration]],
15296
15350
  ['idefics3', ['Idefics3ForConditionalGeneration', Idefics3ForConditionalGeneration]],
15351
+ ['paligemma', ['PaliGemmaForConditionalGeneration', PaliGemmaForConditionalGeneration]],
15297
15352
  ]);
15298
15353
 
15299
15354
  const MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES = new Map([
@@ -15302,6 +15357,7 @@ const MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES = new Map([
15302
15357
 
15303
15358
  const MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES = new Map([
15304
15359
  ['vit', ['ViTForImageClassification', ViTForImageClassification]],
15360
+ ['ijepa', ['IJepaForImageClassification', IJepaForImageClassification]],
15305
15361
  ['pvt', ['PvtForImageClassification', PvtForImageClassification]],
15306
15362
  ['vit_msn', ['ViTMSNForImageClassification', ViTMSNForImageClassification]],
15307
15363
  ['fastvit', ['FastViTForImageClassification', FastViTForImageClassification]],
@@ -18180,6 +18236,106 @@ class OwlViTProcessor extends _base_processing_utils_js__WEBPACK_IMPORTED_MODULE
18180
18236
  }
18181
18237
 
18182
18238
 
18239
+ /***/ }),
18240
+
18241
+ /***/ "./src/models/paligemma/processing_paligemma.js":
18242
+ /*!******************************************************!*\
18243
+ !*** ./src/models/paligemma/processing_paligemma.js ***!
18244
+ \******************************************************/
18245
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
18246
+
18247
+ "use strict";
18248
+ __webpack_require__.r(__webpack_exports__);
18249
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
18250
+ /* harmony export */ PaliGemmaProcessor: () => (/* binding */ PaliGemmaProcessor)
18251
+ /* harmony export */ });
18252
+ /* harmony import */ var _base_processing_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../base/processing_utils.js */ "./src/base/processing_utils.js");
18253
+ /* harmony import */ var _auto_image_processing_auto_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../auto/image_processing_auto.js */ "./src/models/auto/image_processing_auto.js");
18254
+ /* harmony import */ var _tokenizers_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../tokenizers.js */ "./src/tokenizers.js");
18255
+
18256
+
18257
+
18258
+
18259
+ const IMAGE_TOKEN = "<image>";
18260
+
18261
+ function build_string_from_input(
18262
+ prompt,
18263
+ bos_token,
18264
+ image_seq_len,
18265
+ image_token,
18266
+ num_images,
18267
+ ) {
18268
+ return `${image_token.repeat(image_seq_len * num_images)}${bos_token}${prompt}\n`
18269
+ }
18270
+
18271
+ class PaliGemmaProcessor extends _base_processing_utils_js__WEBPACK_IMPORTED_MODULE_0__.Processor {
18272
+ static tokenizer_class = _tokenizers_js__WEBPACK_IMPORTED_MODULE_2__.AutoTokenizer
18273
+ static image_processor_class = _auto_image_processing_auto_js__WEBPACK_IMPORTED_MODULE_1__.AutoImageProcessor
18274
+ static uses_processor_config = false;
18275
+
18276
+ /**
18277
+ * @typedef {import('../../utils/image.js').RawImage} RawImage
18278
+ */
18279
+
18280
+ // `images` is required, `text` is optional
18281
+ async _call(/** @type {RawImage|RawImage[]} */ images, text = null, kwargs = {}) {
18282
+ if (!text) {
18283
+ console.warn(
18284
+ "You are using PaliGemma without a text prefix. It will perform as a picture-captioning model."
18285
+ )
18286
+ text = ""
18287
+ }
18288
+
18289
+ if (!Array.isArray(images)) {
18290
+ images = [images]
18291
+ }
18292
+
18293
+ if (!Array.isArray(text)) {
18294
+ text = [text]
18295
+ }
18296
+
18297
+ const bos_token = this.tokenizer.bos_token;
18298
+ const image_seq_length = this.image_processor.config.image_seq_length;
18299
+ let input_strings;
18300
+ if (text.some((t) => t.includes(IMAGE_TOKEN))) {
18301
+ input_strings = text.map(
18302
+ sample => {
18303
+ const expanded_sample = sample.replaceAll(IMAGE_TOKEN, IMAGE_TOKEN.repeat(image_seq_length));
18304
+ const bos_rfind_index = expanded_sample.lastIndexOf(IMAGE_TOKEN);
18305
+ const bos_index = bos_rfind_index === -1 ? 0 : bos_rfind_index + IMAGE_TOKEN.length;
18306
+ return expanded_sample.slice(0, bos_index) + bos_token + expanded_sample.slice(bos_index) + "\n";
18307
+ }
18308
+ )
18309
+ } else {
18310
+ console.warn(
18311
+ "You are passing both `text` and `images` to `PaliGemmaProcessor`. The processor expects special " +
18312
+ "image tokens in the text, as many tokens as there are images per each text. It is recommended to " +
18313
+ "add `<image>` tokens in the very beginning of your text. For this call, we will infer how many images " +
18314
+ "each text has and add special tokens."
18315
+ )
18316
+
18317
+ input_strings = text.map(
18318
+ sample => build_string_from_input(
18319
+ sample,
18320
+ bos_token,
18321
+ image_seq_length,
18322
+ IMAGE_TOKEN,
18323
+ images.length,
18324
+ )
18325
+ )
18326
+ }
18327
+
18328
+ const text_inputs = this.tokenizer(input_strings, kwargs);
18329
+ const image_inputs = await this.image_processor(images, kwargs);
18330
+
18331
+ return {
18332
+ ...image_inputs,
18333
+ ...text_inputs,
18334
+ }
18335
+ }
18336
+ }
18337
+
18338
+
18183
18339
  /***/ }),
18184
18340
 
18185
18341
  /***/ "./src/models/processors.js":
@@ -18196,13 +18352,14 @@ __webpack_require__.r(__webpack_exports__);
18196
18352
  /* harmony export */ JinaCLIPProcessor: () => (/* reexport safe */ _jina_clip_processing_jina_clip_js__WEBPACK_IMPORTED_MODULE_4__.JinaCLIPProcessor),
18197
18353
  /* harmony export */ MgpstrProcessor: () => (/* reexport safe */ _mgp_str_processing_mgp_str_js__WEBPACK_IMPORTED_MODULE_1__.MgpstrProcessor),
18198
18354
  /* harmony export */ OwlViTProcessor: () => (/* reexport safe */ _owlvit_processing_owlvit_js__WEBPACK_IMPORTED_MODULE_5__.OwlViTProcessor),
18199
- /* harmony export */ PyAnnoteProcessor: () => (/* reexport safe */ _pyannote_processing_pyannote_js__WEBPACK_IMPORTED_MODULE_6__.PyAnnoteProcessor),
18200
- /* harmony export */ Qwen2VLProcessor: () => (/* reexport safe */ _qwen2_vl_processing_qwen2_vl_js__WEBPACK_IMPORTED_MODULE_7__.Qwen2VLProcessor),
18201
- /* harmony export */ SamProcessor: () => (/* reexport safe */ _sam_processing_sam_js__WEBPACK_IMPORTED_MODULE_8__.SamProcessor),
18202
- /* harmony export */ SpeechT5Processor: () => (/* reexport safe */ _speecht5_processing_speecht5_js__WEBPACK_IMPORTED_MODULE_9__.SpeechT5Processor),
18355
+ /* harmony export */ PaliGemmaProcessor: () => (/* reexport safe */ _paligemma_processing_paligemma_js__WEBPACK_IMPORTED_MODULE_6__.PaliGemmaProcessor),
18356
+ /* harmony export */ PyAnnoteProcessor: () => (/* reexport safe */ _pyannote_processing_pyannote_js__WEBPACK_IMPORTED_MODULE_7__.PyAnnoteProcessor),
18357
+ /* harmony export */ Qwen2VLProcessor: () => (/* reexport safe */ _qwen2_vl_processing_qwen2_vl_js__WEBPACK_IMPORTED_MODULE_8__.Qwen2VLProcessor),
18358
+ /* harmony export */ SamProcessor: () => (/* reexport safe */ _sam_processing_sam_js__WEBPACK_IMPORTED_MODULE_9__.SamProcessor),
18359
+ /* harmony export */ SpeechT5Processor: () => (/* reexport safe */ _speecht5_processing_speecht5_js__WEBPACK_IMPORTED_MODULE_10__.SpeechT5Processor),
18203
18360
  /* harmony export */ VLChatProcessor: () => (/* reexport safe */ _janus_processing_janus_js__WEBPACK_IMPORTED_MODULE_3__.VLChatProcessor),
18204
- /* harmony export */ Wav2Vec2ProcessorWithLM: () => (/* reexport safe */ _wav2vec2_processing_wav2vec2_js__WEBPACK_IMPORTED_MODULE_10__.Wav2Vec2ProcessorWithLM),
18205
- /* harmony export */ WhisperProcessor: () => (/* reexport safe */ _whisper_processing_whisper_js__WEBPACK_IMPORTED_MODULE_11__.WhisperProcessor)
18361
+ /* harmony export */ Wav2Vec2ProcessorWithLM: () => (/* reexport safe */ _wav2vec2_processing_wav2vec2_js__WEBPACK_IMPORTED_MODULE_11__.Wav2Vec2ProcessorWithLM),
18362
+ /* harmony export */ WhisperProcessor: () => (/* reexport safe */ _whisper_processing_whisper_js__WEBPACK_IMPORTED_MODULE_12__.WhisperProcessor)
18206
18363
  /* harmony export */ });
18207
18364
  /* harmony import */ var _florence2_processing_florence2_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./florence2/processing_florence2.js */ "./src/models/florence2/processing_florence2.js");
18208
18365
  /* harmony import */ var _mgp_str_processing_mgp_str_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mgp_str/processing_mgp_str.js */ "./src/models/mgp_str/processing_mgp_str.js");
@@ -18210,12 +18367,14 @@ __webpack_require__.r(__webpack_exports__);
18210
18367
  /* harmony import */ var _janus_processing_janus_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./janus/processing_janus.js */ "./src/models/janus/processing_janus.js");
18211
18368
  /* harmony import */ var _jina_clip_processing_jina_clip_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./jina_clip/processing_jina_clip.js */ "./src/models/jina_clip/processing_jina_clip.js");
18212
18369
  /* harmony import */ var _owlvit_processing_owlvit_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./owlvit/processing_owlvit.js */ "./src/models/owlvit/processing_owlvit.js");
18213
- /* harmony import */ var _pyannote_processing_pyannote_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./pyannote/processing_pyannote.js */ "./src/models/pyannote/processing_pyannote.js");
18214
- /* harmony import */ var _qwen2_vl_processing_qwen2_vl_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./qwen2_vl/processing_qwen2_vl.js */ "./src/models/qwen2_vl/processing_qwen2_vl.js");
18215
- /* harmony import */ var _sam_processing_sam_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sam/processing_sam.js */ "./src/models/sam/processing_sam.js");
18216
- /* harmony import */ var _speecht5_processing_speecht5_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./speecht5/processing_speecht5.js */ "./src/models/speecht5/processing_speecht5.js");
18217
- /* harmony import */ var _wav2vec2_processing_wav2vec2_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./wav2vec2/processing_wav2vec2.js */ "./src/models/wav2vec2/processing_wav2vec2.js");
18218
- /* harmony import */ var _whisper_processing_whisper_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./whisper/processing_whisper.js */ "./src/models/whisper/processing_whisper.js");
18370
+ /* harmony import */ var _paligemma_processing_paligemma_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./paligemma/processing_paligemma.js */ "./src/models/paligemma/processing_paligemma.js");
18371
+ /* harmony import */ var _pyannote_processing_pyannote_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./pyannote/processing_pyannote.js */ "./src/models/pyannote/processing_pyannote.js");
18372
+ /* harmony import */ var _qwen2_vl_processing_qwen2_vl_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./qwen2_vl/processing_qwen2_vl.js */ "./src/models/qwen2_vl/processing_qwen2_vl.js");
18373
+ /* harmony import */ var _sam_processing_sam_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./sam/processing_sam.js */ "./src/models/sam/processing_sam.js");
18374
+ /* harmony import */ var _speecht5_processing_speecht5_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./speecht5/processing_speecht5.js */ "./src/models/speecht5/processing_speecht5.js");
18375
+ /* harmony import */ var _wav2vec2_processing_wav2vec2_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./wav2vec2/processing_wav2vec2.js */ "./src/models/wav2vec2/processing_wav2vec2.js");
18376
+ /* harmony import */ var _whisper_processing_whisper_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./whisper/processing_whisper.js */ "./src/models/whisper/processing_whisper.js");
18377
+
18219
18378
 
18220
18379
 
18221
18380
 
@@ -26133,6 +26292,12 @@ class PreTrainedTokenizer extends _utils_generic_js__WEBPACK_IMPORTED_MODULE_0__
26133
26292
  this.unk_token = this.getToken('unk_token');
26134
26293
  this.unk_token_id = this.model.tokens_to_ids.get(this.unk_token);
26135
26294
 
26295
+ this.bos_token = this.getToken('bos_token');
26296
+ this.bos_token_id = this.model.tokens_to_ids.get(this.bos_token);
26297
+
26298
+ this.eos_token = this.getToken('eos_token');
26299
+ this.eos_token_id = this.model.tokens_to_ids.get(this.eos_token);
26300
+
26136
26301
  this.model_max_length = tokenizerConfig.model_max_length;
26137
26302
 
26138
26303
  /** @type {boolean} Whether or not to strip the text when tokenizing (removing excess spaces before and after the string). */
@@ -27105,6 +27270,11 @@ class WhisperTokenizer extends PreTrainedTokenizer {
27105
27270
  let chunk = new_chunk();
27106
27271
  let time_offset = 0.0;
27107
27272
  const timestamp_begin = this.timestamp_begin;
27273
+ // Whisper timestamp tokens start from 0.00 and go to timestamp 30.00 in 0.02 increments.
27274
+ // We can calculate the last time stamp token as timestamp_begin plus the number of tokens
27275
+ // tokens from 0.00 to 30.00 which is 1500.
27276
+ const total_timestamp_tokens = 1500; // (30.00 - 0.00) / 0.02
27277
+ const timestamp_end = timestamp_begin + total_timestamp_tokens;
27108
27278
 
27109
27279
  let previous_tokens = [];
27110
27280
  let previous_token_timestamps = [];
@@ -27192,7 +27362,7 @@ class WhisperTokenizer extends PreTrainedTokenizer {
27192
27362
  } else {
27193
27363
  // 2/ This is a regular special token, ignoring it
27194
27364
  }
27195
- } else if (token >= timestamp_begin) {
27365
+ } else if (token >= timestamp_begin && token <= timestamp_end) {
27196
27366
  // 3/ Timestamp token
27197
27367
  const time = (token - timestamp_begin) * time_precision + time_offset;
27198
27368
  const rounded_time = (0,_utils_maths_js__WEBPACK_IMPORTED_MODULE_3__.round)(time, 2);
@@ -28684,15 +28854,45 @@ __webpack_require__.r(__webpack_exports__);
28684
28854
  */
28685
28855
 
28686
28856
  /**
28687
- * @typedef {Object} ProgressInfo
28688
- * @property {'initiate' | 'download' | 'progress' | 'done'} status The status of the progress item.
28689
- * @property {string} name This can be either:
28690
- * - a string, the *model id* of a model repo on huggingface.co.
28691
- * - a path to a *directory* potentially containing the file.
28692
- * @property {string} file The name of the file
28693
- * @property {number} [progress] A number between 0 and 100. Only available for the 'progress' status.
28694
- * @property {number} [loaded] The number of bytes loaded. Only available for the 'progress' status.
28695
- * @property {number} [total] The total number of bytes to be loaded. Only available for the 'progress' status.
28857
+ * @typedef {Object} InitiateProgressInfo
28858
+ * @property {'initiate'} status
28859
+ * @property {string} name The model id or directory path.
28860
+ * @property {string} file The name of the file.
28861
+ */
28862
+
28863
+ /**
28864
+ * @typedef {Object} DownloadProgressInfo
28865
+ * @property {'download'} status
28866
+ * @property {string} name The model id or directory path.
28867
+ * @property {string} file The name of the file.
28868
+ */
28869
+
28870
+ /**
28871
+ * @typedef {Object} ProgressStatusInfo
28872
+ * @property {'progress'} status
28873
+ * @property {string} name The model id or directory path.
28874
+ * @property {string} file The name of the file.
28875
+ * @property {number} progress A number between 0 and 100.
28876
+ * @property {number} loaded The number of bytes loaded.
28877
+ * @property {number} total The total number of bytes to be loaded.
28878
+ */
28879
+
28880
+ /**
28881
+ * @typedef {Object} DoneProgressInfo
28882
+ * @property {'done'} status
28883
+ * @property {string} name The model id or directory path.
28884
+ * @property {string} file The name of the file.
28885
+ */
28886
+
28887
+ /**
28888
+ * @typedef {Object} ReadyProgressInfo
28889
+ * @property {'ready'} status
28890
+ * @property {string} task The loaded task.
28891
+ * @property {string} model The loaded model.
28892
+ */
28893
+
28894
+ /**
28895
+ * @typedef {InitiateProgressInfo | DownloadProgressInfo | ProgressStatusInfo | DoneProgressInfo | ReadyProgressInfo} ProgressInfo
28696
28896
  */
28697
28897
 
28698
28898
  /**
@@ -30035,13 +30235,6 @@ async function getModelFile(path_or_repo_id, filename, fatal = true, options = {
30035
30235
  file: filename
30036
30236
  })
30037
30237
 
30038
- /** @type {import('./core.js').ProgressInfo} */
30039
- const progressInfo = {
30040
- status: 'progress',
30041
- name: path_or_repo_id,
30042
- file: filename
30043
- }
30044
-
30045
30238
  /** @type {Uint8Array} */
30046
30239
  let buffer;
30047
30240
 
@@ -30061,7 +30254,9 @@ async function getModelFile(path_or_repo_id, filename, fatal = true, options = {
30061
30254
 
30062
30255
  // For completeness, we still fire the final progress callback
30063
30256
  (0,_core_js__WEBPACK_IMPORTED_MODULE_3__.dispatchCallback)(options.progress_callback, {
30064
- ...progressInfo,
30257
+ status: 'progress',
30258
+ name: path_or_repo_id,
30259
+ file: filename,
30065
30260
  progress: 100,
30066
30261
  loaded: buffer.length,
30067
30262
  total: buffer.length,
@@ -30069,7 +30264,9 @@ async function getModelFile(path_or_repo_id, filename, fatal = true, options = {
30069
30264
  } else {
30070
30265
  buffer = await readResponse(response, data => {
30071
30266
  (0,_core_js__WEBPACK_IMPORTED_MODULE_3__.dispatchCallback)(options.progress_callback, {
30072
- ...progressInfo,
30267
+ status: 'progress',
30268
+ name: path_or_repo_id,
30269
+ file: filename,
30073
30270
  ...data,
30074
30271
  })
30075
30272
  })
@@ -30126,12 +30323,11 @@ async function getModelJSON(modelPath, fileName, fatal = true, options = {}) {
30126
30323
 
30127
30324
  return JSON.parse(jsonData);
30128
30325
  }
30129
-
30130
30326
  /**
30131
30327
  * Read and track progress when reading a Response object
30132
30328
  *
30133
- * @param {any} response The Response object to read
30134
- * @param {function} progress_callback The function to call with progress updates
30329
+ * @param {Response|FileResponse} response The Response object to read
30330
+ * @param {(data: {progress: number, loaded: number, total: number}) => void} progress_callback The function to call with progress updates
30135
30331
  * @returns {Promise<Uint8Array>} A Promise that resolves with the Uint8Array buffer
30136
30332
  */
30137
30333
  async function readResponse(response, progress_callback) {
@@ -30528,6 +30724,46 @@ class RawImage {
30528
30724
  return this._update(newData, this.width, this.height, 4);
30529
30725
  }
30530
30726
 
30727
+ /**
30728
+ * Apply an alpha mask to the image. Operates in place.
30729
+ * @param {RawImage} mask The mask to apply. It should have a single channel.
30730
+ * @returns {RawImage} The masked image.
30731
+ * @throws {Error} If the mask is not the same size as the image.
30732
+ * @throws {Error} If the image does not have 4 channels.
30733
+ * @throws {Error} If the mask is not a single channel.
30734
+ */
30735
+ putAlpha(mask) {
30736
+ if (mask.width !== this.width || mask.height !== this.height) {
30737
+ throw new Error(`Expected mask size to be ${this.width}x${this.height}, but got ${mask.width}x${mask.height}`);
30738
+ }
30739
+ if (mask.channels !== 1) {
30740
+ throw new Error(`Expected mask to have 1 channel, but got ${mask.channels}`);
30741
+ }
30742
+
30743
+ const this_data = this.data;
30744
+ const mask_data = mask.data;
30745
+ const num_pixels = this.width * this.height;
30746
+ if (this.channels === 3) {
30747
+ // Convert to RGBA and simultaneously apply mask to alpha channel
30748
+ const newData = new Uint8ClampedArray(num_pixels * 4);
30749
+ for (let i = 0, in_offset = 0, out_offset = 0; i < num_pixels; ++i) {
30750
+ newData[out_offset++] = this_data[in_offset++];
30751
+ newData[out_offset++] = this_data[in_offset++];
30752
+ newData[out_offset++] = this_data[in_offset++];
30753
+ newData[out_offset++] = mask_data[i];
30754
+ }
30755
+ return this._update(newData, this.width, this.height, 4);
30756
+
30757
+ } else if (this.channels === 4) {
30758
+ // Apply mask to alpha channel in place
30759
+ for (let i = 0; i < num_pixels; ++i) {
30760
+ this_data[4 * i + 3] = mask_data[i];
30761
+ }
30762
+ return this;
30763
+ }
30764
+ throw new Error(`Expected image to have 3 or 4 channels, but got ${this.channels}`);
30765
+ }
30766
+
30531
30767
  /**
30532
30768
  * Resize the image to the given dimensions. This method uses the canvas API to perform the resizing.
30533
30769
  * @param {number} width The width of the new image. `null` or `-1` will preserve the aspect ratio.
@@ -33694,7 +33930,7 @@ function quantize_embeddings(tensor, precision) {
33694
33930
  /******/
33695
33931
  /************************************************************************/
33696
33932
  var __webpack_exports__ = {};
33697
- // This entry need to be wrapped in an IIFE because it need to be in strict mode.
33933
+ // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
33698
33934
  (() => {
33699
33935
  "use strict";
33700
33936
  /*!*****************************!*\
@@ -33963,6 +34199,9 @@ __webpack_require__.r(__webpack_exports__);
33963
34199
  /* harmony export */ HubertForSequenceClassification: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.HubertForSequenceClassification),
33964
34200
  /* harmony export */ HubertModel: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.HubertModel),
33965
34201
  /* harmony export */ HubertPreTrainedModel: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.HubertPreTrainedModel),
34202
+ /* harmony export */ IJepaForImageClassification: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.IJepaForImageClassification),
34203
+ /* harmony export */ IJepaModel: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.IJepaModel),
34204
+ /* harmony export */ IJepaPreTrainedModel: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.IJepaPreTrainedModel),
33966
34205
  /* harmony export */ Idefics3ForConditionalGeneration: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.Idefics3ForConditionalGeneration),
33967
34206
  /* harmony export */ Idefics3ImageProcessor: () => (/* reexport safe */ _models_image_processors_js__WEBPACK_IMPORTED_MODULE_13__.Idefics3ImageProcessor),
33968
34207
  /* harmony export */ Idefics3PreTrainedModel: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.Idefics3PreTrainedModel),
@@ -34101,6 +34340,9 @@ __webpack_require__.r(__webpack_exports__);
34101
34340
  /* harmony export */ OPTModel: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.OPTModel),
34102
34341
  /* harmony export */ OPTPreTrainedModel: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.OPTPreTrainedModel),
34103
34342
  /* harmony export */ ObjectDetectionPipeline: () => (/* reexport safe */ _pipelines_js__WEBPACK_IMPORTED_MODULE_1__.ObjectDetectionPipeline),
34343
+ /* harmony export */ Olmo2ForCausalLM: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.Olmo2ForCausalLM),
34344
+ /* harmony export */ Olmo2Model: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.Olmo2Model),
34345
+ /* harmony export */ Olmo2PreTrainedModel: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.Olmo2PreTrainedModel),
34104
34346
  /* harmony export */ OlmoForCausalLM: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.OlmoForCausalLM),
34105
34347
  /* harmony export */ OlmoModel: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.OlmoModel),
34106
34348
  /* harmony export */ OlmoPreTrainedModel: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.OlmoPreTrainedModel),
@@ -34117,6 +34359,9 @@ __webpack_require__.r(__webpack_exports__);
34117
34359
  /* harmony export */ Owlv2ImageProcessor: () => (/* reexport safe */ _models_image_processors_js__WEBPACK_IMPORTED_MODULE_13__.Owlv2ImageProcessor),
34118
34360
  /* harmony export */ Owlv2Model: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.Owlv2Model),
34119
34361
  /* harmony export */ Owlv2PreTrainedModel: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.Owlv2PreTrainedModel),
34362
+ /* harmony export */ PaliGemmaForConditionalGeneration: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.PaliGemmaForConditionalGeneration),
34363
+ /* harmony export */ PaliGemmaPreTrainedModel: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.PaliGemmaPreTrainedModel),
34364
+ /* harmony export */ PaliGemmaProcessor: () => (/* reexport safe */ _models_processors_js__WEBPACK_IMPORTED_MODULE_16__.PaliGemmaProcessor),
34120
34365
  /* harmony export */ PatchTSMixerForPrediction: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.PatchTSMixerForPrediction),
34121
34366
  /* harmony export */ PatchTSMixerModel: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.PatchTSMixerModel),
34122
34367
  /* harmony export */ PatchTSMixerPreTrainedModel: () => (/* reexport safe */ _models_js__WEBPACK_IMPORTED_MODULE_2__.PatchTSMixerPreTrainedModel),
@@ -34452,7 +34697,7 @@ __webpack_require__.r(__webpack_exports__);
34452
34697
  })();
34453
34698
 
34454
34699
  var __webpack_export_target__ = exports;
34455
- for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
34700
+ for(var __webpack_i__ in __webpack_exports__) __webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
34456
34701
  if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
34457
34702
  /******/ })()
34458
34703
  ;