Пример #1
0
	def __init__(self, checkpoint):



		#experiment_name='None', driver_conf=None, memory_fraction=0.18,
		#image_cut=[115, 510]):

		# use_planner=False,graph_file=None,map_file=None,augment_left_right=False,image_cut = [170,518]):

		Agent.__init__(self)
		# This should likely come from global
		#config_gpu = tf.ConfigProto()
		#config_gpu.gpu_options.visible_device_list = '0'

		#config_gpu.gpu_options.per_process_gpu_memory_fraction = memory_fraction
		#self._sess = tf.Session(config=config_gpu)

		# THIS DOES NOT WORK FOR FUSED PLUS LSTM
		#if self._config.number_frames_sequenced > self._config.number_frames_fused:
		#    self._config_train.batch_size = self._config.number_frames_sequenced
		#else:
		#    self._config_train.batch_size = self._config.number_frames_fused

		#self._train_manager = load_system(self._config_train)
		#self._config.train_segmentation = False
		self.model = CoILModel(g_conf.MODEL_NAME)

		self.model.load_state_dict(checkpoint['state_dict'])

		self.model.cuda()

		self.model.eval()
    def __init__(self, city_name):
        self.timer = Timer()

        # Map setup
        self._map = CarlaMap(city_name)
        self._centerlines = Centerlines(city_name)

        # Agent Setup
        Agent.__init__(self)
        self._neural_net = CAL_network()
        self._seq_len = 5  #self._neural_net.model.max_input_shape
        self._state = VehicleState()
        self._agents_present = False

        # Controller setup
        param_path = os.path.dirname(__file__) + '/controller/params/'
        cruise_params = get_params_from_txt(param_path + 'cruise_params.txt')
        self._PID_cruise = PID(*cruise_params)
        follow_params = get_params_from_txt(param_path + 'follow_params.txt')
        self._PID_follow = PID(*follow_params)

        # General Parameter setup
        general_params = get_params_from_txt(param_path + 'general_params.txt')
        self.c, self.d = general_params[0], general_params[1]
        self.Kl_STANLEY = general_params[2]
        self.Kr_STANLEY = general_params[3]
        self.K0_STANLEY = general_params[4]
        self.curve_slowdown = general_params[5]
        self.DELTAl = general_params[6]
        self.DELTAr = general_params[7]
        self.DELTA0 = general_params[8]
        self.EXP_DECAY = general_params[9]
Пример #3
0
    def __init__(self,
                 city_name,
                 avoid_stopping,
                 memory_fraction=0.25,
                 image_cut=[115, 510]):

        Agent.__init__(self)

        scopeName = 'NET'
        scopeName1 = 'First'
        scopeName2 = 'Second'

        self.dropout_vec = [1.0] * 8 + [0.7] * 2 + [0.5] * 2 + [0.5] * 1 + [
            0.5, 1.
        ] * 2

        config_gpu = tf.ConfigProto()

        # GPU to be selected, just take zero , select GPU  with CUDA_VISIBLE_DEVICES

        config_gpu.gpu_options.visible_device_list = '0'

        config_gpu.gpu_options.per_process_gpu_memory_fraction = memory_fraction

        self._image_size = (88, 200, 3)
        self._avoid_stopping = avoid_stopping

        self._sess = tf.Session(config=config_gpu)

        with tf.device('/gpu:0'):
            self._input_images = tf.placeholder("float",
                                                shape=[
                                                    None, self._image_size[0],
                                                    self._image_size[1],
                                                    self._image_size[2]
                                                ],
                                                name="input_image")

            self._input_data = tf.placeholder(tf.float32,
                                              shape=[None, 1],
                                              name="input_speed")

            self._dout = tf.placeholder("float", shape=[len(self.dropout_vec)])

        with tf.variable_scope(scopeName) as scope:
            self._network_tensor = load_imitation_learning_network(
                self._input_images, self._input_data, self._image_size,
                self._dout, scopeName1, scopeName2)

        import os
        dir_path = os.path.dirname(__file__)

        self._models_path = dir_path + '/model/test/'

        # tf.reset_default_graph()
        self._sess.run(tf.global_variables_initializer())

        self.load_model()

        self._image_cut = image_cut
Пример #4
0
    def __init__(self,
                 city_name,
                 avoid_stopping,
                 memory_fraction=0.25,
                 image_cut=[115, 510]):

        Agent.__init__(self)

        self.dropout_vec = [1.0] * 8 + [0.7] * 2 + [0.5] * 2 + [0.5] * 1 + [
            0.5, 1.
        ] * 5

        config_gpu = tf.ConfigProto()

        # GPU to be selected, just take zero , select GPU  with CUDA_VISIBLE_DEVICES

        # config_gpu.gpu_options.visible_device_list = '0'

        # config_gpu.gpu_options.per_process_gpu_memory_fraction = memory_fraction

        self._image_size = (88, 200, 3)
        self._avoid_stopping = avoid_stopping

        self._sess = tf.Session(config=config_gpu)

        with tf.device('/cpu:0'):
            self._input_images = tf.placeholder("float",
                                                shape=[
                                                    None, self._image_size[0],
                                                    self._image_size[1],
                                                    self._image_size[2]
                                                ],
                                                name="input_image")

            self._input_data = []

            self._input_data.append(
                tf.placeholder(tf.float32,
                               shape=[None, 3],
                               name="target_control"))

            self._input_data.append(
                tf.placeholder(tf.float32, shape=[None, 1],
                               name="input_speed"))

            self._dout = tf.placeholder("float", shape=[len(self.dropout_vec)])

        # with tf.name_scope("Network"):
        #     self._network_tensor = make_network()
        self._network_tensor = make_network()
        dir_path = os.path.dirname(__file__)

        self._models_path = dir_path + '/data_fine_tune/'

        # tf.reset_default_graph()
        self._sess.run(tf.global_variables_initializer())

        self.load_model()
        self._image_cut = image_cut
Пример #5
0
    def __init__(self, checkpoint):

        Agent.__init__(self)

        self.checkpoint = checkpoint  # We save the checkpoint for some interesting future use.
        self.model = CoILModel(g_conf.MODEL_NAME)

        self.model.load_state_dict(checkpoint['state_dict'])

        self.model.cuda()
Пример #6
0
    def __init__(self, checkpoint, architecture_name):

        #experiment_name='None', driver_conf=None, memory_fraction=0.18,
        #image_cut=[115, 510]):

        # use_planner=False,graph_file=None,map_file=None,augment_left_right=False,image_cut = [170,518]):

        Agent.__init__(self)
        # This should likely come from global
        #config_gpu = tf.ConfigProto()
        #config_gpu.gpu_options.visible_device_list = '0'

        #config_gpu.gpu_options.per_process_gpu_memory_fraction = memory_fraction
        #self._sess = tf.Session(config=config_gpu)

        # THIS DOES NOT WORK FOR FUSED PLUS LSTM
        #if self._config.number_frames_sequenced > self._config.number_frames_fused:
        #    self._config_train.batch_size = self._config.number_frames_sequenced
        #else:
        #    self._config_train.batch_size = self._config.number_frames_fused

        #self._train_manager = load_system(self._config_train)
        #self._config.train_segmentation = False
        self.architecture_name = architecture_name

        if architecture_name == 'coil_unit':
            self.model_task, self.model_gen = CoILModel('coil_unit')
            self.model_task, self.model_gen = self.model_task.cuda(
            ), self.model_gen.cuda()
        elif architecture_name == 'unit_task_only':
            self.model_task, self.model_gen = CoILModel('unit_task_only')
            self.model_task, self.model_gen = self.model_task.cuda(
            ), self.model_gen.cuda()
        else:
            self.model = CoILModel(architecture_name)
            self.model.cuda()

        if architecture_name == 'wgangp_lsd':
            # print(ckpt, checkpoint['best_loss_iter_F'])
            self.model.load_state_dict(checkpoint['stateF_dict'])
            self.model.eval()
        elif architecture_name == 'coil_unit':
            self.model_task.load_state_dict(checkpoint['task'])
            self.model_gen.load_state_dict(checkpoint['b'])
            self.model_task.eval()
            self.model_gen.eval()
        elif architecture_name == 'coil_icra':
            self.model.load_state_dict(checkpoint['state_dict'])
            self.model.eval()
        elif architecture_name == 'unit_task_only':
            self.model_task.load_state_dict(checkpoint['task_state_dict'])
            self.model_gen.load_state_dict(checkpoint['enc_state_dict'])
            self.model_task.eval()
            self.model_gen.eval()
Пример #7
0
    def __init__(self, city_name, avoid_stopping, memory_fraction=0.25, image_cut=[115, 510]):
        Agent.__init__(self)
        self._image_size = (88, 200, 3)
        self._avoid_stopping = avoid_stopping

        # Reading models and weights

        dir_path = 'E:\GP\org data less'
        self._model_path = dir_path + '/BH1_Nvidia.h5'
        self._weights_path = dir_path + '/BH1_Nividia_at_epoch_40.h5'
        self._image_cut = image_cut
        self.model = keras.models.load_model(self._model_path, custom_objects={'masked_loss_function': masked_loss_function})
        self.model.load_weights(self._weights_path)
Пример #8
0
 def __init__(self,
              city_name,
              args_file='',
              model_file='',
              n_actions=0,
              frameskip=1):
     Agent.__init__(self)
     self.args = self.read_args(args_file)
     self.args.model = model_file
     self.n_actions = n_actions
     self.n_meas = self.compute_n_meas(self.args)
     self.args.town_traintest = city_name
     self.setup_model(self.n_actions, self.n_meas, self.args)
     self.setup_data_preprocessor(self.args)
     self.frameskip = frameskip
     self.step = 0
Пример #9
0
 def __init__(self,
              city_name,
              mode,
              num_control,
              path=None,
              image_cut=[115, 510],
              gpu_fraction=0.75):
     Agent.__init__(self)
     # set keras session
     config_gpu = tf.ConfigProto()
     config_gpu.gpu_options.allow_growth = True
     config_gpu.gpu_options.per_process_gpu_memory_fraction = gpu_fraction
     KTF.set_session(tf.Session(config=config_gpu))
     self.model = None
     self.mode = mode
     self.num_control = num_control
     self.path = path
     self._image_cut = image_cut
     self.init()
Пример #10
0
    def __init__(self,
                 city_name,
                 avoid_stopping,
                 memory_fraction=0.25,
                 image_cut=[115, 510]):

        Agent.__init__(self)
        self.images = list([])
        self.imagenum = 0
        self._image_size = (88, 200, 3)
        self._avoid_stopping = avoid_stopping
        self.network = make_network()
        self._sess = tf.Session(config=tf.ConfigProto(
            log_device_placement=False))
        self._sess.run(tf.global_variables_initializer())
        saver = tf.train.Saver(write_version=saver_pb2.SaverDef.V2)
        saver.restore(self._sess, './agents/imitation/mymodel/epoch-149.ckpt')
        print('hellohellohellohellohellohello')

        self._image_cut = image_cut
    def __init__(self,
                 city_name,
                 task,
                 intersection,
                 save_choice,
                 avoid_stopping,
                 min_frames,
                 max_frames,
                 trajectory_no,
                 memory_fraction=0.25,
                 image_cut=[115, 510],
                 opt=0):

        Agent.__init__(self)

        self.opt = opt
        self.save_choice = save_choice
        self.intersection = intersection
        task = task
        self.trajectory_no = trajectory_no
        self.dataset_pt = "datasets_" + str(
            self.trajectory_no) + "/" + task + "/" + self.intersection + "/"
        self.clean_frame_pt = self.dataset_pt + "clean_frame/"
        self.input_pt = self.dataset_pt + "inputInfo/"
        self.images_save_path = "out_" + self.intersection + "_" + str(
            self.trajectory_no) + "/"
        self.steer_pt = self.dataset_pt + "steer/"
        self.steer_deviation_clean_pt = self.dataset_pt + "steer_deviation_cleanFrame/"
        self.steer_pt_input = self.dataset_pt + "steer_input/"
        self.control_info_pt = self.dataset_pt + "control_input/"
        self.frame_count = 0
        self.min_frames = min_frames
        self.max_frames = max_frames

        if not os.path.exists(self.dataset_pt):
            os.mkdir(self.dataset_pt)
        if not os.path.exists(self.input_pt):
            os.mkdir(self.input_pt)
        if not os.path.exists(self.steer_pt):
            os.mkdir(self.steer_pt)
        if not os.path.exists(self.steer_deviation_clean_pt):
            os.mkdir(self.steer_deviation_clean_pt)

        self.dropout_vec = [1.0] * 8 + [0.7] * 2 + [0.5] * 2 + [0.5] * 1 + [
            0.5, 1.
        ] * 5

        config_gpu = tf.ConfigProto()

        # GPU to be selected, just take zero , select GPU  with CUDA_VISIBLE_DEVICES

        config_gpu.gpu_options.visible_device_list = '0'

        config_gpu.gpu_options.per_process_gpu_memory_fraction = memory_fraction

        self._image_size = (88, 200, 3)
        self._avoid_stopping = avoid_stopping
        """ loading adversary """
        self.city_name = city_name
        self._sess = tf.Session(config=config_gpu)

        with tf.device('/cpu:0'):
            self._input_images = tf.placeholder("float",
                                                shape=[
                                                    None, self._image_size[0],
                                                    self._image_size[1],
                                                    self._image_size[2]
                                                ],
                                                name="input_image")

            self._input_data = []

            self.start = True
            self.frame_count = 0

            self._input_data.append(
                tf.placeholder(tf.float32,
                               shape=[None, 4],
                               name="input_control"))

            self._input_data.append(
                tf.placeholder(tf.float32, shape=[None, 1],
                               name="input_speed"))

            self._dout = tf.placeholder("float", shape=[len(self.dropout_vec)])

        with tf.name_scope("Network"):
            self._network_tensor, self.gradients_steers, self.gradients_acc, self.gradients_brake = load_imitation_learning_network(
                self._input_images, self._input_data, self._image_size,
                self._dout)

        dir_path = os.path.dirname(__file__)

        self._models_path = dir_path + '/model/'

        # tf.reset_default_graph()
        self._sess.run(tf.global_variables_initializer())

        self.load_model()

        self._image_cut = image_cut
Пример #12
0
    def __init__(self,
                 city_name,
                 avoid_stopping,
                 gpu_num=0,
                 memory_fraction=0.25,
                 image_cut=[115, 510]):
        """
        Source: https://github.com/carla-simulator/imitation-learning
        """
        Agent.__init__(self)
        self._image_size = (88, 200, 3)
        self._avoid_stopping = avoid_stopping

        self.dropout_vec = [1.0] * 8 + [0.7] * 2 + [0.5] * 2 + [0.5] * 1 + [
            0.5, 1.
        ] * 5

        config_gpu = tf.ConfigProto()

        #print(tf.test.is_gpu_available())
        #g = input()

        #if tf.test.is_gpu_available():
        #    tf_device = '/gpu:' + str(gpu_num)
        #    # GPU to be selected, just take zero , select GPU  with CUDA_VISIBLE_DEVICES
        #    config_gpu.gpu_options.visible_device_list = '0'
        #    config_gpu.gpu_options.visible_device_list = str(gpu_num)

        #else:
        #    tf_device = '/cpu:0'
        tf_device = '/cpu:0'
        config_gpu.gpu_options.visible_device_list = '0'
        config_gpu.gpu_options.per_process_gpu_memory_fraction = memory_fraction
        self._sess = tf.Session(config=config_gpu)

        with tf.device(tf_device):
            self._input_images = tf.placeholder("float",
                                                shape=[
                                                    None, self._image_size[0],
                                                    self._image_size[1],
                                                    self._image_size[2]
                                                ],
                                                name="input_image")

            self._input_data = []

            self._input_data.append(
                tf.placeholder(tf.float32,
                               shape=[None, 4],
                               name="input_control"))

            self._input_data.append(
                tf.placeholder(tf.float32, shape=[None, 1],
                               name="input_speed"))

            self._dout = tf.placeholder("float", shape=[len(self.dropout_vec)])

        with tf.name_scope("Network"):
            self._network_tensor = load_imitation_learning_network(
                self._input_images, self._input_data, self._image_size,
                self._dout)

        import os
        dir_path = os.path.dirname(__file__)

        self._models_path = dir_path + '/model/'

        # tf.reset_default_graph()
        self._sess.run(tf.global_variables_initializer())

        self.load_model()

        self._image_cut = image_cut