我正在尝试使用张量流检测教程对批次执行检测,但以下代码给出了setting an array element with a sequence.错误。
# load multiple images
np_images = []
for img_path in img_paths:
img = Image.open(image_path)
image_np = load_image_into_numpy_array(img)
image_np_expanded = np.expand_dims(image_np, axis=0)
np_images.append(image_np)
#Get input and output tensors
image_tensor = det_graph.get_tensor_by_name('image_tensor:0')
boxes = det_graph.get_tensor_by_name('detection_boxes:0')
scores = det_graph.get_tensor_by_name('detection_scores:0')
classes = det_graph.get_tensor_by_name('detection_classes:0')
num_detections = det_graph.get_tensor_by_name('num_detections:0')
# detect on batch of images
detection_results = sess.run(
[boxes, scores, classes, num_detections],
feed_dict={image_tensor: np_images})
Run Code Online (Sandbox Code Playgroud)
如何正确输入图像数组?
我遵循了代码的整个步骤/格式(多次交叉检查以 100% 确定它们是正确的)以及在 Tensorflow 对象检测 API 上训练自定义对象所需的数据。我尝试使用 ssd_mobilenet_v1_coco、faster_rcnn_resnet101_coco 以及 fast_rcnn_inception_v2_coco 模型,但仍然没有得到任何好的结果。我得到的只是对象的错误分类或根本没有边界框。
我正在训练检测单个类对象,训练图像数量约为 250,验证图像数量为 63;并且每个大小不一的图像大多在 300 x 300 像素或更小。我正在训练模型直到它们收敛(不完全)。我通过查看 eval 性能(步长超过 15000 步)来了解这一点,损失随着时间的推移逐渐减少(至 < 0.04),但也会波动。我停止训练并导出图表。我的问题是:
我对用于解决物体检测的测试视频有很大的疑问。视频帧的尺寸为 1370 x 786 像素,其中我需要检测的对象与帧大小相比非常小。这是否会导致问题?,因为我的训练图像很小(300 x 300 或更小),而与训练图像相比,我的测试视频帧如此之大?我尝试了几次训练,但每次都失败了,我坚持到了我想放弃这个的地步。
有人可以了解这里发生的事情吗?我应该训练更多的步骤吗?或者我也应该训练与测试帧中相似尺寸的图像进行训练?这会有所帮助吗?
以下是我使用的配置文件和 labelmap.pbtxt 的代码。
配置文件:
fine_tune_checkpoint: ".../ssd_mobilenet_v1_coco_2017_11_17/model.ckpt"
from_detection_checkpoint: true
num_steps: 200000
data_augmentation_options {
random_horizontal_flip {
}
}
data_augmentation_options {
ssd_random_crop {
}
}
}
train_input_reader: {
tf_record_input_reader {
input_path: ".../train.record"
}
label_map_path: ".../labelmap.pbtxt"
}
eval_config: {
num_examples: 63
Run Code Online (Sandbox Code Playgroud)
标签图.pbtxt:
item {
id: 1
name: 'tomato'
}
Run Code Online (Sandbox Code Playgroud) I want to read the data stored in a TFRecord file that I've used as a train record in TF Object Detection API.
However, I get an InvalidArgumentError: Input to reshape is a tensor with 91090 values, but the requested shape has 921600. I don't understand what the root of the error is, even though the discrepancy seems to be a factor of 10.
Question: How can I read the file without this error?
我正在尝试使用 tensorflow 对象检测 api 训练自定义对象检测模型。出于训练目的,我使用腌制图像数据集进行训练,并作为我使用的模型ssd_mobilenet_v1_coco。当我开始训练时,它给了我这个错误。
Traceback (most recent call last):
File "train.py", line 184, in <module>
tf.app.run()
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/platform/app.py", line 126, in run
_sys.exit(main(argv))
File "train.py", line 180, in main
graph_hook_fn=graph_rewriter_fn)
File "/content/models/research/object_detection/trainer.py", line 381, in train
init_saver = tf.train.Saver(available_var_map)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/saver.py", line 1338, in __init__
self.build()
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/saver.py", line 1347, in build
self._build(self._filename, build_save=True, build_restore=True)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/saver.py", line 1372, in _build
raise ValueError("No variables to save")
ValueError: No variables to save
Run Code Online (Sandbox Code Playgroud)
完整的错误代码可以在这里找到...
[https://gist.github.com/mpgovinda/1f59f7de7873f6ec4c4426b79dc6827a][1]
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
tensorflow python-3.6 object-detection-api google-colaboratory
我不太明白这个指南:https : //github.com/tensorflow/models/blob/master/research/object_detection/g3doc/instance_segmentation.md
我有很多三个类的对象。根据指南,我必须制作尺寸为 [N, H, W] 的面具,其中:
我有这个功能来创建一个面具
def image_mask(img, polygons):
w, h = img.size
n = len(polygons)
mask = np.zeros([n, h, w], dtype=np.float32)
for i in range(0, n):
polygon = polygons[i].reshape((-1, 1, 2))
tmp_mask = np.zeros([h, w], dtype=np.float32)
cv2.fillPoly(tmp_mask, [polygon], (1, 1, 1))
mask[i, :, :] = tmp_mask
return mask
Run Code Online (Sandbox Code Playgroud)
我使用本指南来创建我的数据集:https : //github.com/tensorflow/models/blob/master/research/object_detection/g3doc/using_your_own_dataset.md
我在 tf_example 的末尾添加了一个掩码
tf_example = tf.train.Example(features=tf.train.Features(feature={
...
'image/object/class/label': dataset_util.int64_list_feature(classes),
'image/object/mask': dataset_util.bytes_list_feature(mask.reshape((-1))),
}))
Run Code Online (Sandbox Code Playgroud)
由于reshape …
python mask object-detection tensorflow object-detection-api
我试图找出在 iOS 应用程序中从 Tensorflow 模型(Inception 或 mobilenet)运行对象检测的最简单方法。
我有 iOS Tensorflow 图像分类在我自己的应用程序和网络中按照这个示例工作
并按照此示例在 Android 中为我自己的应用程序和网络使用 Tensorflow 图像分类和对象检测
但是iOS的例子不包含物体检测,只有图像分类,那么如何扩展iOS的例子代码来支持物体检测,或者iOS中有完整的例子吗?(最好是目标-C)
我确实找到了this和this,但是它从源代码重新编译了 Tensorflow,这看起来很复杂,
还发现了Tensorflow lite,
但同样没有物体检测。
我还找到了将 Tensorflow 模型转换为 Apple Core ML 的选项,使用 Core ML,但这看起来很复杂,在 Core ML 中找不到对象检测的完整示例
我想知道模型配置文件中的术语“步骤”(在训练模型时)在 Tensorflow 对象检测 API 中到底指的是什么。谁能解释一下它与纪元以及每个纪元的步数有何关系?
python computer-vision deep-learning tensorflow object-detection-api
我有几个自己制作的 tfrecord 文件。它们在 tf1 中运行良好,我在几个项目中使用了它们。但是,如果我想在带有 tf2(运行 model_main_tf2.py 脚本)的 Tensorflow Object Detection API 中使用它们,我会在 tensorboard 中看到以下内容:
它完全叠加了图像。(运行 /work/tfapi/research/object_detection/model_main.py 脚本甚至 legacy_train 它们看起来不错)tf2 是否在 tfrecords 中使用了不同类型的编码?或者什么会导致这样的结果?
tensorboard tfrecord object-detection-api tensorflow2.0 tensorflow2
我怎样才能将训练好的模型导出到frozen_inference_graph.pb而不是saved_model.pb,因为当我使用Tensorflow对象检测v2附带的exporter_main_v2.py时,它给了我一个文件夹
\n\xe2\x94\x9c\xe2\x94\x80 exported-models/\n \xe2\x94\x94\xe2\x94\x80 my_model/ \n \xe2\x94\x9c\xe2\x94\x80 checkpoint/\n \xe2\x94\x9c\xe2\x94\x80 saved_model/\n \xe2\x94\x94\xe2\x94\x80 assets/\n \xe2\x94\x9c\xe2\x94\x80 variables/\n \xe2\x94\x94\xe2\x94\x80 saved_model.pb\n \xe2\x94\x94\xe2\x94\x80 pipeline.config\nRun Code Online (Sandbox Code Playgroud)\n在 save_model 中我有 saving_model.pb 但问题是我不能单独使用它进行推理,但我需要使用它附带的变量文件夹。这就是为什么我问是否有一种方法可以将经过训练的模型导出到 freeze_inference_graph.pb 以使用它进行推理,而不需要 TF1 中的变量文件夹。
\npython object-detection computer-vision tensorflow object-detection-api
centernet_resnet50_v2_512x512_kpts_coco17_tpu-8我正在Nvidia Tesla P100上使用张量流对象检测模型来提取边界框和关键点,以检测视频中的人物。使用tensorflow.org 上的预训练数据,我每秒能够处理大约 16 帧。有什么方法可以提高该模型的评估速度吗?以下是我一直在研究的一些想法:
label_map似乎并没有提高性能。model_builder我发现性能有所下降。object-detection tensorflow tensorrt object-detection-api tensorflow2.0
tensorflow ×9
python ×6
tfrecord ×2
ios ×1
mask ×1
python-3.6 ×1
tensorboard ×1
tensorflow2 ×1
tensorrt ×1