#cnn 识别狗狗类别
#用类构造代码
#dog图片的训练、保存
#预测以及结果输出
import os
import numpy as np
from PIL import Image
from keras.models import Sequential
from keras.layers import Convolution2D,Flatten,MaxPooling2D,Dense,Activation
from keras.optimizers import Adam
from keras.utils import np_utils
class PreFile(object):#对数据进行预处理
def __init__(self,DogType):
self.FilePath = FilePath
Self.DogType = DogType
def FileReName(self):
count=0
for type in self.DogType:
subfolder = os.listdir(self.FilePath+type)
for subclass in subfolder:
print('count_class:->>',count)
print(subclass)
print(self.FilePath+type+'/'+subclass) #打印图片路径以及名字
os.rename(self.FilePath+type+'/'+subclass,self.FilePath+type+'/'+str(type_counter)+'_'+str(file_counter)+'.jpg')
count+=1
def FileResize(self,Width,Height,Output_folder):
for type in self.DogType:
print(type)
files = os.listdir(self.FilePath+type)
for i in files:
img_open = Image.open(self.Path+type+
深度学习实战笔记四:在自己处理的数据集上训练CNN网络并进行预测
最新推荐文章于 2024-05-25 20:49:11 发布