Labels = [] Selected_scores = [] Selected_bboxes = [] filenames = [] for i in range(1,params['num_classes']): selected_shape = tf.shape(selected_scores[i]) label = tf.ones(selected_shape,dtype=tf.int32)*i filename1 = tf.tile(filename,selected_shape) filenames.append(filename1) Labels.append(label) Selected_scores.append(selected_scores[i]) Selected_bboxes.append(selected_bboxes[i]) Selected_bboxes = tf.reshape(tf.stack(Selected_bboxes),[-1,4]) Selected_scores = tf.reshape(tf.stack(Selected_scores),[-1]) Labels = tf.reshape(tf.stack(Labels),[-1]) Filenames = tf.reshape(filenames,[-1]) Selected_mask = tf.greater(Selected_scores,0.0) last_labels = tf.boolean_mask(Labels,Selected_mask) last_filenames = tf.boolean_mask(Filenames,Selected_mask) last_bboxes = tf.boolean_mask(Selected_bboxes,Selected_mask) last_scores=tf.boolean_mask(Selected_scores,Selected_mask) 等价的方法: Selected_mask = tf.where(Selected_mask) last_labels=tf.squeeze(tf.gather(Labels,Selected_mask)) last_scores = tf.squeeze(tf.gather(Selected_scores,Selected_mask)) last_bboxes = tf.squeeze(tf.gather(Selected_bboxes,Selected_mask)) last_filenames = tf.squeeze(tf.gather(Filenames,Selected_mask))
选取目标数据
最新推荐文章于 2022-04-19 21:50:57 发布