def _cnn_lstm(self, inputs, state, feature_prev, sum_kernel, config, reuse_variables, is_training = True, lstm=True):
     def make_cell():
         cell = self._get_lstm_cell(config, is_training)
         if is_training and config.keep_prob < 1:
             cell = tf.contrib.rnn.DropoutWrapper(cell, output_keep_prob=config.keep_prob)
         return cell
     with tf.variable_scope(tf.get_variable_scope(), reuse=reuse_variables):
         # instead of using the last feature layer, we want to bring recurrency on other layers
         # 
         _, _, feature = modelEAST.model(inputs, is_training=False)
         if feature_prev is not None:
             # add correlation computation to state, so the state is updated;
             cvt = cost_volume(feature_prev, feature, 5)
             feature_
         if lstm:
             cell = tf.contrib.rnn.MultiRNNCell(
                 [make_cell() for _ in range(config.num_layers)], state_is_tuple=True)
             self._initial_state = cell.zero_state(config.batch_size, tf.float32)
             if state is None:
                 state = self._initial_state
             output, state = cell(feature, state)
             # F_heatmap = slim.conv2d(output, 1, 1, activation_fn=tf.nn.sigmoid, normalizer_fn=None)
             with tf.variable_scope('pred_module', reuse=reuse_variables):
                 F_score = slim.conv2d(output, 1, 1, activation_fn=tf.nn.sigmoid, normalizer_fn=None)
                 # 4 channel of axis aligned bbox and 1 channel rotation angle
                 geo_map = slim.conv2d(output, 4, 1, activation_fn=tf.nn.sigmoid, normalizer_fn=None) * 512
                 angle_map = (slim.conv2d(output, 1, 1, activation_fn=tf.nn.sigmoid, normalizer_fn=None) - 0.5) * np.pi/2 # angle is between [-45, 45]
                 F_geometry = tf.concat([geo_map, angle_map], axis=-1)
             feature_prev = feature
             return F_score, F_geometry, state, feature_prev
         else:
             pass
Exemple #2
0
    def _cnn_lstm(self,
                  inputs,
                  state,
                  config,
                  reuse_variables,
                  is_training=True,
                  lstm=True):
        def make_cell():
            cell = self._get_lstm_cell(config, is_training)
            if is_training and config.keep_prob < 1:
                cell = tf.contrib.rnn.DropoutWrapper(
                    cell, output_keep_prob=config.keep_prob)
            return cell

        with tf.variable_scope(tf.get_variable_scope(), reuse=reuse_variables):
            _, _, feature = modelEAST.model(inputs, is_training=False)
            # by xiaolong Sep. 13th
            # feature_stoped = tf.stop_gradient(feature)
            if lstm:
                cell = tf.contrib.rnn.MultiRNNCell(
                    [make_cell() for _ in range(config.num_layers)],
                    state_is_tuple=True)
                self._initial_state = cell.zero_state(config.batch_size,
                                                      tf.float32)
                if state is None:
                    state = self._initial_state
                output, state = cell(feature, state)
                # F_heatmap = slim.conv2d(output, 1, 1, activation_fn=tf.nn.sigmoid, normalizer_fn=None)
                with tf.variable_scope('pred_module', reuse=reuse_variables):
                    F_score = slim.conv2d(output,
                                          1,
                                          1,
                                          activation_fn=tf.nn.sigmoid,
                                          normalizer_fn=None)
                    # 4 channel of axis aligned bbox and 1 channel rotation angle
                    geo_map = slim.conv2d(output,
                                          4,
                                          1,
                                          activation_fn=tf.nn.sigmoid,
                                          normalizer_fn=None) * 512
                    angle_map = (slim.conv2d(output,
                                             1,
                                             1,
                                             activation_fn=tf.nn.sigmoid,
                                             normalizer_fn=None) -
                                 0.5) * np.pi / 2  # angle is between [-45, 45]
                    F_geometry = tf.concat([geo_map, angle_map], axis=-1)

                return F_score, F_geometry, state
            else:
                pass