Exemple #1
0
# Copy ourselves to outdir to replicate results
if not os.path.exists(outdir):
    os.makedirs(outdir)
shutil.copy(__file__, os.path.join(outdir, 'train.py'))

print('Loading data ... ', end='')
if rotate:
    rotate_transform = datasets.RandomRotate(p=rotate)
else:
    rotate_transform = None
dataset = {}
dataloader = {}
dataset['train'] = datasets.FreiburgRGBDDataset('data',
                                                mode='train',
                                                color=color,
                                                transform=rotate_transform,
                                                seed=42)
dataloader['train'] = DataLoader(dataset['train'],
                                 batch_size=16,
                                 shuffle=True,
                                 num_workers=0)
dataset['val'] = datasets.FreiburgRGBDDataset('data',
                                              mode='val',
                                              color=color,
                                              seed=42)
dataloader['val'] = DataLoader(dataset['val'],
                               batch_size=16,
                               shuffle=True,
                               num_workers=0)
print('OK.')
Exemple #2
0
# Copy ourselves to outdir to replicate results
if not os.path.exists(outdir):
    os.makedirs(outdir)
shutil.copy(__file__, os.path.join(outdir, 'train.py'))

print('Loading data ... ', end='')
if rotate:
    rotate_transform = datasets.RandomRotate(p=rotate)
else:
    rotate_transform = None
dataset = {}
dataloader = {}
dataset['train'] = datasets.FreiburgRGBDDataset('data',
                                                mode='train',
                                                color=None,
                                                transform=None,
                                                seed=42)
dataloader['train'] = DataLoader(dataset['train'],
                                 batch_size=16,
                                 shuffle=True,
                                 num_workers=0)
dataset['val'] = datasets.FreiburgRGBDDataset('data',
                                              mode='val',
                                              color=None,
                                              seed=42)
dataloader['val'] = DataLoader(dataset['val'],
                               batch_size=16,
                               shuffle=True,
                               num_workers=0)
print('OK.')
Exemple #3
0
import numpy as np
import shutil
from torch.autograd import Variable
import torch.nn as nn
import torch.optim as optim

import datasets
import networks

# Variables
dropout = True
color = True
outdir = '/imatge/jdelarica/work/PycharmProjects/TFG/tests_512_100_50_1/sgd_lr0.0001_mom0.0_wd0.0_drop_color'

print('Loading data ... ', end='')
dataset = datasets.FreiburgRGBDDataset('data', mode='test', color=color)
dataloader = DataLoader(dataset, batch_size=16, shuffle=True, num_workers=0)
print('OK.')

print('Creating network ... ', end='')
net = networks.NetFC(nodes=[dataset.get_input_size(), 600, 100, 1],
                     dropout=dropout)
net.load_state_dict(torch.load(os.path.join(outdir, 'net.pkl')))
print('OK.')

print('Creating loss and optimizer ... ', end='')
criterion = nn.BCELoss(size_average=False)
#optimizer = optim.SGD(net.parameters(), lr=lr, momentum=momentum, weight_decay=weight_decay)
print('OK.')

cuda = torch.cuda.is_available()