网上找了好多教程,发现还是原汁原味的好。我的digits是6.1.1版本的
文地址:https://github.com/NVIDIA/DIGITS/blob/v6.1.1/docs/GettingStarted.mdGetting Started
Now that you have successfully installed DIGITS, this guide will teach you the basics of how to use it.By the end, you will have trained a Caffe model to recognize hand-written digits.We will be using the MNIST handwritten digit database as our dataset and LeNet-5 for our network.Both are generously made available by Yann LeCun on his website.
Download the data
Use the following command to download the MNIST dataset onto your server:
$ python -m digits.download_data mnist ~/mnist
Downloading url=http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz ...
Downloading url=http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz ...
Downloading url=http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz ...
Downloading url=http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz ...
Uncompressing file=train-images-idx3-ubyte.gz ...
Uncompressing file=train-labels-idx1-ubyte.gz ...
Uncompressing file=t10k-images-idx3-ubyte.gz ...
Uncompressing file=t10k-labels-idx1-ubyte.gz ...
Reading labels from /home/username/mnist/train-labels.bin ...
Reading images from /home/username/mnist/train-images.bin ...
Reading labels from /home/username/mnist/test-labels.bin ...
Reading images from /home/username/mnist/test-images.bin ...
Dataset directory is created successfully at '/home/username/mnist'
Done after 16.722807169 seconds.
See Standard Datasets for details about this script.
Using the Webapp
Open up a web browser and navigate to the home screen of DIGITS.The server should be at either http://localhost/
(if installed from Deb packages), or http://localhost:5000/
(if using digits-devserver
).
Logging in
Click on Datasets > New Dataset > Images > Classification
.This will lead you to the login page:
NOTE: there is no authentication - you don't even need a password.This is a utility feature, not a security feature.
Creating a Dataset
After logging in, you will be brought to the "New Image Classification Dataset" page.
- Type in the path to the MNIST training images
- You can also add the folder of MNIST test images as a "Separate validation images folder", if you like. Don't use the "test images" fields - test images are not used for anything in DIGITS yet.
- Change the
Image Type
toGrayscale
- Change the
Image size
to 28 x 28 - Give the dataset a name
- Click on the
Create
button
在这个页面的左边,可以设置图片是彩色图片还是灰度图片,如果提供的原始图片大小不一致,还可用Resize Transformation功能转换成一致大小 。从页面中间可以看出,系统默认将训练图片中的25%取出来作为验证集(for validation)。
如果想把用来测试的图片,也生成lmdb, 则把“ separate test image folder" 这个选项选上。
全部设置好后,点击"create" 按钮,开始生成lmdb数据。
While the job is running, you should see the expected completion time on the right side:
注意左上角的Job Directory(工作目录),生成的lmdb文件就放在这个目录下面,大家最好打开这个目录去看看,看一下生成了些什么文件,了解一下运行原理。
在这个界面,我们还可以可视化查看训练和测试的图片,如下图:
train.txt里面存放的是所有训练图片的列表清单,柱状图清晰地显示了10类样本各自的数量。点击" Explorer the db” 即可查看图片。
最后,点击最左上角“ DIGITS" 链接回到网站根目录。
When the job is finished, go back to the home page by clicking DIGITS
in the top left hand part of the page.You should now see your dataset listed under the "Datasets" tab.
Training a Model
经过前面的操作,我们就把数据准备好了。
一、训练一个model
右击右边Models模块的” Images" 按钮 ,选择“classification"
在打开页面右下角可以看到,系统提供了一个caffe model,分别为LeNet, AlexNet, GoogLeNet, 如果使用这三个模型,则所有参数都已经设置好了,就不用再设置了。
Click on Models > New Model > Images > Classification
.This will lead you to the "New Image Classification Model" page.
For this example, do the following:
- Choose the "MNIST" dataset in the
Select Dataset
field - Choose the
LeNet
network in theStandard Networks
tab - Give the model a name
- Click on the
Create
button
While training the model, you should see the expected completion time on the right side:
在训练过程页面,左上角显示了生成的配置文件名称 (放在job目录文件下,默认路径为:/usr/share/digits/digits/jobs/),运行过程中保存的caffemodel快照也保存在这个目录下面。
页面中间显示了训练和测试的数据信息,右面显示了训练所用的时间和gpu使用情况,下面就是一些实时化图表,可以看到训练阶段的loss, 测试阶段的loss和accuracy,相当方便,甚至还可以看到学习率的变化情况,吃惊吧!
模型训练好后,直接就可以在下面进行测试了。
二、测试新来的图片
将页面拖到最下面,选择Upload imager按钮,加载一幅测试图片。在 /home/username/mnist/test/ 下面有大量的测试图片,随便选一张就可以了。
也可以通过在Image URL方框里,输入一张网上的图片地址来进行测试。
加载好测试图片,在 Show visualizations and statistics
选择模式框上点上勾。
点击”Classify One" 按钮就可以开始测试了。
如果你不是对一张图片进行测试,而是一个测试集,则是在" Upload Image List"这个地方,选择测试图片的列表清单文件(如 val.txt)
To test the model, scroll to the bottom of the page.
- Click on the
Upload image
button and choose a file- There are plenty to choose from in
/home/username/mnist/test/
- There are plenty to choose from in
- Or, find an image on the web and paste the URL into the
Image URL
field - Check the
Show visualizations and statistics
box - Click on
Classify One
At the top of the page, DIGITS displays the top five classifications and corresponding confidence values.DIGITS also provides visualizations and statistics about the weights and activations of each layer in your network.
系统会弹出一个新的页面,显示top-5的分类情况 ,同时digits还提供了测试数据与权值的可视化和统计信息。