Merge pull request #2495 from Risenafis/fix-change-model
Fix transformers model changes
This commit is contained in:
commit
db4fe14011
|
@ -94,7 +94,11 @@ function getModelForTask(task) {
|
|||
*/
|
||||
async function getPipeline(task, forceModel = '') {
|
||||
if (tasks[task].pipeline) {
|
||||
return tasks[task].pipeline;
|
||||
if (forceModel === '' || tasks[task].currentModel === forceModel) {
|
||||
return tasks[task].pipeline;
|
||||
}
|
||||
console.log('Disposing transformers.js pipeline for for task', task, 'with model', tasks[task].currentModel);
|
||||
await tasks[task].pipeline.dispose();
|
||||
}
|
||||
|
||||
const cache_dir = path.join(process.cwd(), 'cache');
|
||||
|
@ -103,6 +107,7 @@ async function getPipeline(task, forceModel = '') {
|
|||
console.log('Initializing transformers.js pipeline for task', task, 'with model', model);
|
||||
const instance = await pipeline(task, model, { cache_dir, quantized: tasks[task].quantized ?? true, local_files_only: localOnly });
|
||||
tasks[task].pipeline = instance;
|
||||
tasks[task].currentModel = model;
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue