static async getInstance()

in semantic-image-search-web/src/worker.js [20:44]


  static async getInstance(progress_callback = null) {
    // Load tokenizer and text model
    this.tokenizer ??= AutoTokenizer.from_pretrained(this.model_id, {
      progress_callback,
    });
    this.text_model ??= CLIPTextModelWithProjection.from_pretrained(
      this.model_id,
      { progress_callback },
    );
    this.metadata ??= getCachedJSON(this.BASE_URL + "image-embeddings.json");
    this.embeddings ??= new Promise((resolve, reject) => {
      getCachedFile(this.BASE_URL + "image-embeddings_25k-512-32bit.bin")
        .then((buffer) => {
          resolve(new Float32Array(buffer));
        })
        .catch(reject);
    });

    return Promise.all([
      this.tokenizer,
      this.text_model,
      this.metadata,
      this.embeddings,
    ]);
  }