$ npm install @qvac/dl-filesystem@qvac/dl-filesystem is a data loading library designed to load model weights and other resources from a local filesystem. It provides a simple and efficient way to retrieve files required for AI model inference, training, and other operations directly from a specified directory.
FilesystemDL extends BaseDL to provide a unified interface for loading files from a local directory. It is designed to integrate seamlessly with other QVAC AI Runtime libraries and classes.
const FilesystemDL = require('@qvac/dl-filesystem');
const fsDL = new FilesystemDL({ dirPath: '/path/to/your/models' });
dirPath: A string representing the local path to the directory containing model files or resources.getStream(path): Asynchronously retrieves a readable stream for a specified file path in the local directory.
const stream = await fsDL.getStream('model_weights.bin');
list(directoryPath = '.'): Lists the files in a directory relative to the base directory. If no directory is specified, it lists the files in the base directory.
const files = await fsDL.list();
console.log(files); // Output: ['file1.bin', 'file2.bin']
Below is an example of how FilesystemDL can be used within the QVAC AI Runtime to dynamically load models:
const Qvac = require('@qvac/rt');
const FilesystemDL = require('@qvac/dl-filesystem');
const Whisper = require('@qvac/transcription-whispercpp');
const qvac = new Qvac({ /* runtime options */ });
// Create an inference instance for Whisper using the local filesystem to load weights
const whisper = qvac.inference.add(new Whisper({
weights: new FilesystemDL({ dirPath: '/path/to/your/models' }),
params: { /* model parameters */ }
}));
// Load model weights
await whisper.load();
The FilesystemDL class can be integrated directly within model classes to dynamically fetch and load model files from a local directory.
class MyModel {
constructor(loader) {
this.loader = loader;
}
async load() {
const weightsStream = await this.loader.getStream('model_weights.bin');
// Process all the required files from the stream...
}
async listFiles() {
const files = await this.loader.list();
console.log('Available model files:', files);
}
}
Install dependencies:
npm install
Run unit tests:
npm test
list method can be used to enumerate the files available in the directory.