本文整理匯總了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 )