@huggingface/transformers
Version:
State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!
23 lines (18 loc) • 764 B
JavaScript
import { Processor } from '../../processing_utils.js';
import { AutoImageProcessor } from '../auto/image_processing_auto.js';
import { AutoTokenizer } from '../auto/tokenization_auto.js';
export class JinaCLIPProcessor extends Processor {
static tokenizer_class = AutoTokenizer;
static image_processor_class = AutoImageProcessor;
async _call(text = null, images = null, kwargs = {}) {
if (!text && !images) {
throw new Error('Either text or images must be provided');
}
const text_inputs = text ? this.tokenizer(text, kwargs) : {};
const image_inputs = images ? await this.image_processor(images, kwargs) : {};
return {
...text_inputs,
...image_inputs,
};
}
}