def render(self, ax, args, environment_memory, plan, highest_iou, count_step, count_brick, datetime, iou_min=None, iou_average=None, iter_times=10): ax.clear() plan=self.plan[self.HALF_WINDOW_SIZE:self.HALF_WINDOW_SIZE+self.plan_height,\ self.HALF_WINDOW_SIZE:self.HALF_WINDOW_SIZE+self.plan_width] env_memory=self.environment_memory[self.HALF_WINDOW_SIZE:self.HALF_WINDOW_SIZE+self.plan_height,\ self.HALF_WINDOW_SIZE:self.HALF_WINDOW_SIZE+self.plan_width] background=np.zeros((self.plan_height,self.plan_width)) img=np.stack((env_memory,plan,background),axis=2) plt.imshow(img) plt.plot(self.position_memory[-1][1] - self.HALF_WINDOW_SIZE, self.position_memory[-1][0] - self.HALF_WINDOW_SIZE, "*") IOU = self._iou() # Add the patch to the Axes if iou_min == None: iou_min = IOU if iou_average == None: iou_average = IOU # axe.add_patch(rect) ax.title.set_text('step=%d,used_paint=%d,IOU=%.3f'%(self.count_step, self.count_brick, IOU)) plt.text(0,21.5,'Iou_min_iter_%d = %.3f'%(iter_times,iou_min),color = 'red', fontsize=12) plt.text(0, 20.5, 'Iou_average_iter_%d = %.3f' % (iter_times, iou_average), color='blue', fontsize=12) ax.axis('off') save_plot(args, datetime) plt.draw()
def render(self, ax, args, environment_memory, plan, highest_iou, count_step, count_brick, datetime, iou_min=None, iou_average=None, iter_times=10): x = np.arange(30) ax.set_xlim((-1, 30)) ax.set_ylim((0, 50)) ax.plot(x, plan) print("\tENV STATE: ", environment_memory) ax.title.set_text('step=%d,used_paint=%d,IOU=%.3f' % (count_step, count_brick, highest_iou)) ax.plot(x, plan, color='b') ax.bar(x, environment_memory, color='r') ax.bar(x, environment_memory - 1, color='r') plt.text(12, 46, 'Iou_min_iter_%d = %.3f' % (iter_times, iou_min), color='red', fontsize=10) plt.text(12, 48, 'Iou_average_iter_%d = %.3f' % (iter_times, iou_average), color='blue', fontsize=10) save_plot(args, datetime) # plt.show() plt.close()
def render(self, ax, ax2, args, environment_memory, plan, highest_iou, count_step, count_brick, datetime, iou_min=None, iou_average=None, iter_times=10): ax.clear() ax2.clear() ax.set_xlim(0, self.plan_width) ax.set_ylim(0, self.plan_height) ax.set_zlim(0, self.plan_length) ax2.set_xlabel('X-axis') ax2.set_xlim(-1, self.plan_width) ax2.set_ylabel('Y-axis') ax2.set_ylim(-1, self.plan_height) plan = self.plan[self.HALF_WINDOW_SIZE:self.HALF_WINDOW_SIZE + self.plan_height, self.HALF_WINDOW_SIZE:self.HALF_WINDOW_SIZE + self.plan_width] plan_2d = np.zeros((self.plan_height, self.plan_width)) IOU = self._iou() # if best_env.any(): # env_memory = best_env[self.HALF_WINDOW_SIZE:self.HALF_WINDOW_SIZE + self.plan_height, \ # self.HALF_WINDOW_SIZE:self.HALF_WINDOW_SIZE + self.plan_width] # IOU = best_iou # step = best_step # brick = best_brick # best_posi = position_memo # else: env_memory = self.environment_memory[self.HALF_WINDOW_SIZE:self.HALF_WINDOW_SIZE + self.plan_height, \ self.HALF_WINDOW_SIZE:self.HALF_WINDOW_SIZE + self.plan_width] step = self.count_step brick = self.count_brick best_posi = self.position_memory[-1] env_memory_2d = np.zeros((self.plan_height, self.plan_width)) for i in range(self.plan_height): for j in range(self.plan_width): if plan[i][j] > 0: plan_2d[i][j] = 1 if env_memory[i][j] > 0: env_memory_2d[i][j] = 1 background = np.zeros((self.plan_height, self.plan_width)) img = np.stack((env_memory_2d, plan_2d, background), axis=2) # plot_plan_surface X, Y, Z = self.plot_3d(plan, Env=False) ax.scatter(X, Y, Z, marker='s', s=40, color='r', edgecolor="k",alpha=1) x1, y1, z1 = self.plot_3d(env_memory, Env=True) width = depth = 1 height = np.zeros_like(z1) if x1: ax.bar3d(x1, y1, height, width, depth, z1, color='b', shade=True,alpha=0.15, edgecolor="k") ax.scatter(best_posi[1] - self.HALF_WINDOW_SIZE + 0.5, best_posi[0] - self.HALF_WINDOW_SIZE + 0.5, zs=0, marker="*", color='b', s=50) if iou_min is None: iou_min = IOU if iou_average is None: iou_average = IOU ax.title.set_text('step=%d,used_paint=%d,IOU=%.3f' % (step, brick, IOU)) ax2.text(0, 20, 'Iou_min_iter_%d = %.3f' % (iter_times, iou_min), color='r', fontsize=12) ax2.text(0, 21.2, 'Iou_average_iter_%d = %.3f' % (iter_times, iou_average), color='b', fontsize=12) ax2.axis('off') plt.imshow(img) ax2.plot(best_posi[1] - self.HALF_WINDOW_SIZE, best_posi[0] - self.HALF_WINDOW_SIZE, '*', color='b') save_plot(args, datetime) plt.draw()
def render(self, ax, args, environment_memory, plan, highest_iou, count_step, count_brick, datetime, iou_min=None, iou_average=None, iter_times=10): ax.clear() ax.set_xlabel('X-axis') ax.set_xlim(-1, 30) ax.set_ylabel('Y-axis') ax.set_ylim(0, 50) x = np.arange(self.plan_width) IOU = self._iou() plan = self.plan # print(environment_memory.shape) # env_memory = environment_memory[self.HALF_WINDOW_SIZE:self.plan_width + self.HALF_WINDOW_SIZE] IOU = highest_iou step = count_step brick = count_brick # else: # env_memory = self.environment_memory[0][self.HALF_WINDOW_SIZE:self.plan_width + self.HALF_WINDOW_SIZE] # step = self.count_step # brick = self.count_brick ax.title.set_text('step=%d,used_paint=%d,IOU=%.3f' % (step, brick, IOU)) ax.plot(x, plan, color='b') # print(x.shape, env_memory.shape) ax.bar(x, environment_memory, color='r') if iou_min == None: iou_min = IOU if iou_average == None: iou_average = IOU plt.text(0, 48, 'a=%d,b=%d,c=%.2f' % (self.one_hot[0], self.one_hot[1], self.one_hot[2]), color='g', fontsize=10) plt.text(12, 46, 'Iou_min_iter_%d = %.3f' % (iter_times, iou_min), color='red', fontsize=10) plt.text(12, 48, 'Iou_average_iter_%d = %.3f' % (iter_times, iou_average), color='blue', fontsize=10) save_plot(args, datetime) plt.draw()