-
Notifications
You must be signed in to change notification settings - Fork 4
/
train.py
54 lines (42 loc) · 1.57 KB
/
train.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
import tensorflow as tf
import keras
from keras import backend as K
import h5py
from keras.callbacks import ModelCheckpoint, LearningRateScheduler
from model import *
###############################################################################
def load():
f = h5py.File('','r')
f.keys()
x = f['x'][:]
y = f['y'][:]
val_x = f['val_x'][:]
val_y = f['val_y'][:]
f.close()
return x, y,val_x,val_y
# dimensions of our images.
img_width, img_height = 224,224
epochs = 50
batch_size = 4
model = net(img_width,img_height)
exit()
model_checkpoint = ModelCheckpoint('D:\\.{val_loss:.3f}.hdf5', monitor='val_loss',verbose=1, save_weights_only=True,period=1,save_best_only=False)
train_continue = 1
if train_continue:
model.load_weights('D:\\RGB.hdf5',by_name=True)
model.load_weights('D:\\depthmodel.hdf5',by_name=True)
model.load_weights('D:\\Depth.hdf5',by_name=True)
mode_lr = keras.callbacks.ReduceLROnPlateau(monitor='val_loss', factor=0.7, patience=1, verbose=1, mode='auto', epsilon=0.0001, cooldown=0, min_lr=0.00001)
images,masks ,val_images,val_y= load()
#images,masks = load()
val_image = val_images[:,:,:,0:3]
print (val_image.shape)
val_deep = val_images[:,:,:,3:6]
print (val_deep.shape)
image = images[:,:,:,0:3]
print (image.shape)
deep = images[:,:,:,3:6]
print (deep.shape)
model.fit([image,deep],masks,batch_size=batch_size,epochs=epochs,verbose=1,validation_data=([val_image,val_deep],val_y),callbacks=[model_checkpoint,mode_lr])