fix issue of clip search stuck on pending model download
This commit is contained in:
parent
d1fa900d4b
commit
c239a9631d
1 changed files with 3 additions and 12 deletions
|
@ -192,22 +192,13 @@ async function getOnnxImageSession() {
|
||||||
return onnxImageSessionPromise;
|
return onnxImageSessionPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
let onnxTextSessionPromise: Promise<any> = null;
|
|
||||||
let onnxTextSession: any = null;
|
let onnxTextSession: any = null;
|
||||||
|
|
||||||
async function getOnnxTextSession() {
|
async function getOnnxTextSession() {
|
||||||
if (onnxTextSession) {
|
if (!onnxTextSession) {
|
||||||
return onnxTextSession;
|
|
||||||
}
|
|
||||||
if (onnxTextSessionPromise) {
|
|
||||||
throw Error(CustomErrors.MODEL_DOWNLOAD_PENDING);
|
|
||||||
}
|
|
||||||
onnxTextSessionPromise = (async () => {
|
|
||||||
const clipModelPath = await getClipTextModelPath('onnx');
|
const clipModelPath = await getClipTextModelPath('onnx');
|
||||||
return createOnnxSession(clipModelPath);
|
onnxTextSession = await createOnnxSession(clipModelPath);
|
||||||
})();
|
}
|
||||||
onnxTextSession = await onnxTextSessionPromise;
|
|
||||||
onnxTextSessionPromise = null;
|
|
||||||
return onnxTextSession;
|
return onnxTextSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue