對于圖像分類的工作,其實深度學習已經(jīng)做的足夠好了。
現(xiàn)在先整理一下數(shù)據(jù)集的整理
然后再是resnet訓練的方式.
再之后會使用一下xception
最后就用tensorflow做以上的事情
1. 制作數(shù)據(jù)集
首先自己的數(shù)據(jù) 按照類別用不同的文件夾整理好。
然后 每個文件夾運行一遍 提取名字加label的操作。
# -*- coding: UTF-8 -*-
import os
import random
path = '/home/deep/dataset/cifar10Dataset-master/data/1'? ? ? ? # 替換為你的路徑
dir = os.listdir(path)? ? ? ? ? ? ? ? ? # dir是目錄下的全部文件
fopen = open('/home/deep/dataset/cifar10Dataset-master/data/1/name.txt', 'w') # 替換為你的路徑
for d in dir:
? ? (filename,extension) = os.path.splitext(d)
? ? if extension == '.png':
? ? string =? d + ' 1\n'? ? #拼接字符串并換行
? ? fopen.write(string)
fopen.close()
print 'Done'
然后 把所有圖片再放到一起,把label合成一個文件夾
1.1 制作Cifar 數(shù)據(jù)集?
https://github.com/Arthur-Shi/cifar10Dataset
1.2 轉(zhuǎn)換cifar數(shù)據(jù)集變成 Lmdb數(shù)據(jù)集
https://github.com/Arthur-Shi/ResNet-on-Cifar10中的scipt文件夾中
有轉(zhuǎn)換方法 并且會數(shù)據(jù)增強的方式去 制作pad數(shù)據(jù)集。
2. Resnet訓練
到caffe的目錄下bulid/tools/
caffe train -solver=solver.prototxt -gpu 0
例如:
./caffe train -solver=/home/deep/py-faster-rcnn/caffe-fast-rcnn/ResNet-on-Cifar10/data_augmentation/20/solver.prototxt -gpu 0