Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Config.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import json
from Parameters import ARGS
from Parameters import parse

class Config(dict):
def __init__(self, init_dict=None, ARGS=ARGS, config_file_name=None):
def __init__(self, init_dict=None, parser=parse, config_file_name=None):
"""
Takes in command-line arguments as well as the configuration file and parses them.

Parameters
-----------------
:param init_dict: <dict>: a dictionary of configuration settings to use
:param ARGS: <key-val>: the command-line arguments to take, structured like a dictionary
:param config_file_name: <str>: relative filepath to config file
"""

ARGS = parse()
if init_dict:
self.load_config(init_dict)
config_file_name = './configs/' + (config_file_name or (ARGS and ARGS.config) or '')
Expand Down Expand Up @@ -49,5 +50,3 @@ def load_config(self, kv, ARGS=None):
self[key] = Config(init_dict=kv[key], ARGS=ARGS, config_file_name=None)
else:
self[key] = kv[key]

config = Config()
107 changes: 55 additions & 52 deletions Parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,69 @@
import argparse # default python library for command line argument parsing
import os

parser = argparse.ArgumentParser( # pylint: disable=invalid-name
description='Train DNNs on model car data.',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
def parse():
parser = argparse.ArgumentParser( # pylint: disable=invalid-name
description='Train DNNs on model car data.',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)

parser.add_argument('--gpu', default=-1, type=int, help='Cuda GPU ID')
parser.add_argument('--epoch', default=0, type=int, help='Cuda GPU ID')
parser.add_argument('--batch-size', default=100, type=int)
parser.add_argument('--display', dest='display', action='store_true')
parser.add_argument('--no-display', dest='display', action='store_false')
parser.set_defaults(display=True)
parser.add_argument('--gpu', default=-1, type=int, help='Cuda GPU ID')
parser.add_argument('--epoch', default=0, type=int, help='Cuda GPU ID')
parser.add_argument('--batch-size', default=100, type=int)
parser.add_argument('--display', dest='display', action='store_true')
parser.add_argument('--no-display', dest='display', action='store_false')
parser.set_defaults(display=True)

parser.add_argument('--verbose', default=True, type=bool, help='Debugging mode')
parser.add_argument('--aruco', default=True, type=bool, help='Use Aruco data')
parser.add_argument('--data-path', default='/hostroot/home/dataset/' +
'bair_car_data', type=str)
parser.add_argument('--resume-path', default=None, type=str, help='Path to' +
' resume file containing network state dictionary')
parser.add_argument('--bkup', default=None, type=str, help='Path to' +
' resume file containing network state dictionary')
parser.add_argument('--save-path', default='save', type=str, help='Path to' +
' folder to save net state dictionaries.')
parser.add_argument('--verbose', default=True, type=bool, help='Debugging mode')
parser.add_argument('--aruco', default=True, type=bool, help='Use Aruco data')
parser.add_argument('--data-path', default='/hostroot/home/dataset/' +
'bair_car_data', type=str)
parser.add_argument('--resume-path', default=None, type=str, help='Path to' +
' resume file containing network state dictionary')
parser.add_argument('--bkup', default=None, type=str, help='Path to' +
' resume file containing network state dictionary')
parser.add_argument('--save-path', default='save', type=str, help='Path to' +
' folder to save net state dictionaries.')

# nargs='+' allows for multiple arguments and stores arguments in a list
parser.add_argument(
'--ignore',
default=(
'reject_run',
'left',
'out1_in2',
'play',
'Smyth',
'racing'),
type=str,
nargs='+',
help='Skips these labels in data.')
parser.add_argument(
'--ignore',
default=(
'reject_run',
'left',
'out1_in2',
'play',
'Smyth',
'racing'),
type=str,
nargs='+',
help='Skips these labels in data.')

parser.add_argument('--require-one', default=(), type=str, nargs='+',
help='Skips data without these labels in data.')
parser.add_argument('--use-states', default=(1, 3, 5, 6, 7), type=str,
nargs='+', help='Skips data outside of these states.')
parser.add_argument('--require-one', default=(), type=str, nargs='+',
help='Skips data without these labels in data.')
parser.add_argument('--use-states', default=(1, 3, 5, 6, 7), type=str,
nargs='+', help='Skips data outside of these states.')

parser.add_argument('--nframes', default=8, type=int,
help='# timesteps of camera input')
parser.add_argument('--nsteps', default=10, type=int,
help='# of steps of time to predict in the future')
parser.add_argument('--stride', default=10, type=int,
help="number of timesteps between network predictions")
parser.add_argument('--log-interval', default=1, type=int,
help="Number of batches in between logging")
parser.add_argument('--nframes', default=8, type=int,
help='# timesteps of camera input')
parser.add_argument('--nsteps', default=10, type=int,
help='# of steps of time to predict in the future')
parser.add_argument('--stride', default=10, type=int,
help="number of timesteps between network predictions")
parser.add_argument('--log-interval', default=1, type=int,
help="Number of batches in between logging")

parser.add_argument('--print-moments', default=1000, type=int,
help='# of moments between printing stats')
parser.add_argument('--save-moments', default=400000, type=int,
help='# of moments between printing stats')
parser.add_argument('--print-moments', default=1000, type=int,
help='# of moments between printing stats')
parser.add_argument('--save-moments', default=400000, type=int,
help='# of moments between printing stats')

parser.add_argument('--config', default='default.json', type=str, help='Path of config file to use in ' +
'experiment from ./configs')
parser.add_argument('--config', default='default.json', type=str, help='Path of config file to use in ' +
'experiment from ./configs')

ARGS = parser.parse_args()
ARGS = parser.parse_args()

# Check for $DISPLAY being blank
if 'DISPLAY' not in os.environ:
ARGS.display = False
if 'DISPLAY' not in os.environ:
ARGS.display = False

return ARGS
11 changes: 7 additions & 4 deletions Train.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@
import os
import importlib

from Config import config
from Config import Config

from Dataset import Dataset

import Utils

from torch.autograd import Variable
import torch.nn.utils as nnutils
import torch
Net = importlib.import_module(config['model']['py_path']).Net

def iterate(net, loss_func, optimizer=None, input=None, truth=None, mask=None, train=True):
"""
Encapsulates a training or validation iteration.
"""Encapsulates a training or validation iteration.

:param net: <nn.Module>: network to train
:param optimizer: <torch.optim>: optimizer to use
Expand Down Expand Up @@ -52,6 +51,8 @@ def iterate(net, loss_func, optimizer=None, input=None, truth=None, mask=None, t
return loss.cpu().data[0]

def main():
"""Main training loop"""

# Configure logging
logging.basicConfig(filename=config['logging']['path'], level=logging.DEBUG)
logging.debug(config)
Expand Down Expand Up @@ -169,4 +170,6 @@ def main():
sys.exit(1)

if __name__ == '__main__':
config = Config()
Net = importlib.import_module(config['model']['py_path']).Net
main()
1 change: 0 additions & 1 deletion Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import operator
import time
from Parameters import ARGS
import matplotlib.pyplot as plt
import numpy as np
import torch
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = BDDModelCarTraining
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Binary file added docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file added docs/_build/doctrees/index.doctree
Binary file not shown.
Binary file added docs/_build/doctrees/source/modules.doctree
Binary file not shown.
Binary file added docs/_build/doctrees/source/training.doctree
Binary file not shown.
Binary file added docs/_build/doctrees/source/training.nets.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docs/_build/doctrees/wiki/TX2.doctree
Binary file not shown.
Binary file added docs/_build/doctrees/wiki/computermonitor.doctree
Binary file not shown.
Binary file added docs/_build/doctrees/wiki/computersetup.doctree
Binary file not shown.
Binary file added docs/_build/doctrees/wiki/dataset.doctree
Binary file not shown.
4 changes: 4 additions & 0 deletions docs/_build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: e75c1114160e13dcb17c687f7c4ed2cf
tags: 645f666f9bcd5a90fca523b33c5a78b7
Empty file added docs/_build/html/.nojekyll
Empty file.
Loading