1. Prepare the picture
Under caffe / path: create a new folder images
The caffe / images / data / path stores its own image data set:
Divided into train and val, where all the pictures are placed
Second, generate the label file. Txt file production
import os
def IsSubString(SubStrList,Str):
flag=True
for substr in SubStrList:
if not(substr in Str):
flag=False
return flag
#扫面文件
def GetFileList(FindPath,FlagStr=[]):
FileList=[]
FileNames=os.listdir(FindPath)
if len(FileNames)>0:
for fn in FileNames:
if len(FlagStr)>0:
if IsSubString(FlagStr,fn):
fullfilename=os.path.join(FindPath,fn)
FileList.append(fullfilename)
else:
fullfilename=os.path.join(FindPath,fn)
FileList.append(fullfilename)
if len(FileList)>0:
FileList.sort()
return FileList
train_txt=open('train.txt','w')
#制作标签数据,如果是