UNPKG

@sconedev/ai_toolkit

Version:

Simplify AI integration in web apps with local and offline model support

40 lines (39 loc) 1.63 kB
// Collection of pre-defined models export const predefinedModels = { // Text classification model (example) 'text-classification': { name: 'text-classification', modelUrl: 'https://cdn.example.com/models/text-classification.onnx', // Replace with actual URL inputNames: ['input_ids', 'attention_mask', 'token_type_ids'], outputNames: ['output'], inputShapes: [[1, 128], [1, 128], [1, 128]] // Batch size 1, sequence length 128 }, // Image classification model (example) 'image-classification': { name: 'image-classification', modelUrl: 'https://cdn.example.com/models/image-classification.onnx', // Replace with actual URL inputNames: ['input'], outputNames: ['output'], inputShapes: [[1, 3, 224, 224]] // Batch size 1, 3 channels, 224x224 resolution }, // Object detection model (example) 'object-detection': { name: 'object-detection', modelUrl: 'https://cdn.example.com/models/object-detection.onnx', // Replace with actual URL inputNames: ['input'], outputNames: ['boxes', 'scores', 'classes'], inputShapes: [[1, 3, 640, 640]] // Batch size 1, 3 channels, 640x640 resolution } }; // Function to get model config by name export function getModelConfig(modelName) { const model = predefinedModels[modelName]; if (!model) { throw new Error(`Model '${modelName}' not found in predefined models`); } return model; } // Function to register a custom model export function registerCustomModel(config) { predefinedModels[config.name] = config; }