Http2 error: stream error for model on deno's deploy

On my localhost it takes 2-3 seconds to run but on my Deno Deploy | Deno server. it used to work in 10 secs but now I get the following in logs :

error sending request for url (https://storage.googleapis.com/tfhub-tfjs-modules/tensorflow/tfjs-model/toxicity/1/default/1/group1-shard2of7#undefined):
http2 error: stream error received: unexpected internal error encountered

Maybe @lgusm knows about this given the recent Kaggle models stuff? Seems like the tfhub model is not available?

Just to make sure, are you calling that url or this:

https://tfhub.dev/tensorflow/tfjs-model/toxicity/1/default/1

?

can you share the code snippet too please?

It is working successfully now. Before I sometimes used to get the above error.

import tfjs from "https://esm.sh/@tensorflow/tfjs@4.2.0";
import * as toxicity from "https://esm.sh/@tensorflow-models/toxicity@1.2.2";

const threshold = 0.5;
let arrToxicity = {};
let t0 = performance.now();

let toxicityF = async (sentence) =>
{
    return await new Promise((resolve, reject) =>
    {
        console.log("Calling toxicity .. now");

        toxicity.load(threshold).then((model: any) =>
        {
            const sentences = [sentence];
            model.classify(sentences).then((predictions: Array<String>) =>
            {                
                predictions.map((p) =>
                {
                    arrToxicity[p.label] = p.results[0].match
                });
            }).then(() =>
            {
                let t1 = performance.now();
                console.log("Call to toxicity took " + (t1 - t0) + " milliseconds.");
                resolve(JSON.stringify(arrToxicity, null, 2));
            }).catch((error) =>
                {
                    console.log("Some error" + error);
                    reject("error")
                });
        });
    });
};

export default toxicityF;
1 Like

Nice, we’ll keep an eye for this

If you notice it again please let us know

1 Like