@huggingface/transformers
Version:
State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!
21 lines (17 loc) • 769 B
JavaScript
import { IMAGE_PROCESSOR_NAME } from '../constants.js';
import { get_file_metadata } from './get_file_metadata.js';
/**
* Returns the list of processor files that will be loaded for a model.
* Auto-detects if the model has a processor by checking if preprocessor_config.json exists.
*
* @param {string} modelId The model id (e.g., "Xenova/detr-resnet-50")
* @returns {Promise<string[]>} Array of processor file names (empty if no processor)
*/
export async function get_processor_files(modelId) {
if (!modelId) {
throw new Error('modelId is required');
}
// Check if preprocessor_config.json exists
const metadata = await get_file_metadata(modelId, IMAGE_PROCESSOR_NAME, {});
return metadata.exists ? [IMAGE_PROCESSOR_NAME] : [];
}