示例#1
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
示例#2
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()
示例#3
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)
示例#4
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()
示例#5
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