Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/base/feature_extraction_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ export class FeatureExtractor extends Callable {
}

/**
* Instantiate one of the processor classes of the library from a pretrained model.
* Instantiate one of the feature extractor classes of the library from a pretrained model.
*
* The processor class to instantiate is selected based on the `image_processor_type` (or `feature_extractor_type`; legacy)
* property of the config object (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible)
* The feature extractor class to instantiate is selected based on the `feature_extractor_type` property of
* the config object (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible)
*
* @param {string} pretrained_model_name_or_path The name or path of the pretrained model. Can be either:
* - A string, the *model id* of a pretrained processor hosted inside a model repo on huggingface.co.
* - A string, the *model id* of a pretrained feature_extractor hosted inside a model repo on huggingface.co.
* Valid model ids can be located at the root-level, like `bert-base-uncased`, or namespaced under a
* user or organization name, like `dbmdz/bert-base-german-cased`.
* - A path to a *directory* containing processor files, e.g., `./my_model_directory/`.
* @param {import('../utils/hub.js').PretrainedOptions} options Additional options for loading the processor.
* - A path to a *directory* containing feature_extractor files, e.g., `./my_model_directory/`.
* @param {import('../utils/hub.js').PretrainedOptions} options Additional options for loading the feature_extractor.
*
* @returns {Promise<FeatureExtractor>} A new instance of the Processor class.
* @returns {Promise<FeatureExtractor>} A new instance of the Feature Extractor class.
*/
static async from_pretrained(pretrained_model_name_or_path, options) {
const preprocessorConfig = await getModelJSON(pretrained_model_name_or_path, FEATURE_EXTRACTOR_NAME, true, options);
return new this(preprocessorConfig);
const config = await getModelJSON(pretrained_model_name_or_path, FEATURE_EXTRACTOR_NAME, true, options);
return new this(config);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/base/processing_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ export class Processor extends Callable {
/**
* Instantiate one of the processor classes of the library from a pretrained model.
*
* The processor class to instantiate is selected based on the `feature_extractor_type` property of the config object
* (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible)
* The processor class to instantiate is selected based on the `image_processor_type` (or `feature_extractor_type`; legacy)
* property of the config object (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible)
*
* @param {string} pretrained_model_name_or_path The name or path of the pretrained model. Can be either:
* - A string, the *model id* of a pretrained processor hosted inside a model repo on huggingface.co.
Expand Down
16 changes: 0 additions & 16 deletions src/models/auto/feature_extraction_auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,6 @@ import * as AllFeatureExtractors from '../feature_extractors.js';

export class AutoFeatureExtractor {

/**
* Instantiate one of the feature extractor classes of the library from a pretrained model.
*
* The processor class to instantiate is selected based on the `feature_extractor_type` property of
* the config object (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible)
*
* @param {string} pretrained_model_name_or_path The name or path of the pretrained model. Can be either:
* - A string, the *model id* of a pretrained processor hosted inside a model repo on huggingface.co.
* Valid model ids can be located at the root-level, like `bert-base-uncased`, or namespaced under a
* user or organization name, like `dbmdz/bert-base-german-cased`.
* - A path to a *directory* containing processor files, e.g., `./my_model_directory/`.
* @param {import('../../utils/hub.js').PretrainedOptions} options Additional options for loading the processor.
*
* @returns {Promise<AllFeatureExtractors.ImageProcessor>} A new instance of the Processor class.
*/

/** @type {typeof FeatureExtractor.from_pretrained} */
static async from_pretrained(pretrained_model_name_or_path, options={}) {

Expand Down
16 changes: 0 additions & 16 deletions src/models/auto/processing_auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,6 @@ import * as AllFeatureExtractors from '../feature_extractors.js';
*/
export class AutoProcessor {

/**
* Instantiate one of the processor classes of the library from a pretrained model.
*
* The processor class to instantiate is selected based on the `image_processor_type` (or `feature_extractor_type`; legacy)
* property of the config object (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible)
*
* @param {string} pretrained_model_name_or_path The name or path of the pretrained model. Can be either:
* - A string, the *model id* of a pretrained processor hosted inside a model repo on huggingface.co.
* Valid model ids can be located at the root-level, like `bert-base-uncased`, or namespaced under a
* user or organization name, like `dbmdz/bert-base-german-cased`.
* - A path to a *directory* containing processor files, e.g., `./my_model_directory/`.
* @param {import('../../utils/hub.js').PretrainedOptions} options Additional options for loading the processor.
*
* @returns {Promise<Processor>} A new instance of the Processor class.
*/

/** @type {typeof Processor.from_pretrained} */
static async from_pretrained(pretrained_model_name_or_path, options={}) {

Expand Down
2 changes: 1 addition & 1 deletion src/models/phi3_v/processing_phi3_v.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Phi3VProcessor extends Processor {
*
* @param {string|string[]} text
* @param {RawImage|RawImage[]} images
* @param {...any} args
* @param { { padding?: boolean, truncation?: boolean, num_crops?: number } | undefined } options
* @returns {Promise<any>}
*/
async _call(text, images = null, {
Expand Down
2 changes: 1 addition & 1 deletion src/pipelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -1916,7 +1916,7 @@ export class AutomaticSpeechRecognitionPipeline extends (/** @type {new (options
const max_new_tokens = Math.floor(aud.length / sampling_rate) * 6;
const outputs = await this.model.generate({ max_new_tokens, ...kwargs, ...inputs });

const text = this.processor.batch_decode(outputs, { skip_special_tokens: true })[0];
const text = this.processor.batch_decode(/** @type {Tensor} */(outputs), { skip_special_tokens: true })[0];
toReturn.push({ text });
}
return single ? toReturn[0] : toReturn;
Expand Down
Loading