Пример #1
0
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
import torch.utils.data
import torchvision.transforms as transforms
import torchvision.datasets as datasets

H5_address = '/home/lyq/caffe-master/data_gaze/gaze_detection/h5/'
Save_model_address = '/disks/disk0/linyuqi/model/gaze_2eye_AR/'
BatchSize = 64

gaze_model = model.gaze_model()
gaze_model = nn.DataParallel(gaze_model)
gaze_model.cuda()

img_list_left, img_list_right = dataset.load_all_h5(H5_address)
#print(img_list_left[1])
#print(img_list_right[1])
train_Dataset = dataset.train_gaze_dataset(img_list_left, img_list_right)
test_Dataset = dataset.test_gaze_dataset(img_list_left, img_list_right)
train_loader = torch.utils.data.DataLoader(train_Dataset,
                                           batch_size=BatchSize,
                                           num_workers=6)
test_loader = torch.utils.data.DataLoader(test_Dataset,
                                          batch_size=BatchSize,
                                          num_workers=6)

l1_loss = nn.SmoothL1Loss().cuda()
#l1_loss = nn.MSELoss().cuda()
#optimizer = torch.optim.Adam(gaze_model.parameters(),lr=0.01)
Пример #2
0
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
import torch.utils.data
import torchvision.transforms as transforms
import torchvision.datasets as datasets

H5_address = '/home/lyq/caffe-master/data_gaze/gaze_detection/h5/'
Save_model_address = '/disks/disk0/linyuqi/model/gaze_demo/'

gaze_model = model.gaze_model()
#gaze_model = nn.DataParallel(gaze_model)
gaze_model.cuda()

img_list = dataset.load_all_h5(H5_address)
train_Dataset = dataset.train_gaze_dataset(img_list)
test_Dataset = dataset.test_gaze_dataset(img_list)
train_loader = torch.utils.data.DataLoader(train_Dataset,
                                           batch_size=128,
                                           num_workers=6)
test_loader = torch.utils.data.DataLoader(test_Dataset,
                                          batch_size=128,
                                          num_workers=6)

l1_loss = nn.SmoothL1Loss().cuda()
optimizer = torch.optim.Adam(gaze_model.parameters(), lr=0.001)


def train():
    gaze_model.train()
Пример #3
0
#AR_down_model = model_ns.AR_Net_down()
#AR_down_model = nn.DataParallel(AR_down_model)
#AR_down_model.cuda()

#AR_up_model = model_ns.AR_Net_up()
#AR_up_model = nn.DataParallel(AR_down_model)
#AR_up_model.cuda()

loss_f_ARE = loss_func.loss_f_ARE()
loss_f_ARE.cuda()
loss_f_E = loss_func.loss_f_E()
loss_f_E.cuda()

#img_train_list, img_test_list = dataset.load_all_h5(H5_address)

train_list = dataset.load_all_h5(H5_train_address)
test_list = dataset.load_h5_list(H5_test_address)
train_Dataset = dataset.gaze_train_dataset(train_list)
test_Dataset = dataset.gaze_test_dataset(test_list)
train_loader = torch.utils.data.DataLoader(train_Dataset,
                                           shuffle=True,
                                           batch_size=BatchSize,
                                           num_workers=4)
test_loader = torch.utils.data.DataLoader(test_Dataset,
                                          shuffle=True,
                                          batch_size=BatchSize,
                                          num_workers=4)

#L1_loss = nn.SmoothL1Loss().cuda()
#l1_loss = nn.MSELoss().cuda()
#optimizer = torch.optim.Adam(gaze_model.parameters(),lr=0.01)