in florence2-webgpu/src/worker.js [24:44]
static async getInstance(progress_callback = null) {
this.processor ??= AutoProcessor.from_pretrained(this.model_id);
this.tokenizer ??= AutoTokenizer.from_pretrained(this.model_id);
this.supports_fp16 ??= await hasFp16();
this.model ??= Florence2ForConditionalGeneration.from_pretrained(
this.model_id,
{
dtype: {
embed_tokens: this.supports_fp16 ? "fp16" : "fp32",
vision_encoder: this.supports_fp16 ? "fp16" : "fp32",
encoder_model: "q4", // or 'fp16' or 'fp32'
decoder_model_merged: "q4", // or 'fp16' or 'fp32'
},
device: "webgpu",
progress_callback,
},
);
return Promise.all([this.model, this.tokenizer, this.processor]);
}