我正在尝试使Mobilenetv2模型(将最后一层重新训练到我的数据中)在Google Edge TPU珊瑚上运行。
我已经按照这个教程https://www.tensorflow.org/lite/performance/post_training_quantization?hl=zh-CN进行了训练后量化。相关代码为:
...
train = tf.convert_to_tensor(np.array(train, dtype='float32'))
my_ds = tf.data.Dataset.from_tensor_slices(train).batch(1)
# POST TRAINING QUANTIZATION
def representative_dataset_gen():
for input_value in my_ds.take(30):
yield [input_value]
converter = tf.lite.TFLiteConverter.from_keras_model_file(saved_model_dir)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.representative_dataset = representative_dataset_gen
converter.target_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
tflite_quant_model = converter.convert()
Run Code Online (Sandbox Code Playgroud)
我已经成功生成了tflite量化模型,但是当我运行edgetpu_compiler时(此页面为https://coral.withgoogle.com/docs/edgetpu/compiler/#usage),我得到以下输出:
edgetpu_compiler Notebooks/MobileNetv2_3class_visit_split_best-val-
acc.h5.quant.tflite
Edge TPU Compiler version 2.0.258810407
INFO: Initialized TensorFlow Lite runtime.
ERROR: quantized_dimension must be in range [0, 1). Was 3.
ERROR: quantized_dimension must be in range [0, 1). Was 3.
ERROR: quantized_dimension must …Run Code Online (Sandbox Code Playgroud) 我正在努力在Google Coral开发板上为Python 安装最新版本的dlib(http://dlib.net/,v19.17)。它与Raspberry Pi 3 B +(似乎具有完全相同的CPU和RAM数量)一起很好地工作,但是在珊瑚开发板上的卡住率为80%(在编译vector.cpp时)。运行跑步时会发生这种情况:
python3 setup.py install
Run Code Online (Sandbox Code Playgroud)
我尝试在Mendel Linux(运行开发板)上进行以下跟踪,但未成功:
我看到的RPI和Coral / Mendel之间的主要区别是孟德尔上的cmake和gcc的旧版本。
我已经将cmake升级到最新版本,但没有成功,但是还没有涉及gcc。
我正在尝试为 Google Coral USB 加速器运行一些 Gstreamer 示例 - 我没有使用 Coral 开发板。驱动程序已安装并运行,我可以使用 OpenCV 和 edgetpu 库对来自我的相机的图像进行分类。我想让网络服务器演示运行。我已经将范围缩小到 Gstreamer 无法找到 Coral 提供的插件。
插件来自这个 repo(它还包含演示代码edgetpu_detect_server和edgetpu_detect:https : //coral.googlesource.com/edgetpuvision/+/refs/heads/master/plugins/
Coral 提供了三个插件:
linaro@linaro-alip:~$ ls /home/linaro/edgetpuvision/plugins/
glbox.py glsvgoverlaysink.py glsvgoverlaysrc.py
Run Code Online (Sandbox Code Playgroud)
我在尝试运行时遇到的错误,例如检测服务器是:
(edgetpu_detect:28764): dbind-WARNING **: 11:38:56.589: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
v4l2src device=/dev/video0 ! video/x-raw,format=YUYV,width=640,height=512,framerate=30/1 ! glupload ! tee name=t
t. ! queue ! glsvgoverlaysink name=glsink
t. ! queue max-size-buffers=1 leaky=downstream ! glfilterbin filter=glbox …Run Code Online (Sandbox Code Playgroud) 我想在Android设备中使用USB Coral加速器在我的Android应用程序中使用CNN。可以使用吗?如果你们知道的话。请告诉我。谢谢。
我有一个使用 sigmoid 函数进行二元分类的 Keras 模型。我编译了我的模型以.tflite按照 Coral USB 的要求进行格式化以运行推理。但是,我注意到该脚本classify_image.py执行多类分类。因此,当我尝试对图像进行分类时,我对任何图像都得到了 100% 的预测。例如,我的模型将红外图像分类为发烧状态。即使我传球图像,它也会为发烧级提供 100% 阳性。
因此,我再次使用完全自定义的模型对植物使用 layer softmax 测试了多类模型,这一次它起作用了。它为植物 A、植物 B 和植物 C 提供了合理的 85% 准确度。
因此,我想知道我需要做哪些更改,才能使用二进制分类自定义模型与 Pycoral 配合使用。
这是我用于分类的代码:
import argparse
import time
from PIL import Image
from pycoral.adapters import classify
from pycoral.adapters import common
from pycoral.utils.dataset import read_label_file
from pycoral.utils.edgetpu import make_interpreter
import cv2 as cv
import numpy as np
def main():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-m', '--model', required=True,
help='File path of .tflite file.')
parser.add_argument('-i', '--input', required=True, …Run Code Online (Sandbox Code Playgroud) python machine-learning tensorflow tensorflow-lite google-coral
刚刚设置了我的 Google Coral Dev Board,Mendel 的安装有点粗糙,但是现在我已经刷了板,即使经过几次重新启动,风扇也不会旋转。
散热器变得超级热。我是菜鸟,有什么代码可以解决这个问题,如果是这样,请告诉我如何运行上述代码的详细信息?
当我使用串行端口运行谷歌珊瑚时,我能够运行演示应用程序,但是当我尝试使用数据端口(c 型电缆)运行谷歌珊瑚时,我无法连接开发板
rahul@ubuntu:~$ mdt shell 正在等待设备...正在连接到如意纱在 192.168.101.2 如意纱上不存在密钥 -- 推送
看起来您正在尝试连接到未通过 USB 连接到您的工作站并且没有此 MDT 生成的 SSH 密钥的设备。要与 MDT shell 连接,您需要首先仅通过 USB 连接到您的设备。
遵循Edge TPU开发板入门上的说明时,我无法走过步骤2:
$ screen /dev/ttyUSB0 115200
Run Code Online (Sandbox Code Playgroud)
问题是屏幕立即返回
[screen is terminating]
Run Code Online (Sandbox Code Playgroud)
我已经验证了/etc/udev/rules.d/65-edgetpu-board.rules的内容,验证了dmesg输出,尝试了不同的USB端口,验证了所有屏幕实例均已关闭,等等。
我正在关注 Coral Dev Board 入门指南 - 开始使用 Dev Board ( https://coral.withgoogle.com/docs/dev-board/get-started/ )。一切正常,直到步骤 -通过 MDT 连接到板的外壳。我等了大约 5 分钟,直到闪烁完成,终端提示返回给我,然后我尝试了命令:
mdt devices
终端什么都不返回。不像指南说它应该返回我的主板主机名和 IP 地址。我检查了USB-C OTG和USB-C电源线,它们都连接良好。
我也试过这个解决方案:https : //superuser.com/questions/1452786/coral-dev-board-not-recongized-on-mdt-shell。我转到系统偏好设置下的网络,然后单击“+”图标,但我找不到孟德尔设备。
我正在使用在 macOS Catalina 上运行的 Macbook Pro。fastboot 和 mdt 命令都可以工作。
在转换和执行 keras 模型的 8 位量化时,我遇到了图像数据集没有发生的奇怪错误。
import tensorflow.python.keras.backend as K
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.models import load_model
import numpy as np
x_train = np.array([[0.6171875 0.59791666],[0.6171875 0.59791666],[0.6171875 0.59791666]])
y_train = np.array([[0.6171875 0.59791666],[0.6171875 0.59791666],[0.6171875 0.59791666]])
def representative_dataset_gen():
for i in range(1):
# Get sample input data as a numpy array in a method of your choosing.
sample = np.array([0.5,0.6])
sample = np.expand_dims(sample, axis=0)
yield [sample]
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(2,)),
tf.keras.layers.Dense(12, activation='relu'),
tf.keras.layers.Dense(2, activation='softmax')
])
model.compile(optimizer='adam',
loss='categorical_crossentropy',
metrics=['accuracy'])
model.fit(x_train, …Run Code Online (Sandbox Code Playgroud) google-coral ×10
tpu ×4
python ×3
tensorflow ×3
quantization ×2
accelerator ×1
android ×1
arm ×1
dlib ×1
fastboot ×1
gcc ×1
gstreamer ×1
keras ×1
linux ×1
macos ×1
usb ×1