TensorflowJS TFJS 错误:字典中键的 dtype

尝试运行 https://glitch.com/~tar-understood-exoplanet 时,模型无法加载,并且我无法启用网络摄像头。

有人遇到过同样的问题吗?

程序运行时,控制台中显示以下信息:

tfjs:2 Uncaught (in promise) Error: The dtype of dict['image_tensor'] provided in model.execute(dict) must be int32, but was float32    at Object.b [as assert] (tfjs:2)    at tfjs:2    at Array.forEach (<anonymous>)    at t.checkInputShapeAndType (tfjs:2)    at t.<anonymous> (tfjs:2)    at tfjs:2    at Object.next (tfjs:2)    at tfjs:2    at new Promise (<anonymous>)    at Zv (tfjs:2)

我使用的是 Macbook Pro,其他一些使用 Windows 系统的朋友在运行模型时也遇到了问题。我们还尝试了不同的浏览器,包括 Safari 和 Chrome。

成功!切换到 coco-ssd 2.0.2 后:

我在第 62 行添加了版本 2.0.2,如下所示:

<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/[email protected]"></script>

回答:

这是由 coco-ssd 的预热运行引起的,该运行使用了 tf.zeros 张量。在 TFJS 的最新版本中,tf.zeros 的默认 dtype 是 ‘float’。我已经发布了一个包含修复的新版本。如果您在 glitch 示例(index.html)中使用 coco-ssd 的最新版本(2.0.2),应该可以正常工作,如下所示。

    <!-- Load the coco-ssd model to use to recognize things in images -->    <script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/[email protected]"></script>

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注