@min-pack/tfjs-node 2.17.1 → 3.8.1-patch.0
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 +4 -2
- package/addon-node_modules/onnxruntime-node/bin/{napi-v3/linux/x64/libonnxruntime.so.1.14.0 → napi-v6/linux/arm64/libonnxruntime.so.1} +0 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v6/linux/arm64/onnxruntime_binding.node +0 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v6/linux/x64/libonnxruntime.so.1 +0 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v6/linux/x64/onnxruntime_binding.node +0 -0
- package/index.d.ts +2 -0
- package/index.js +7102 -3371
- package/package.json +1 -10
- package/tfjs-types/backends/onnx.d.ts +37 -0
- package/tfjs-types/base/feature_extraction_utils.d.ts +41 -0
- package/tfjs-types/base/image_processors_utils.d.ts +332 -0
- package/tfjs-types/base/processing_utils.d.ts +89 -0
- package/tfjs-types/configs.d.ts +93 -0
- package/tfjs-types/env.d.ts +112 -0
- package/tfjs-types/generation/configuration_utils.d.ts +326 -0
- package/tfjs-types/generation/logits_process.d.ts +364 -0
- package/tfjs-types/generation/logits_sampler.d.ts +51 -0
- package/tfjs-types/generation/parameters.d.ts +47 -0
- package/tfjs-types/generation/stopping_criteria.d.ts +81 -0
- package/tfjs-types/generation/streamers.d.ts +88 -0
- package/tfjs-types/models/audio_spectrogram_transformer/feature_extraction_audio_spectrogram_transformer.d.ts +25 -0
- package/tfjs-types/models/auto/feature_extraction_auto.d.ts +5 -0
- package/tfjs-types/models/auto/image_processing_auto.d.ts +5 -0
- package/tfjs-types/models/auto/processing_auto.d.ts +39 -0
- package/tfjs-types/models/beit/image_processing_beit.d.ts +4 -0
- package/tfjs-types/models/bit/image_processing_bit.d.ts +4 -0
- package/tfjs-types/models/chinese_clip/image_processing_chinese_clip.d.ts +4 -0
- package/tfjs-types/models/clap/feature_extraction_clap.d.ts +57 -0
- package/tfjs-types/models/clip/image_processing_clip.d.ts +6 -0
- package/tfjs-types/models/convnext/image_processing_convnext.d.ts +12 -0
- package/tfjs-types/models/dac/feature_extraction_dac.d.ts +4 -0
- package/tfjs-types/models/deit/image_processing_deit.d.ts +6 -0
- package/tfjs-types/models/detr/image_processing_detr.d.ts +42 -0
- package/tfjs-types/models/dinov3_vit/image_processing_dinov3_vit.d.ts +4 -0
- package/tfjs-types/models/donut/image_processing_donut.d.ts +7 -0
- package/tfjs-types/models/dpt/image_processing_dpt.d.ts +6 -0
- package/tfjs-types/models/efficientnet/image_processing_efficientnet.d.ts +6 -0
- package/tfjs-types/models/encodec/feature_extraction_encodec.d.ts +13 -0
- package/tfjs-types/models/feature_extractors.d.ts +16 -0
- package/tfjs-types/models/florence2/processing_florence2.d.ts +39 -0
- package/tfjs-types/models/gemma3n/feature_extraction_gemma3n.d.ts +35 -0
- package/tfjs-types/models/gemma3n/processing_gemma3n.d.ts +31 -0
- package/tfjs-types/models/glpn/image_processing_glpn.d.ts +4 -0
- package/tfjs-types/models/grounding_dino/image_processing_grounding_dino.d.ts +20 -0
- package/tfjs-types/models/grounding_dino/processing_grounding_dino.d.ts +27 -0
- package/tfjs-types/models/idefics3/image_processing_idefics3.d.ts +40 -0
- package/tfjs-types/models/idefics3/processing_idefics3.d.ts +19 -0
- package/tfjs-types/models/image_processors.d.ts +44 -0
- package/tfjs-types/models/janus/image_processing_janus.d.ts +7 -0
- package/tfjs-types/models/janus/processing_janus.d.ts +77 -0
- package/tfjs-types/models/jina_clip/image_processing_jina_clip.d.ts +5 -0
- package/tfjs-types/models/jina_clip/processing_jina_clip.d.ts +9 -0
- package/tfjs-types/models/llava/processing_llava.d.ts +12 -0
- package/tfjs-types/models/llava_onevision/image_processing_llava_onevision.d.ts +4 -0
- package/tfjs-types/models/mask2former/image_processing_mask2former.d.ts +4 -0
- package/tfjs-types/models/maskformer/image_processing_maskformer.d.ts +22 -0
- package/tfjs-types/models/mgp_str/processing_mgp_str.d.ts +64 -0
- package/tfjs-types/models/mobilenet_v1/image_processing_mobilenet_v1.d.ts +6 -0
- package/tfjs-types/models/mobilenet_v2/image_processing_mobilenet_v2.d.ts +6 -0
- package/tfjs-types/models/mobilenet_v3/image_processing_mobilenet_v3.d.ts +6 -0
- package/tfjs-types/models/mobilenet_v4/image_processing_mobilenet_v4.d.ts +6 -0
- package/tfjs-types/models/mobilevit/image_processing_mobilevit.d.ts +6 -0
- package/tfjs-types/models/moonshine/feature_extraction_moonshine.d.ts +13 -0
- package/tfjs-types/models/moonshine/processing_moonshine.d.ts +17 -0
- package/tfjs-types/models/nougat/image_processing_nougat.d.ts +4 -0
- package/tfjs-types/models/owlv2/image_processing_owlv2.d.ts +4 -0
- package/tfjs-types/models/owlvit/image_processing_owlvit.d.ts +10 -0
- package/tfjs-types/models/owlvit/processing_owlvit.d.ts +8 -0
- package/tfjs-types/models/paligemma/processing_paligemma.d.ts +12 -0
- package/tfjs-types/models/parakeet/feature_extraction_parakeet.d.ts +22 -0
- package/tfjs-types/models/phi3_v/image_processing_phi3_v.d.ts +17 -0
- package/tfjs-types/models/phi3_v/processing_phi3_v.d.ts +21 -0
- package/tfjs-types/models/pixtral/image_processing_pixtral.d.ts +4 -0
- package/tfjs-types/models/pixtral/processing_pixtral.d.ts +12 -0
- package/tfjs-types/models/processors.d.ts +25 -0
- package/tfjs-types/models/pvt/image_processing_pvt.d.ts +4 -0
- package/tfjs-types/models/pyannote/feature_extraction_pyannote.d.ts +31 -0
- package/tfjs-types/models/pyannote/processing_pyannote.d.ts +19 -0
- package/tfjs-types/models/qwen2_vl/image_processing_qwen2_vl.d.ts +11 -0
- package/tfjs-types/models/qwen2_vl/processing_qwen2_vl.d.ts +17 -0
- package/tfjs-types/models/rt_detr/image_processing_rt_detr.d.ts +8 -0
- package/tfjs-types/models/sam/image_processing_sam.d.ts +103 -0
- package/tfjs-types/models/sam/processing_sam.d.ts +9 -0
- package/tfjs-types/models/sam2/image_processing_sam2.d.ts +2 -0
- package/tfjs-types/models/sam2/processing_sam2.d.ts +6 -0
- package/tfjs-types/models/sam3/image_processing_sam3.d.ts +2 -0
- package/tfjs-types/models/sapiens/image_processing_sapiens.d.ts +10 -0
- package/tfjs-types/models/seamless_m4t/feature_extraction_seamless_m4t.d.ts +34 -0
- package/tfjs-types/models/segformer/image_processing_segformer.d.ts +10 -0
- package/tfjs-types/models/siglip/image_processing_siglip.d.ts +4 -0
- package/tfjs-types/models/smolvlm/image_processing_smolvlm.d.ts +2 -0
- package/tfjs-types/models/smolvlm/processing_smolvlm.d.ts +2 -0
- package/tfjs-types/models/snac/feature_extraction_snac.d.ts +4 -0
- package/tfjs-types/models/speecht5/feature_extraction_speecht5.d.ts +4 -0
- package/tfjs-types/models/speecht5/processing_speecht5.d.ts +14 -0
- package/tfjs-types/models/swin2sr/image_processing_swin2sr.d.ts +5 -0
- package/tfjs-types/models/ultravox/processing_ultravox.d.ts +16 -0
- package/tfjs-types/models/vit/image_processing_vit.d.ts +6 -0
- package/tfjs-types/models/vitmatte/image_processing_vitmatte.d.ts +12 -0
- package/tfjs-types/models/vitpose/image_processing_vitpose.d.ts +26 -0
- package/tfjs-types/models/voxtral/processing_voxtral.d.ts +16 -0
- package/tfjs-types/models/wav2vec2/feature_extraction_wav2vec2.d.ts +19 -0
- package/tfjs-types/models/wav2vec2/processing_wav2vec2.d.ts +14 -0
- package/tfjs-types/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.d.ts +14 -0
- package/tfjs-types/models/wespeaker/feature_extraction_wespeaker.d.ts +23 -0
- package/tfjs-types/models/whisper/common_whisper.d.ts +8 -0
- package/tfjs-types/models/whisper/feature_extraction_whisper.d.ts +23 -0
- package/tfjs-types/models/whisper/generation_whisper.d.ts +76 -0
- package/tfjs-types/models/whisper/processing_whisper.d.ts +17 -0
- package/tfjs-types/models/yolos/image_processing_yolos.d.ts +10 -0
- package/tfjs-types/models.d.ts +4396 -0
- package/tfjs-types/ops/registry.d.ts +13 -0
- package/tfjs-types/pipelines.d.ts +2433 -0
- package/tfjs-types/tokenizers.d.ts +1002 -0
- package/tfjs-types/transformers.d.ts +27 -0
- package/tfjs-types/utils/audio.d.ts +160 -0
- package/tfjs-types/utils/constants.d.ts +8 -0
- package/tfjs-types/utils/core.d.ts +231 -0
- package/tfjs-types/utils/data-structures.d.ts +294 -0
- package/tfjs-types/utils/devices.d.ts +18 -0
- package/tfjs-types/utils/dtypes.d.ts +20 -0
- package/tfjs-types/utils/generic.d.ts +11 -0
- package/tfjs-types/utils/hub.d.ts +175 -0
- package/tfjs-types/utils/image.d.ts +141 -0
- package/tfjs-types/utils/maths.d.ts +282 -0
- package/tfjs-types/utils/tensor.d.ts +490 -0
- package/tfjs-types/utils/video.d.ts +37 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v3/linux/arm64/libonnxruntime.so.1.14.0 +0 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v3/linux/arm64/onnxruntime_binding.node +0 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v3/linux/x64/onnxruntime_binding.node +0 -0
package/package.json
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@min-pack/tfjs-node",
|
|
3
|
-
"description": "Latest transformers.js with linux x64/arm64 binary preloaded for Node.js usage",
|
|
4
|
-
"main": "index.js",
|
|
5
|
-
"config": {
|
|
6
|
-
"TRANSFORMERS_JS_VERSION": "2.17.1"
|
|
7
|
-
},
|
|
8
|
-
"version": "2.17.1",
|
|
9
|
-
"license": "Apache-2.0"
|
|
10
|
-
}
|
|
1
|
+
{"name":"@min-pack/tfjs-node","version":"3.8.1-patch.0","description":"Latest transformers.js with linux x64/arm64 binary preloaded for Node.js usage","main":"index.js","config":{"TRANSFORMERS_JS_VERSION":"3.8.1","ONNXRUNTIME_NODE_VERSION":"1.24.3"},"license":"Apache-2.0"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map a device to the execution providers to use for the given device.
|
|
3
|
+
* @param {import("../utils/devices.js").DeviceType|"auto"|null} [device=null] (Optional) The device to run the inference on.
|
|
4
|
+
* @returns {ONNXExecutionProviders[]} The execution providers to use for the given device.
|
|
5
|
+
*/
|
|
6
|
+
export function deviceToExecutionProviders(device?: import("../utils/devices.js").DeviceType | "auto" | null): ONNXExecutionProviders[];
|
|
7
|
+
/**
|
|
8
|
+
* Create an ONNX inference session.
|
|
9
|
+
* @param {Uint8Array|string} buffer_or_path The ONNX model buffer or path.
|
|
10
|
+
* @param {import('onnxruntime-common').InferenceSession.SessionOptions} session_options ONNX inference session options.
|
|
11
|
+
* @param {Object} session_config ONNX inference session configuration.
|
|
12
|
+
* @returns {Promise<import('onnxruntime-common').InferenceSession & { config: Object}>} The ONNX inference session.
|
|
13
|
+
*/
|
|
14
|
+
export function createInferenceSession(buffer_or_path: Uint8Array | string, session_options: import("onnxruntime-common").InferenceSession.SessionOptions, session_config: any): Promise<import("onnxruntime-common").InferenceSession & {
|
|
15
|
+
config: any;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Run an inference session.
|
|
19
|
+
* @param {import('onnxruntime-common').InferenceSession} session The ONNX inference session.
|
|
20
|
+
* @param {Record<string, import('onnxruntime-common').Tensor>} ortFeed The input tensors.
|
|
21
|
+
* @returns {Promise<Record<string, import('onnxruntime-common').Tensor>>} The output tensors.
|
|
22
|
+
*/
|
|
23
|
+
export function runInferenceSession(session: import("onnxruntime-common").InferenceSession, ortFeed: Record<string, import("onnxruntime-common").Tensor>): Promise<Record<string, import("onnxruntime-common").Tensor>>;
|
|
24
|
+
/**
|
|
25
|
+
* Check if an object is an ONNX tensor.
|
|
26
|
+
* @param {any} x The object to check
|
|
27
|
+
* @returns {boolean} Whether the object is an ONNX tensor.
|
|
28
|
+
*/
|
|
29
|
+
export function isONNXTensor(x: any): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Check if ONNX's WASM backend is being proxied.
|
|
32
|
+
* @returns {boolean} Whether ONNX's WASM backend is being proxied.
|
|
33
|
+
*/
|
|
34
|
+
export function isONNXProxy(): boolean;
|
|
35
|
+
export { Tensor } from "onnxruntime-common";
|
|
36
|
+
export type ONNXExecutionProviders = import("onnxruntime-common").InferenceSession.ExecutionProviderConfig;
|
|
37
|
+
//# sourceMappingURL=onnx.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function to validate audio inputs.
|
|
3
|
+
* @param {any} audio The audio data.
|
|
4
|
+
* @param {string} feature_extractor The name of the feature extractor.
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
7
|
+
export function validate_audio_inputs(audio: any, feature_extractor: string): void;
|
|
8
|
+
declare const FeatureExtractor_base: new () => {
|
|
9
|
+
(...args: any[]): any;
|
|
10
|
+
_call(...args: any[]): any;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Base class for feature extractors.
|
|
14
|
+
*/
|
|
15
|
+
export class FeatureExtractor extends FeatureExtractor_base {
|
|
16
|
+
/**
|
|
17
|
+
* Instantiate one of the feature extractor classes of the library from a pretrained model.
|
|
18
|
+
*
|
|
19
|
+
* The feature extractor class to instantiate is selected based on the `feature_extractor_type` property of
|
|
20
|
+
* the config object (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible)
|
|
21
|
+
*
|
|
22
|
+
* @param {string} pretrained_model_name_or_path The name or path of the pretrained model. Can be either:
|
|
23
|
+
* - A string, the *model id* of a pretrained feature_extractor hosted inside a model repo on huggingface.co.
|
|
24
|
+
* Valid model ids can be located at the root-level, like `bert-base-uncased`, or namespaced under a
|
|
25
|
+
* user or organization name, like `dbmdz/bert-base-german-cased`.
|
|
26
|
+
* - A path to a *directory* containing feature_extractor files, e.g., `./my_model_directory/`.
|
|
27
|
+
* @param {import('../utils/hub.js').PretrainedOptions} options Additional options for loading the feature_extractor.
|
|
28
|
+
*
|
|
29
|
+
* @returns {Promise<FeatureExtractor>} A new instance of the Feature Extractor class.
|
|
30
|
+
*/
|
|
31
|
+
static from_pretrained(pretrained_model_name_or_path: string, options?: import("../utils/hub.js").PretrainedOptions): Promise<FeatureExtractor>;
|
|
32
|
+
/**
|
|
33
|
+
* Constructs a new FeatureExtractor instance.
|
|
34
|
+
*
|
|
35
|
+
* @param {Object} config The configuration for the feature extractor.
|
|
36
|
+
*/
|
|
37
|
+
constructor(config: any);
|
|
38
|
+
config: any;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=feature_extraction_utils.d.ts.map
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts bounding boxes from center format to corners format.
|
|
3
|
+
*
|
|
4
|
+
* @param {number[]} arr The coordinate for the center of the box and its width, height dimensions (center_x, center_y, width, height)
|
|
5
|
+
* @returns {number[]} The coodinates for the top-left and bottom-right corners of the box (top_left_x, top_left_y, bottom_right_x, bottom_right_y)
|
|
6
|
+
*/
|
|
7
|
+
export function center_to_corners_format([centerX, centerY, width, height]: number[]): number[];
|
|
8
|
+
/**
|
|
9
|
+
* Post-processes the outputs of the model (for object detection).
|
|
10
|
+
* @param {Object} outputs The outputs of the model that must be post-processed
|
|
11
|
+
* @param {Tensor} outputs.logits The logits
|
|
12
|
+
* @param {Tensor} outputs.pred_boxes The predicted boxes.
|
|
13
|
+
* @param {number} [threshold=0.5] The threshold to use for the scores.
|
|
14
|
+
* @param {[number, number][]} [target_sizes=null] The sizes of the original images.
|
|
15
|
+
* @param {boolean} [is_zero_shot=false] Whether zero-shot object detection was performed.
|
|
16
|
+
* @return {Object[]} An array of objects containing the post-processed outputs.
|
|
17
|
+
*/
|
|
18
|
+
export function post_process_object_detection(outputs: {
|
|
19
|
+
logits: Tensor;
|
|
20
|
+
pred_boxes: Tensor;
|
|
21
|
+
}, threshold?: number, target_sizes?: [number, number][], is_zero_shot?: boolean): any[];
|
|
22
|
+
/**
|
|
23
|
+
* Post-processes the outputs of the model (for semantic segmentation).
|
|
24
|
+
* @param {*} outputs Raw outputs of the model.
|
|
25
|
+
* @param {[number, number][]} [target_sizes=null] List of tuples corresponding to the requested final size
|
|
26
|
+
* (height, width) of each prediction. If unset, predictions will not be resized.
|
|
27
|
+
* @returns {{segmentation: Tensor; labels: number[]}[]} The semantic segmentation maps.
|
|
28
|
+
*/
|
|
29
|
+
export function post_process_semantic_segmentation(outputs: any, target_sizes?: [number, number][]): {
|
|
30
|
+
segmentation: Tensor;
|
|
31
|
+
labels: number[];
|
|
32
|
+
}[];
|
|
33
|
+
/**
|
|
34
|
+
* Post-process the model output to generate the final panoptic segmentation.
|
|
35
|
+
* @param {*} outputs The model output to post process
|
|
36
|
+
* @param {number} [threshold=0.5] The probability score threshold to keep predicted instance masks.
|
|
37
|
+
* @param {number} [mask_threshold=0.5] Threshold to use when turning the predicted masks into binary values.
|
|
38
|
+
* @param {number} [overlap_mask_area_threshold=0.8] The overlap mask area threshold to merge or discard small disconnected parts within each binary instance mask.
|
|
39
|
+
* @param {Set<number>} [label_ids_to_fuse=null] The labels in this state will have all their instances be fused together.
|
|
40
|
+
* @param {[number, number][]} [target_sizes=null] The target sizes to resize the masks to.
|
|
41
|
+
* @returns {Array<{ segmentation: Tensor, segments_info: Array<{id: number, label_id: number, score: number}>}>}
|
|
42
|
+
*/
|
|
43
|
+
export function post_process_panoptic_segmentation(outputs: any, threshold?: number, mask_threshold?: number, overlap_mask_area_threshold?: number, label_ids_to_fuse?: Set<number>, target_sizes?: [number, number][]): Array<{
|
|
44
|
+
segmentation: Tensor;
|
|
45
|
+
segments_info: Array<{
|
|
46
|
+
id: number;
|
|
47
|
+
label_id: number;
|
|
48
|
+
score: number;
|
|
49
|
+
}>;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Post-processes the outputs of the model (for instance segmentation).
|
|
53
|
+
* @param {*} outputs Raw outputs of the model.
|
|
54
|
+
* @param {number} [threshold=0.5] The probability score threshold to keep predicted instance masks.
|
|
55
|
+
* @param {[number, number][]} [target_sizes=null] List of tuples corresponding to the requested final size
|
|
56
|
+
* (height, width) of each prediction. If unset, predictions will not be resized.
|
|
57
|
+
* @returns {Array<{ segmentation: Tensor, segments_info: Array<{id: number, label_id: number, score: number}>}>}
|
|
58
|
+
*/
|
|
59
|
+
export function post_process_instance_segmentation(outputs: any, threshold?: number, target_sizes?: [number, number][]): Array<{
|
|
60
|
+
segmentation: Tensor;
|
|
61
|
+
segments_info: Array<{
|
|
62
|
+
id: number;
|
|
63
|
+
label_id: number;
|
|
64
|
+
score: number;
|
|
65
|
+
}>;
|
|
66
|
+
}>;
|
|
67
|
+
declare const ImageProcessor_base: new () => {
|
|
68
|
+
(...args: any[]): any;
|
|
69
|
+
_call(...args: any[]): any;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* @typedef {Object} ImageProcessorConfig A configuration object used to create an image processor.
|
|
73
|
+
* @property {function} [progress_callback=null] If specified, this function will be called during model construction, to provide the user with progress updates.
|
|
74
|
+
* @property {number[]} [image_mean] The mean values for image normalization.
|
|
75
|
+
* @property {number[]} [image_std] The standard deviation values for image normalization.
|
|
76
|
+
* @property {boolean} [do_rescale] Whether to rescale the image pixel values to the [0,1] range.
|
|
77
|
+
* @property {number} [rescale_factor] The factor to use for rescaling the image pixel values.
|
|
78
|
+
* @property {boolean} [do_normalize] Whether to normalize the image pixel values.
|
|
79
|
+
* @property {boolean} [do_resize] Whether to resize the image.
|
|
80
|
+
* @property {number} [resample] What method to use for resampling.
|
|
81
|
+
* @property {number|Object} [size] The size to resize the image to.
|
|
82
|
+
* @property {number|Object} [image_size] The size to resize the image to (same as `size`).
|
|
83
|
+
* @property {boolean} [do_flip_channel_order=false] Whether to flip the color channels from RGB to BGR.
|
|
84
|
+
* Can be overridden by the `do_flip_channel_order` parameter in the `preprocess` method.
|
|
85
|
+
* @property {boolean} [do_center_crop] Whether to center crop the image to the specified `crop_size`.
|
|
86
|
+
* Can be overridden by `do_center_crop` in the `preprocess` method.
|
|
87
|
+
* @property {boolean} [do_thumbnail] Whether to resize the image using thumbnail method.
|
|
88
|
+
* @property {boolean} [keep_aspect_ratio] If `true`, the image is resized to the largest possible size such that the aspect ratio is preserved.
|
|
89
|
+
* Can be overidden by `keep_aspect_ratio` in `preprocess`.
|
|
90
|
+
* @property {number} [ensure_multiple_of] If `do_resize` is `true`, the image is resized to a size that is a multiple of this value.
|
|
91
|
+
* Can be overidden by `ensure_multiple_of` in `preprocess`.
|
|
92
|
+
*
|
|
93
|
+
* @property {number[]} [mean] The mean values for image normalization (same as `image_mean`).
|
|
94
|
+
* @property {number[]} [std] The standard deviation values for image normalization (same as `image_std`).
|
|
95
|
+
*/
|
|
96
|
+
export class ImageProcessor extends ImageProcessor_base {
|
|
97
|
+
/**
|
|
98
|
+
* Instantiate one of the processor classes of the library from a pretrained model.
|
|
99
|
+
*
|
|
100
|
+
* The processor class to instantiate is selected based on the `image_processor_type` (or `feature_extractor_type`; legacy)
|
|
101
|
+
* property of the config object (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible)
|
|
102
|
+
*
|
|
103
|
+
* @param {string} pretrained_model_name_or_path The name or path of the pretrained model. Can be either:
|
|
104
|
+
* - A string, the *model id* of a pretrained processor hosted inside a model repo on huggingface.co.
|
|
105
|
+
* Valid model ids can be located at the root-level, like `bert-base-uncased`, or namespaced under a
|
|
106
|
+
* user or organization name, like `dbmdz/bert-base-german-cased`.
|
|
107
|
+
* - A path to a *directory* containing processor files, e.g., `./my_model_directory/`.
|
|
108
|
+
* @param {import('../utils/hub.js').PretrainedOptions} options Additional options for loading the processor.
|
|
109
|
+
*
|
|
110
|
+
* @returns {Promise<ImageProcessor>} A new instance of the Processor class.
|
|
111
|
+
*/
|
|
112
|
+
static from_pretrained(pretrained_model_name_or_path: string, options?: import("../utils/hub.js").PretrainedOptions): Promise<ImageProcessor>;
|
|
113
|
+
/**
|
|
114
|
+
* Constructs a new `ImageProcessor`.
|
|
115
|
+
* @param {ImageProcessorConfig} config The configuration object.
|
|
116
|
+
*/
|
|
117
|
+
constructor(config: ImageProcessorConfig);
|
|
118
|
+
image_mean: number[];
|
|
119
|
+
image_std: number[];
|
|
120
|
+
resample: number;
|
|
121
|
+
do_rescale: boolean;
|
|
122
|
+
rescale_factor: number;
|
|
123
|
+
do_normalize: boolean;
|
|
124
|
+
do_thumbnail: boolean;
|
|
125
|
+
size: any;
|
|
126
|
+
do_resize: boolean;
|
|
127
|
+
size_divisibility: any;
|
|
128
|
+
do_center_crop: boolean;
|
|
129
|
+
crop_size: any;
|
|
130
|
+
do_convert_rgb: any;
|
|
131
|
+
do_crop_margin: any;
|
|
132
|
+
pad_size: any;
|
|
133
|
+
do_pad: any;
|
|
134
|
+
min_pixels: any;
|
|
135
|
+
max_pixels: any;
|
|
136
|
+
do_flip_channel_order: boolean;
|
|
137
|
+
config: ImageProcessorConfig;
|
|
138
|
+
/**
|
|
139
|
+
* Resize the image to make a thumbnail. The image is resized so that no dimension is larger than any
|
|
140
|
+
* corresponding dimension of the specified size.
|
|
141
|
+
* @param {RawImage} image The image to be resized.
|
|
142
|
+
* @param {{height:number, width:number}} size The size `{"height": h, "width": w}` to resize the image to.
|
|
143
|
+
* @param {string | 0 | 1 | 2 | 3 | 4 | 5} [resample=2] The resampling filter to use.
|
|
144
|
+
* @returns {Promise<RawImage>} The resized image.
|
|
145
|
+
*/
|
|
146
|
+
thumbnail(image: RawImage, size: {
|
|
147
|
+
height: number;
|
|
148
|
+
width: number;
|
|
149
|
+
}, resample?: string | 0 | 1 | 2 | 3 | 4 | 5): Promise<RawImage>;
|
|
150
|
+
/**
|
|
151
|
+
* Crops the margin of the image. Gray pixels are considered margin (i.e., pixels with a value below the threshold).
|
|
152
|
+
* @param {RawImage} image The image to be cropped.
|
|
153
|
+
* @param {number} gray_threshold Value below which pixels are considered to be gray.
|
|
154
|
+
* @returns {Promise<RawImage>} The cropped image.
|
|
155
|
+
*/
|
|
156
|
+
crop_margin(image: RawImage, gray_threshold?: number): Promise<RawImage>;
|
|
157
|
+
/**
|
|
158
|
+
* Pad the image by a certain amount.
|
|
159
|
+
* @param {Float32Array} pixelData The pixel data to pad.
|
|
160
|
+
* @param {number[]} imgDims The dimensions of the image (height, width, channels).
|
|
161
|
+
* @param {{width:number; height:number}|number|'square'} padSize The dimensions of the padded image.
|
|
162
|
+
* @param {Object} options The options for padding.
|
|
163
|
+
* @param {'constant'|'symmetric'} [options.mode='constant'] The type of padding to add.
|
|
164
|
+
* @param {boolean} [options.center=false] Whether to center the image.
|
|
165
|
+
* @param {number|number[]} [options.constant_values=0] The constant value to use for padding.
|
|
166
|
+
* @returns {[Float32Array, number[]]} The padded pixel data and image dimensions.
|
|
167
|
+
*/
|
|
168
|
+
pad_image(pixelData: Float32Array, imgDims: number[], padSize: {
|
|
169
|
+
width: number;
|
|
170
|
+
height: number;
|
|
171
|
+
} | number | "square", { mode, center, constant_values, }?: {
|
|
172
|
+
mode?: "constant" | "symmetric";
|
|
173
|
+
center?: boolean;
|
|
174
|
+
constant_values?: number | number[];
|
|
175
|
+
}): [Float32Array, number[]];
|
|
176
|
+
/**
|
|
177
|
+
* Rescale the image' pixel values by `this.rescale_factor`.
|
|
178
|
+
* @param {Float32Array} pixelData The pixel data to rescale.
|
|
179
|
+
* @returns {void}
|
|
180
|
+
*/
|
|
181
|
+
rescale(pixelData: Float32Array): void;
|
|
182
|
+
/**
|
|
183
|
+
* Find the target (width, height) dimension of the output image after
|
|
184
|
+
* resizing given the input image and the desired size.
|
|
185
|
+
* @param {RawImage} image The image to resize.
|
|
186
|
+
* @param {any} size The size to use for resizing the image.
|
|
187
|
+
* @returns {[number, number]} The target (width, height) dimension of the output image after resizing.
|
|
188
|
+
*/
|
|
189
|
+
get_resize_output_image_size(image: RawImage, size: any): [number, number];
|
|
190
|
+
/**
|
|
191
|
+
* Resizes the image.
|
|
192
|
+
* @param {RawImage} image The image to resize.
|
|
193
|
+
* @returns {Promise<RawImage>} The resized image.
|
|
194
|
+
*/
|
|
195
|
+
resize(image: RawImage): Promise<RawImage>;
|
|
196
|
+
/**
|
|
197
|
+
* @typedef {object} PreprocessedImage
|
|
198
|
+
* @property {HeightWidth} original_size The original size of the image.
|
|
199
|
+
* @property {HeightWidth} reshaped_input_size The reshaped input size of the image.
|
|
200
|
+
* @property {Tensor} pixel_values The pixel values of the preprocessed image.
|
|
201
|
+
*/
|
|
202
|
+
/**
|
|
203
|
+
* Preprocesses the given image.
|
|
204
|
+
*
|
|
205
|
+
* @param {RawImage} image The image to preprocess.
|
|
206
|
+
* @param {Object} overrides The overrides for the preprocessing options.
|
|
207
|
+
* @returns {Promise<PreprocessedImage>} The preprocessed image.
|
|
208
|
+
*/
|
|
209
|
+
preprocess(image: RawImage, { do_normalize, do_pad, do_convert_rgb, do_convert_grayscale, do_flip_channel_order, }?: any): Promise<{
|
|
210
|
+
/**
|
|
211
|
+
* The original size of the image.
|
|
212
|
+
*/
|
|
213
|
+
original_size: HeightWidth;
|
|
214
|
+
/**
|
|
215
|
+
* The reshaped input size of the image.
|
|
216
|
+
*/
|
|
217
|
+
reshaped_input_size: HeightWidth;
|
|
218
|
+
/**
|
|
219
|
+
* The pixel values of the preprocessed image.
|
|
220
|
+
*/
|
|
221
|
+
pixel_values: Tensor;
|
|
222
|
+
}>;
|
|
223
|
+
/**
|
|
224
|
+
* Calls the feature extraction process on an array of images,
|
|
225
|
+
* preprocesses each image, and concatenates the resulting
|
|
226
|
+
* features into a single Tensor.
|
|
227
|
+
* @param {RawImage[]} images The image(s) to extract features from.
|
|
228
|
+
* @param {...any} args Additional arguments.
|
|
229
|
+
* @returns {Promise<ImageProcessorResult>} An object containing the concatenated pixel values (and other metadata) of the preprocessed images.
|
|
230
|
+
*/
|
|
231
|
+
_call(images: RawImage[], ...args: any[]): Promise<ImageProcessorResult>;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Named tuple to indicate the order we are using is (height x width),
|
|
235
|
+
* even though the Graphics' industry standard is (width x height).
|
|
236
|
+
*/
|
|
237
|
+
export type HeightWidth = [height: number, width: number];
|
|
238
|
+
export type ImageProcessorResult = {
|
|
239
|
+
/**
|
|
240
|
+
* The pixel values of the batched preprocessed images.
|
|
241
|
+
*/
|
|
242
|
+
pixel_values: Tensor;
|
|
243
|
+
/**
|
|
244
|
+
* Array of two-dimensional tuples like [[480, 640]].
|
|
245
|
+
*/
|
|
246
|
+
original_sizes: HeightWidth[];
|
|
247
|
+
/**
|
|
248
|
+
* Array of two-dimensional tuples like [[1000, 1330]].
|
|
249
|
+
*/
|
|
250
|
+
reshaped_input_sizes: HeightWidth[];
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* A configuration object used to create an image processor.
|
|
254
|
+
*/
|
|
255
|
+
export type ImageProcessorConfig = {
|
|
256
|
+
/**
|
|
257
|
+
* If specified, this function will be called during model construction, to provide the user with progress updates.
|
|
258
|
+
*/
|
|
259
|
+
progress_callback?: Function;
|
|
260
|
+
/**
|
|
261
|
+
* The mean values for image normalization.
|
|
262
|
+
*/
|
|
263
|
+
image_mean?: number[];
|
|
264
|
+
/**
|
|
265
|
+
* The standard deviation values for image normalization.
|
|
266
|
+
*/
|
|
267
|
+
image_std?: number[];
|
|
268
|
+
/**
|
|
269
|
+
* Whether to rescale the image pixel values to the [0,1] range.
|
|
270
|
+
*/
|
|
271
|
+
do_rescale?: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* The factor to use for rescaling the image pixel values.
|
|
274
|
+
*/
|
|
275
|
+
rescale_factor?: number;
|
|
276
|
+
/**
|
|
277
|
+
* Whether to normalize the image pixel values.
|
|
278
|
+
*/
|
|
279
|
+
do_normalize?: boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Whether to resize the image.
|
|
282
|
+
*/
|
|
283
|
+
do_resize?: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* What method to use for resampling.
|
|
286
|
+
*/
|
|
287
|
+
resample?: number;
|
|
288
|
+
/**
|
|
289
|
+
* The size to resize the image to.
|
|
290
|
+
*/
|
|
291
|
+
size?: number | any;
|
|
292
|
+
/**
|
|
293
|
+
* The size to resize the image to (same as `size`).
|
|
294
|
+
*/
|
|
295
|
+
image_size?: number | any;
|
|
296
|
+
/**
|
|
297
|
+
* Whether to flip the color channels from RGB to BGR.
|
|
298
|
+
* Can be overridden by the `do_flip_channel_order` parameter in the `preprocess` method.
|
|
299
|
+
*/
|
|
300
|
+
do_flip_channel_order?: boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Whether to center crop the image to the specified `crop_size`.
|
|
303
|
+
* Can be overridden by `do_center_crop` in the `preprocess` method.
|
|
304
|
+
*/
|
|
305
|
+
do_center_crop?: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Whether to resize the image using thumbnail method.
|
|
308
|
+
*/
|
|
309
|
+
do_thumbnail?: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* If `true`, the image is resized to the largest possible size such that the aspect ratio is preserved.
|
|
312
|
+
* Can be overidden by `keep_aspect_ratio` in `preprocess`.
|
|
313
|
+
*/
|
|
314
|
+
keep_aspect_ratio?: boolean;
|
|
315
|
+
/**
|
|
316
|
+
* If `do_resize` is `true`, the image is resized to a size that is a multiple of this value.
|
|
317
|
+
* Can be overidden by `ensure_multiple_of` in `preprocess`.
|
|
318
|
+
*/
|
|
319
|
+
ensure_multiple_of?: number;
|
|
320
|
+
/**
|
|
321
|
+
* The mean values for image normalization (same as `image_mean`).
|
|
322
|
+
*/
|
|
323
|
+
mean?: number[];
|
|
324
|
+
/**
|
|
325
|
+
* The standard deviation values for image normalization (same as `image_std`).
|
|
326
|
+
*/
|
|
327
|
+
std?: number[];
|
|
328
|
+
};
|
|
329
|
+
import { Tensor } from "../utils/tensor.js";
|
|
330
|
+
import { RawImage } from "../utils/image.js";
|
|
331
|
+
export {};
|
|
332
|
+
//# sourceMappingURL=image_processors_utils.d.ts.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
declare const Processor_base: new () => {
|
|
2
|
+
(...args: any[]): any;
|
|
3
|
+
_call(...args: any[]): any;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} ProcessorProperties Additional processor-specific properties.
|
|
7
|
+
* @typedef {import('../utils/hub.js').PretrainedOptions & ProcessorProperties} PretrainedProcessorOptions
|
|
8
|
+
* @typedef {import('../tokenizers.js').PreTrainedTokenizer} PreTrainedTokenizer
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Represents a Processor that extracts features from an input.
|
|
12
|
+
*/
|
|
13
|
+
export class Processor extends Processor_base {
|
|
14
|
+
static classes: string[];
|
|
15
|
+
static uses_processor_config: boolean;
|
|
16
|
+
static uses_chat_template_file: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Instantiate one of the processor classes of the library from a pretrained model.
|
|
19
|
+
*
|
|
20
|
+
* The processor class to instantiate is selected based on the `image_processor_type` (or `feature_extractor_type`; legacy)
|
|
21
|
+
* property of the config object (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible)
|
|
22
|
+
*
|
|
23
|
+
* @param {string} pretrained_model_name_or_path The name or path of the pretrained model. Can be either:
|
|
24
|
+
* - A string, the *model id* of a pretrained processor hosted inside a model repo on huggingface.co.
|
|
25
|
+
* Valid model ids can be located at the root-level, like `bert-base-uncased`, or namespaced under a
|
|
26
|
+
* user or organization name, like `dbmdz/bert-base-german-cased`.
|
|
27
|
+
* - A path to a *directory* containing processor files, e.g., `./my_model_directory/`.
|
|
28
|
+
* @param {PretrainedProcessorOptions} options Additional options for loading the processor.
|
|
29
|
+
*
|
|
30
|
+
* @returns {Promise<Processor>} A new instance of the Processor class.
|
|
31
|
+
*/
|
|
32
|
+
static from_pretrained(pretrained_model_name_or_path: string, options?: PretrainedProcessorOptions): Promise<Processor>;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new Processor with the given components
|
|
35
|
+
* @param {Object} config
|
|
36
|
+
* @param {Record<string, Object>} components
|
|
37
|
+
* @param {string} chat_template
|
|
38
|
+
*/
|
|
39
|
+
constructor(config: any, components: Record<string, any>, chat_template: string);
|
|
40
|
+
config: any;
|
|
41
|
+
components: Record<string, any>;
|
|
42
|
+
chat_template: string;
|
|
43
|
+
/**
|
|
44
|
+
* @returns {import('./image_processors_utils.js').ImageProcessor|undefined} The image processor of the processor, if it exists.
|
|
45
|
+
*/
|
|
46
|
+
get image_processor(): import("./image_processors_utils.js").ImageProcessor | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* @returns {PreTrainedTokenizer|undefined} The tokenizer of the processor, if it exists.
|
|
49
|
+
*/
|
|
50
|
+
get tokenizer(): PreTrainedTokenizer | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* @returns {import('./feature_extraction_utils.js').FeatureExtractor|undefined} The feature extractor of the processor, if it exists.
|
|
53
|
+
*/
|
|
54
|
+
get feature_extractor(): import("./feature_extraction_utils.js").FeatureExtractor | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* @param {Parameters<PreTrainedTokenizer['apply_chat_template']>[0]} messages
|
|
57
|
+
* @param {Parameters<PreTrainedTokenizer['apply_chat_template']>[1]} options
|
|
58
|
+
* @returns {ReturnType<PreTrainedTokenizer['apply_chat_template']>}
|
|
59
|
+
*/
|
|
60
|
+
apply_chat_template(messages: Parameters<PreTrainedTokenizer["apply_chat_template"]>[0], options?: Parameters<PreTrainedTokenizer["apply_chat_template"]>[1]): ReturnType<PreTrainedTokenizer["apply_chat_template"]>;
|
|
61
|
+
/**
|
|
62
|
+
* @param {Parameters<PreTrainedTokenizer['batch_decode']>} args
|
|
63
|
+
* @returns {ReturnType<PreTrainedTokenizer['batch_decode']>}
|
|
64
|
+
*/
|
|
65
|
+
batch_decode(batch: number[][] | import("../transformers.js").Tensor, decode_args?: any): ReturnType<PreTrainedTokenizer["batch_decode"]>;
|
|
66
|
+
/**
|
|
67
|
+
* @param {Parameters<PreTrainedTokenizer['decode']>} args
|
|
68
|
+
* @returns {ReturnType<PreTrainedTokenizer['decode']>}
|
|
69
|
+
*/
|
|
70
|
+
decode(token_ids: number[] | bigint[] | import("../transformers.js").Tensor, decode_args?: {
|
|
71
|
+
skip_special_tokens?: boolean;
|
|
72
|
+
clean_up_tokenization_spaces?: boolean;
|
|
73
|
+
}): ReturnType<PreTrainedTokenizer["decode"]>;
|
|
74
|
+
/**
|
|
75
|
+
* Calls the feature_extractor function with the given input.
|
|
76
|
+
* @param {any} input The input to extract features from.
|
|
77
|
+
* @param {...any} args Additional arguments.
|
|
78
|
+
* @returns {Promise<any>} A Promise that resolves with the extracted features.
|
|
79
|
+
*/
|
|
80
|
+
_call(input: any, ...args: any[]): Promise<any>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Additional processor-specific properties.
|
|
84
|
+
*/
|
|
85
|
+
export type ProcessorProperties = any;
|
|
86
|
+
export type PretrainedProcessorOptions = import("../utils/hub.js").PretrainedOptions & ProcessorProperties;
|
|
87
|
+
export type PreTrainedTokenizer = import("../tokenizers.js").PreTrainedTokenizer;
|
|
88
|
+
export {};
|
|
89
|
+
//# sourceMappingURL=processing_utils.d.ts.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {PretrainedConfig} config
|
|
4
|
+
* @returns {Record<string, number[]>}
|
|
5
|
+
*/
|
|
6
|
+
export function getCacheShapes(config: PretrainedConfig, options: any): Record<string, number[]>;
|
|
7
|
+
/**
|
|
8
|
+
* Base class for all configuration classes. For more information, see the corresponding
|
|
9
|
+
* [Python documentation](https://huggingface.co/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig).
|
|
10
|
+
*/
|
|
11
|
+
export class PretrainedConfig {
|
|
12
|
+
/**
|
|
13
|
+
* Loads a pre-trained config from the given `pretrained_model_name_or_path`.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} pretrained_model_name_or_path The path to the pre-trained config.
|
|
16
|
+
* @param {PretrainedOptions} options Additional options for loading the config.
|
|
17
|
+
* @throws {Error} Throws an error if the config.json is not found in the `pretrained_model_name_or_path`.
|
|
18
|
+
*
|
|
19
|
+
* @returns {Promise<PretrainedConfig>} A new instance of the `PretrainedConfig` class.
|
|
20
|
+
*/
|
|
21
|
+
static from_pretrained(pretrained_model_name_or_path: string, { progress_callback, config, cache_dir, local_files_only, revision, }?: PretrainedOptions): Promise<PretrainedConfig>;
|
|
22
|
+
/**
|
|
23
|
+
* Create a new PreTrainedTokenizer instance.
|
|
24
|
+
* @param {Object} configJSON The JSON of the config.
|
|
25
|
+
*/
|
|
26
|
+
constructor(configJSON: any);
|
|
27
|
+
/** @type {string|null} */
|
|
28
|
+
model_type: string | null;
|
|
29
|
+
/** @type {boolean} */
|
|
30
|
+
is_encoder_decoder: boolean;
|
|
31
|
+
/** @type {number} */
|
|
32
|
+
max_position_embeddings: number;
|
|
33
|
+
/** @type {TransformersJSConfig} */
|
|
34
|
+
'transformers.js_config': TransformersJSConfig;
|
|
35
|
+
normalized_config: any;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Helper class which is used to instantiate pretrained configs with the `from_pretrained` function.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* const config = await AutoConfig.from_pretrained('Xenova/bert-base-uncased');
|
|
42
|
+
*/
|
|
43
|
+
export class AutoConfig {
|
|
44
|
+
/**
|
|
45
|
+
* Loads a pre-trained config from the given `pretrained_model_name_or_path`.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} pretrained_model_name_or_path The path to the pre-trained config.
|
|
48
|
+
* @param {PretrainedOptions} options Additional options for loading the config.
|
|
49
|
+
* @throws {Error} Throws an error if the config.json is not found in the `pretrained_model_name_or_path`.
|
|
50
|
+
*
|
|
51
|
+
* @returns {Promise<PretrainedConfig>} A new instance of the `PretrainedConfig` class.
|
|
52
|
+
*/
|
|
53
|
+
static from_pretrained(pretrained_model_name_or_path: string, { progress_callback, config, cache_dir, local_files_only, revision, }?: PretrainedOptions): Promise<PretrainedConfig>;
|
|
54
|
+
}
|
|
55
|
+
export type PretrainedOptions = import("./utils/hub.js").PretrainedOptions;
|
|
56
|
+
export type ProgressCallback = import("./utils/core.js").ProgressCallback;
|
|
57
|
+
export type ProgressInfo = import("./utils/core.js").ProgressInfo;
|
|
58
|
+
/**
|
|
59
|
+
* Transformers.js-specific configuration, possibly present in config.json under the key `transformers.js_config`.
|
|
60
|
+
*/
|
|
61
|
+
export type TransformersJSConfig = {
|
|
62
|
+
/**
|
|
63
|
+
* Device-specific configurations.
|
|
64
|
+
*/
|
|
65
|
+
device_config?: Record<import("./utils/devices.js").DeviceType, DeviceConfig>;
|
|
66
|
+
/**
|
|
67
|
+
* The data type of the key-value cache.
|
|
68
|
+
*/
|
|
69
|
+
kv_cache_dtype?: import("./utils/tensor.js").DataType | Record<import("./utils/dtypes.js").DataType, import("./utils/tensor.js").DataType>;
|
|
70
|
+
/**
|
|
71
|
+
* Override the free dimensions of the model.
|
|
72
|
+
* See https://onnxruntime.ai/docs/tutorials/web/env-flags-and-session-options.html#freedimensionoverrides
|
|
73
|
+
* for more information.
|
|
74
|
+
*/
|
|
75
|
+
free_dimension_overrides?: Record<string, number>;
|
|
76
|
+
/**
|
|
77
|
+
* The default device to use for the model.
|
|
78
|
+
*/
|
|
79
|
+
device?: import("./utils/devices.js").DeviceType;
|
|
80
|
+
/**
|
|
81
|
+
* The default data type to use for the model.
|
|
82
|
+
*/
|
|
83
|
+
dtype?: import("./utils/dtypes.js").DataType | Record<string, import("./utils/dtypes.js").DataType>;
|
|
84
|
+
/**
|
|
85
|
+
* Whether to load the model using the external data format (used for models >= 2GB in size).
|
|
86
|
+
*/
|
|
87
|
+
use_external_data_format?: import("./utils/hub.js").ExternalData | Record<string, import("./utils/hub.js").ExternalData>;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Device-specific configuration options.
|
|
91
|
+
*/
|
|
92
|
+
export type DeviceConfig = Omit<TransformersJSConfig, "device" | "device_config">;
|
|
93
|
+
//# sourceMappingURL=configs.d.ts.map
|