本文整理汇总了Python中Data.show_rect方法的典型用法代码示例。如果您正苦于以下问题:Python Data.show_rect方法的具体用法?Python Data.show_rect怎么用?Python Data.show_rect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Data
的用法示例。
在下文中一共展示了Data.show_rect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: predict
# 需要导入模块: import Data [as 别名]
# 或者: from Data import show_rect [as 别名]
def predict(self):
class_num = cfg.Class_num
image_path = cfg.Images_path
with open(r'./Data/test_list.txt','r') as f:
test_index_collect = f.readlines()
for test_index in test_index_collect:
test_index = test_index.strip()
regions = []
results_dic = {}
for cls_index in range(1, class_num+1):
results_dic[cls_index] = []
images, roises, labels = self.data.get_valid_batch(test_index)
feed_dict = {self.net.images: images, self.net.rois: roises}
results, bbox_ = self.sess.run([self.net.logits, self.net.bbox], feed_dict=feed_dict)
print('********************************************')
for index in range(len(results)):
if (np.argmax(results[index][0:class_num])) != 0 and np.max(results[index][0:class_num] > 0.5):
rois = roises[index][1:5] * 16
regions_old = [(rois[0] + rois[2]) / 2.0, (rois[1] + rois[3]) / 2.0, rois[2] - rois[0],
rois[3] - rois[1]]
ind = np.argmax(results[index]) - 1
score = np.max(results[index][0:5])
x_rate, y_rate, w_rate, h_rate = bbox_[index][ind * 4], bbox_[index][ind * 4 + 1], \
bbox_[index][ind * 4 + 2], bbox_[index][ind * 4 + 3]
region_new = [regions_old[0] + regions_old[2] * x_rate, regions_old[1] + regions_old[3] * y_rate,
regions_old[2] * np.exp(w_rate), regions_old[3] * np.exp(h_rate)]
results_dic[ind + 1].append(
[results[index][ind + 1], region_new[0] - region_new[2] / 2.0, region_new[1] - region_new[3] / 2.0,
region_new[0] + region_new[2] / 2.0, region_new[1] + region_new[3] / 2.0])
regions.append([region_new[0] - region_new[2] / 2.0, region_new[1] - region_new[3] / 2.0, region_new[2],
region_new[3], ind + 1, score])
if len(regions) != 0:
print(image_path+test_index+'.jpg')
Data.show_rect(image_path+test_index+'.jpg', regions, test_index)
else:
print('There is no target')
NMS_results = self.NMS(results_dic)
if len(NMS_results) != 0:
Data.show_rect(image_path+test_index+'.jpg', NMS_results, test_index )
NMS_average_results = self.NMS_average(results_dic)
if len(NMS_average_results) != 0:
Data.show_rect(image_path+test_index+'.jpg', NMS_average_results, test_index )