convert_imageset.cpp 指南 [英] A guide to convert_imageset.cpp

查看:13
本文介绍了convert_imageset.cpp 指南的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对机器学习/python/ubuntu 比较陌生.

I am relatively new to machine learning/python/ubuntu.

我有一组 .jpg 格式的图像,其中一半包含我希望 caffe 学习的功能,另一半不包含.我找不到将它们转换为所需 lmdb 格式的方法.

I have a set of images in .jpg format where half contain a feature I want caffe to learn and half don't. I'm having trouble in finding a way to convert them to the required lmdb format.

我有必要的文本输入文件.

I have the necessary text input files.

我的问题是谁能提供有关如何在 ubuntu 终端中使用 convert_imageset.cpp 的分步指南?

My question is can anyone provide a step by step guide on how to use convert_imageset.cpp in the ubuntu terminal?

谢谢

推荐答案

Caffe convert_imageset

快速指南

构建

您必须做的第一件事是构建 caffe 和 caffe 的工具(convert_imageset 是这些工具之一).
安装 caffe 和 make 后,确保你也运行了 make tools.
验证是否在 $CAFFE_ROOT/build/tools 中创建了二进制文件 convert_imageset.

A quick guide to Caffe's convert_imageset

Build

First thing you must do is build caffe and caffe's tools (convert_imageset is one of these tools).
After installing caffe and makeing it make sure you ran make tools as well.
Verify that a binary file convert_imageset is created in $CAFFE_ROOT/build/tools.

图像: 将所有图像放在一个文件夹中(我在这里称之为 /path/to/jpegs/).
标签:创建一个文本文件(例如,/path/to/labels/train.txt),每个输入图像有一行.例如:

Images: put all images in a folder (I'll call it here /path/to/jpegs/).
Labels: create a text file (e.g., /path/to/labels/train.txt) with a line per input image . For example:

img_0000.jpeg 1
img_0001.jpeg 0
img_0002.jpeg 0

img_0000.jpeg 1
img_0001.jpeg 0
img_0002.jpeg 0

在这个例子中,第一个图像被标记为1,而另外两个被标记为0.

In this example the first image is labeled 1 while the other two are labeled 0.

在 shell 中运行二进制文件

Run the binary in shell

~$ GLOG_logtostderr=1 $CAFFE_ROOT/build/tools/convert_imageset 
    --resize_height=200 --resize_width=200 --shuffle  
    /path/to/jpegs/ 
    /path/to/labels/train.txt 
    /path/to/lmdb/train_lmdb

命令行解释:

  • GLOG_logtostderr 标志设置为 1 before 调用 convert_imageset 表示将日志消息重定向到 stderr 的日志记录机制.
  • --resize_height--resize_width所有 输入图像的大小调整为相同的 200x200.
  • --shuffle 随机改变图像的顺序,不保留/path/to/labels/train.txt 文件中的顺序.
  • 以下是图像文件夹的路径、标签文本文件和输出名称.请注意,在调用 convert_imageset 之前不应存在输出名称,否则您会收到可怕的错误消息.
  • GLOG_logtostderr flag is set to 1 before calling convert_imageset indicates the logging mechanism to redirect log messages to stderr.
  • --resize_height and --resize_width resize all input images to same size 200x200.
  • --shuffle randomly change the order of images and does not preserve the order in the /path/to/labels/train.txt file.
  • Following are the path to the images folder, the labels text file and the output name. Note that the output name should not exist prior to calling convert_imageset otherwise you'll get a scary error message.

其他可能有用的标志:

  • --backend - 允许您在 lmdb 数据集或 levelDB 之间进行选择.
  • --gray - 将所有图像转换为灰度.
  • --encoded--encoded_type - 在数据库中以编码 (jpg/png) 压缩形式保存图像数据.
  • --help - 显示一些帮助,查看 Flags from tools/convert_imageset.cpp 下的所有相关标志
  • --backend - allows you to choose between an lmdb dataset or levelDB.
  • --gray - convert all images to gray scale.
  • --encoded and --encoded_type - keep image data in encoded (jpg/png) compressed form in the database.
  • --help - shows some help, see all relevant flags under Flags from tools/convert_imageset.cpp

您可以查看$CAFFE_ROOT/examples/imagenet/convert_imagenet.sh例如如何使用 convert_imageset.

这篇关于convert_imageset.cpp 指南的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆