Skip to content

Support register custom processor #1233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions src/models/auto/processing_auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ import * as AllFeatureExtractors from '../feature_extractors.js';
*/
export class AutoProcessor {

static PROCESSOR_CLASS_MAPPING = {...AllProcessors};

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

// TODO: first check for processor.json
const preprocessorConfig = await getModelJSON(pretrained_model_name_or_path, IMAGE_PROCESSOR_NAME, true, options);

const { image_processor_type, feature_extractor_type, processor_class } = preprocessorConfig;
if (processor_class && AllProcessors[processor_class]) {
return AllProcessors[processor_class].from_pretrained(pretrained_model_name_or_path, options);
if (processor_class && this.PROCESSOR_CLASS_MAPPING[processor_class]) {
return this.PROCESSOR_CLASS_MAPPING[processor_class].from_pretrained(pretrained_model_name_or_path, options);
}

if (!image_processor_type && !feature_extractor_type) {
Expand Down