使用mobilenet训练自己的数据
实现背景:keras+ tensorflow
一、数据预处理文件:car2626data.py
import os
import numpy as np
import cv2
import pdb
def load_data():
x_train = np.empty((263171,3,224,224),dtype="float32")
y_train = np.empty((263171,),dtype="uint8")
x_test = np.empty((9940,3,224,224),dtype="float32")
y_test = np.empty((9940,),dtype="uint8")
i = 0
j = 0
for line in open('/home/zhanghh/train_label_year.txt'):
ss = line.split(' ')
ori_img = "/home/zhanghh/data/" + ss[0]
img1 = cv2.imread(ori_img)
img2 = cv2.resize(img1,(224,224),interpolation=cv2.INTER_CUBIC)
arr = np.asarray(img2,dtype="float32")
x_train[i,:,:,:] = [arr[:,:,0],arr[:,:,1],arr[:,:,2]]
y_train[i] = int(ss[-1])
i+=1
y_train = np.reshape(y_train,(len(y_train),1))
for line in open('/home/zhanghh/test_label_year.txt'):
nn = line.split(' ')
or_img = "/home/zha