人民币面值识别

Flower_In_The_Dream 2019-08-04 22:11
关注文章
提交模型

这里输入代码160 validation_data=val_generator, 161 validation_steps = math.ceil(len(val_paths) / batch_size), 162 callbacks=[checkpointer,reduce], verbose=1) 163 164 #预测并提交 165 def get_test_img(img_paths,Width,Height): 166 X = np.zeros((len(img_paths), Height, Width, channel), dtype=np.uint8) 167 i = 0 168 for img_path in img_paths: 169 img = Image.open(img_path) 170 img = img.convert('RGB') 171 img = img.resize((Width, Height), Image.LANCZOS) 172 arr = np.asarray(img) 173 X[i, :, :, :] = arr 174 i = i + 1 175 return X 176 177 def get_test_batch(X_path, batch_size, Width,Height): 178 179 while 1: 180 for i in range(0, len(X_path), batch_size): 181 X = get_test_img(X_path[i:i+batch_size], Width,Height) 182 yield X 183 184 model.load_weights('../model/best_RMB_model.hdf5') 185 test_generator = get_test_batch(test_paths, batch_size = batch_size, Width = Width, Height = Height) 186 pred = model.predict_generator(test_generator,steps=math.ceil(len(test_paths)/batch_size),verbose=1) 187 print(pred) 188 print(pred.shape) 189 190 index_list = np.argmax(pred,axis = 1) 191 192 label_list = [] 193 for i in range(0,len(index_list)): 194 label_list.append(key_value2[index_list[i]]) 195 label_list = np.array(label_list) 196 197 test_files = os.listdir(test_data_path) 198 new_test_files = [] 199 for file in test_files: 200 new_test_files.append(file) 201 DataFrame_test =pd.DataFrame({'name':new_test_files,'label':label_list.reshape(-1,)}) 202 DataFrame_test.to_csv('../output/submit_one_stage.csv', index = None) 203 204 print('Done') -- 插入 --

{{panelTitle}}
支持Markdown和数学公式,公式格式:\\(...\\)或\\[...\\]

还没有内容

关注微信公众号