Python matplotlib.pyplot.cla() Examples
The following are 30
code examples of matplotlib.pyplot.cla().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.pyplot
, or try the search function
.
Example #1
Source File: cam_demo.py From gluon-cv with Apache License 2.0 | 6 votes |
def keypoint_detection(img, detector, pose_net, ctx=mx.cpu(), axes=None): x, img = gcv.data.transforms.presets.yolo.transform_test(img, short=512, max_size=350) x = x.as_in_context(ctx) class_IDs, scores, bounding_boxs = detector(x) plt.cla() pose_input, upscale_bbox = detector_to_alpha_pose(img, class_IDs, scores, bounding_boxs, output_shape=(128, 96), ctx=ctx) if len(upscale_bbox) > 0: predicted_heatmap = pose_net(pose_input) pred_coords, confidence = heatmap_to_coord_alpha_pose(predicted_heatmap, upscale_bbox) axes = plot_keypoints(img, pred_coords, confidence, class_IDs, bounding_boxs, scores, box_thresh=0.5, keypoint_thresh=0.2, ax=axes) plt.draw() plt.pause(0.001) else: axes = plot_image(frame, ax=axes) plt.draw() plt.pause(0.001) return axes
Example #2
Source File: show_boxes.py From Deep-Feature-Flow-Segmentation with MIT License | 6 votes |
def show_boxes(im, dets, classes, scale = 1.0): plt.cla() plt.axis("off") plt.imshow(im) for cls_idx, cls_name in enumerate(classes): cls_dets = dets[cls_idx] for det in cls_dets: bbox = det[:4] * scale color = (rand(), rand(), rand()) rect = plt.Rectangle((bbox[0], bbox[1]), bbox[2] - bbox[0], bbox[3] - bbox[1], fill=False, edgecolor=color, linewidth=2.5) plt.gca().add_patch(rect) if cls_dets.shape[1] == 5: score = det[-1] plt.gca().text(bbox[0], bbox[1], '{:s} {:.3f}'.format(cls_name, score), bbox=dict(facecolor=color, alpha=0.5), fontsize=9, color='white') plt.show() return im
Example #3
Source File: dataset.py From small_norb with MIT License | 6 votes |
def explore_random_examples(self, dataset_split): """ Visualize random examples for dataset exploration purposes Parameters ---------- dataset_split: str Dataset split, can be either 'train' or 'test' Returns ------- None """ if self.initialized: subplots = plt.subplots(nrows=1, ncols=2) for i in np.random.permutation(SmallNORBDataset.n_examples): self.data[dataset_split][i].show(subplots) plt.waitforbuttonpress() plt.cla()
Example #4
Source File: cam_demo.py From panoptic-fpn-gluon with Apache License 2.0 | 6 votes |
def keypoint_detection(img, detector, pose_net, ctx=mx.cpu(), axes=None): x, img = gcv.data.transforms.presets.yolo.transform_test(img, short=512, max_size=350) x = x.as_in_context(ctx) class_IDs, scores, bounding_boxs = detector(x) plt.cla() pose_input, upscale_bbox = detector_to_simple_pose(img, class_IDs, scores, bounding_boxs, output_shape=(128, 96), ctx=ctx) if len(upscale_bbox) > 0: predicted_heatmap = pose_net(pose_input) pred_coords, confidence = heatmap_to_coord(predicted_heatmap, upscale_bbox) axes = plot_keypoints(img, pred_coords, confidence, class_IDs, bounding_boxs, scores, box_thresh=0.5, keypoint_thresh=0.2, ax=axes) plt.draw() plt.pause(0.001) else: axes = plot_image(frame, ax=axes) plt.draw() plt.pause(0.001) return axes
Example #5
Source File: show_boxes.py From MANet_for_Video_Object_Detection with Apache License 2.0 | 6 votes |
def show_boxes(im, dets, classes, scale = 1.0): plt.cla() plt.axis("off") plt.imshow(im) for cls_idx, cls_name in enumerate(classes): cls_dets = dets[cls_idx] for det in cls_dets: bbox = det[:4] * scale color = (random.random(), random.random(), random.random()) rect = plt.Rectangle((bbox[0], bbox[1]), bbox[2] - bbox[0], bbox[3] - bbox[1], fill=False, edgecolor=color, linewidth=2.5) plt.gca().add_patch(rect) if cls_dets.shape[1] == 5: score = det[-1] plt.gca().text(bbox[0], bbox[1], '{:s} {:.3f}'.format(cls_name, score), bbox=dict(facecolor=color, alpha=0.5), fontsize=9, color='white') plt.show() return im
Example #6
Source File: test.py From Faster-RCNN_TF with MIT License | 6 votes |
def vis_detections(im, class_name, dets, thresh=0.8): """Visual debugging of detections.""" import matplotlib.pyplot as plt #im = im[:, :, (2, 1, 0)] for i in xrange(np.minimum(10, dets.shape[0])): bbox = dets[i, :4] score = dets[i, -1] if score > thresh: #plt.cla() #plt.imshow(im) plt.gca().add_patch( plt.Rectangle((bbox[0], bbox[1]), bbox[2] - bbox[0], bbox[3] - bbox[1], fill=False, edgecolor='g', linewidth=3) ) plt.gca().text(bbox[0], bbox[1] - 2, '{:s} {:.3f}'.format(class_name, score), bbox=dict(facecolor='blue', alpha=0.5), fontsize=14, color='white') plt.title('{} {:.3f}'.format(class_name, score)) #plt.show()
Example #7
Source File: malware.py From trees with Apache License 2.0 | 6 votes |
def classify(self, features, show=False): recs, _ = features.shape result_shape = (features.shape[0], len(self.root)) scores = np.zeros(result_shape) print scores.shape R = Record(np.arange(recs, dtype=int), features) for i, T in enumerate(self.root): for idxs, result in classify(T, R): for idx in idxs.indexes(): scores[idx, i] = float(result[0]) / sum(result.values()) if show: plt.cla() plt.clf() plt.close() plt.imshow(scores, cmap=plt.cm.gray) plt.title('Scores matrix') plt.savefig(r"../scratch/tree_scores.png", bbox_inches='tight') return scores
Example #8
Source File: utils.py From Pytorch-Networks with MIT License | 6 votes |
def plot_result_data(acc_total, acc_val_total, loss_total, losss_val_total, cfg_path, epoch): import matplotlib.pyplot as plt y = range(epoch) plt.plot(y,acc_total,linestyle="-", linewidth=1,label='acc_train') plt.plot(y,acc_val_total,linestyle="-", linewidth=1,label='acc_val') plt.legend(('acc_train', 'acc_val'), loc='upper right') plt.xlabel("Training Epoch") plt.ylabel("Acc on dataset") plt.savefig('{}/acc.png'.format(cfg_path)) plt.cla() plt.plot(y,loss_total,linestyle="-", linewidth=1,label='loss_train') plt.plot(y,losss_val_total,linestyle="-", linewidth=1,label='loss_val') plt.legend(('loss_train', 'loss_val'), loc='upper right') plt.xlabel("Training Epoch") plt.ylabel("Loss on dataset") plt.savefig('{}/loss.png'.format(cfg_path))
Example #9
Source File: show_boxes.py From kaggle-rsna18 with MIT License | 6 votes |
def show_boxes(im, dets, classes, scale = 1.0): plt.cla() plt.axis("off") plt.imshow(im) for cls_idx, cls_name in enumerate(classes): cls_dets = dets[cls_idx] for det in cls_dets: bbox = det[:4] * scale color = (rand(), rand(), rand()) rect = plt.Rectangle((bbox[0], bbox[1]), bbox[2] - bbox[0], bbox[3] - bbox[1], fill=False, edgecolor=color, linewidth=2.5) plt.gca().add_patch(rect) if cls_dets.shape[1] == 5: score = det[-1] plt.gca().text(bbox[0], bbox[1], '{:s} {:.3f}'.format(cls_name, score), bbox=dict(facecolor=color, alpha=0.5), fontsize=9, color='white') plt.show() return im
Example #10
Source File: test.py From rgz_rcnn with MIT License | 6 votes |
def vis_detections(im, class_name, dets, thresh=0.8): """Visual debugging of detections.""" import matplotlib.pyplot as plt #im = im[:, :, (2, 1, 0)] for i in xrange(np.minimum(10, dets.shape[0])): bbox = dets[i, :4] score = dets[i, -1] if score > thresh: #plt.cla() #plt.imshow(im) plt.gca().add_patch( plt.Rectangle((bbox[0], bbox[1]), bbox[2] - bbox[0], bbox[3] - bbox[1], fill=False, edgecolor='g', linewidth=3) ) plt.gca().text(bbox[0], bbox[1] - 2, '{:s} {:.3f}'.format(class_name, score), bbox=dict(facecolor='blue', alpha=0.5), fontsize=14, color='white') plt.title('{} {:.3f}'.format(class_name, score)) #plt.show()
Example #11
Source File: test.py From DeepSim with MIT License | 6 votes |
def vis_detections(im, class_name, dets, thresh=0.8): """Visual debugging of detections.""" import matplotlib.pyplot as plt #im = im[:, :, (2, 1, 0)] for i in xrange(np.minimum(10, dets.shape[0])): bbox = dets[i, :4] score = dets[i, -1] if score > thresh: #plt.cla() #plt.imshow(im) plt.gca().add_patch( plt.Rectangle((bbox[0], bbox[1]), bbox[2] - bbox[0], bbox[3] - bbox[1], fill=False, edgecolor='g', linewidth=3) ) plt.gca().text(bbox[0], bbox[1] - 2, '{:s} {:.3f}'.format(class_name, score), bbox=dict(facecolor='blue', alpha=0.5), fontsize=14, color='white') plt.title('{} {:.3f}'.format(class_name, score)) #plt.show()
Example #12
Source File: test.py From face-py-faster-rcnn with MIT License | 6 votes |
def vis_detections(im, class_name, dets, thresh=0.3): """Visual debugging of detections.""" import matplotlib.pyplot as plt im = im[:, :, (2, 1, 0)] for i in xrange(np.minimum(10, dets.shape[0])): bbox = dets[i, :4] score = dets[i, -1] if score > thresh: plt.cla() plt.imshow(im) plt.gca().add_patch( plt.Rectangle((bbox[0], bbox[1]), bbox[2] - bbox[0], bbox[3] - bbox[1], fill=False, edgecolor='g', linewidth=3) ) plt.title('{} {:.3f}'.format(class_name, score)) plt.show()
Example #13
Source File: graph_utils.py From coqa-baselines with MIT License | 6 votes |
def plot_metrics(values, yAxis, xAxis, title=None, saveTo=None): colours = ['b', 'g', 'r', 'c', 'm', 'y', 'k'] for i, (train_values, dev_values, metric) in enumerate(values): plt.plot(map(float, train_values), linewidth=2, color=colours[i], linestyle='-', label="Train {}".format(metric)) if dev_values: plt.plot(map(float, dev_values), linewidth=2, color=colours[i], linestyle='--', label="Dev {}".format(metric)) plt.xlabel(xAxis) plt.ylabel(yAxis) if title: plt.title(title) if yAxis == "Loss": plt.legend(loc='upper right', shadow=True, prop={'size': 6}) else: plt.legend(loc='upper left', shadow=True, prop={'size': 6}) assert saveTo plt.savefig("{}".format(saveTo)) plt.cla() plt.clf() plt.close()
Example #14
Source File: test.py From faster-rcnn-resnet with MIT License | 6 votes |
def vis_detections(im, class_name, dets, thresh=0.3): """Visual debugging of detections.""" import matplotlib.pyplot as plt im = im[:, :, (2, 1, 0)] for i in xrange(np.minimum(10, dets.shape[0])): bbox = dets[i, :4] score = dets[i, -1] if score > thresh: plt.cla() plt.imshow(im) plt.gca().add_patch( plt.Rectangle((bbox[0], bbox[1]), bbox[2] - bbox[0], bbox[3] - bbox[1], fill=False, edgecolor='g', linewidth=3) ) plt.title('{} {:.3f}'.format(class_name, score)) plt.show()
Example #15
Source File: lstm_with_tensorflow.py From Neural-Network-Programming-with-TensorFlow with MIT License | 6 votes |
def plot(loss_list, predictions_series, batchX, batchY): plt.subplot(2, 3, 1) plt.cla() plt.plot(loss_list) for batchSeriesIdx in range(5): oneHotOutputSeries = np.array(predictions_series)[:, batchSeriesIdx, :] singleOutputSeries = np.array([(1 if out[0] < 0.5 else 0) for out in oneHotOutputSeries]) plt.subplot(2, 3, batchSeriesIdx + 2) plt.cla() plt.axis([0, backpropagationLength, 0, 2]) left_offset = range(backpropagationLength) plt.bar(left_offset, batchX[batchSeriesIdx, :], width=1, color="blue") plt.bar(left_offset, batchY[batchSeriesIdx, :] * 0.5, width=1, color="red") plt.bar(left_offset, singleOutputSeries * 0.3, width=1, color="green") plt.draw() plt.pause(0.0001)
Example #16
Source File: rnn_with_ms.py From Neural-Network-Programming-with-TensorFlow with MIT License | 6 votes |
def plot(loss_list, predictions_series, batchX, batchY): plt.subplot(2, 3, 1) plt.cla() plt.plot(loss_list) for batchSeriesIdx in range(5): oneHotOutputSeries = np.array(predictions_series)[:, batchSeriesIdx, :] singleOutputSeries = np.array([(1 if out[0] < 0.5 else 0) for out in oneHotOutputSeries]) plt.subplot(2, 3, batchSeriesIdx + 2) plt.cla() plt.axis([0, backpropagationLength, 0, 2]) left_offset = range(backpropagationLength) plt.bar(left_offset, batchX[batchSeriesIdx, :], width=1, color="blue") plt.bar(left_offset, batchY[batchSeriesIdx, :] * 0.5, width=1, color="red") plt.bar(left_offset, singleOutputSeries * 0.3, width=1, color="green") plt.draw() plt.pause(0.0001)
Example #17
Source File: test.py From RetinaNet with MIT License | 6 votes |
def vis_detections(im, class_name, dets, thresh=0.8): """Visual debugging of detections.""" import matplotlib.pyplot as plt #im = im[:, :, (2, 1, 0)] for i in xrange(np.minimum(10, dets.shape[0])): bbox = dets[i, :4] score = dets[i, -1] if score > thresh: #plt.cla() #plt.imshow(im) plt.gca().add_patch( plt.Rectangle((bbox[0], bbox[1]), bbox[2] - bbox[0], bbox[3] - bbox[1], fill=False, edgecolor='g', linewidth=3) ) plt.gca().text(bbox[0], bbox[1] - 2, '{:s} {:.3f}'.format(class_name, score), bbox=dict(facecolor='blue', alpha=0.5), fontsize=14, color='white') plt.title('{} {:.3f}'.format(class_name, score)) #plt.show()
Example #18
Source File: rnn_with_tensorflow.py From Neural-Network-Programming-with-TensorFlow with MIT License | 6 votes |
def plot(loss_list, predictions_series, batchX, batchY): plt.subplot(2, 3, 1) plt.cla() plt.plot(loss_list) for batchSeriesIdx in range(5): oneHotOutputSeries = np.array(predictions_series)[:, batchSeriesIdx, :] singleOutputSeries = np.array([(1 if out[0] < 0.5 else 0) for out in oneHotOutputSeries]) plt.subplot(2, 3, batchSeriesIdx + 2) plt.cla() plt.axis([0, backpropagationLength, 0, 2]) left_offset = range(backpropagationLength) plt.bar(left_offset, batchX[batchSeriesIdx, :], width=1, color="blue") plt.bar(left_offset, batchY[batchSeriesIdx, :] * 0.5, width=1, color="red") plt.bar(left_offset, singleOutputSeries * 0.3, width=1, color="green") plt.draw() plt.pause(0.0001)
Example #19
Source File: draw_plot.py From TaobaoAnalysis with MIT License | 6 votes |
def draw_plot_per_item(draw_func, plots_dir=PLOTS_DIR): """ 每个商品画一个图,保存到文件 :param draw_func: 画图函数,参数:reviews :param plots_dir: 保存图像的文件夹 """ for item in session.query(Item): print(item.id, item.title) filename = '{} {}.png'.format(item.id, item.title) filename = replace_illegal_chars(filename) path = plots_dir + '/' + filename if exists(path): continue draw_func(item.reviews) plt.savefig(path) plt.cla()
Example #20
Source File: BN.py From ML_CIA with MIT License | 6 votes |
def plot_his(inputs, inputs_norm): # plot histogram for the inputs of every layer for j, all_inputs in enumerate([inputs, inputs_norm]): for i, input in enumerate(all_inputs): plt.subplot(2, len(all_inputs), j*len(all_inputs)+(i+1)) plt.cla() if i == 0: the_range = (-7, 10) else: the_range = (-1, 1) plt.hist(input.ravel(), bins=15, range=the_range, color='#FF5733') plt.yticks(()) if j == 1: plt.xticks(the_range) else: plt.xticks(()) ax = plt.gca() ax.spines['right'].set_color('none') ax.spines['top'].set_color('none') plt.title("%s normalizing" % ("Without" if j == 0 else "With")) plt.draw() plt.pause(0.01)
Example #21
Source File: test.py From dpl with MIT License | 6 votes |
def vis_detections(im, class_name, dets, thresh=0.3): """Visual debugging of detections.""" import matplotlib.pyplot as plt im = im[:, :, (2, 1, 0)] for i in xrange(np.minimum(10, dets.shape[0])): bbox = dets[i, :4] score = dets[i, -1] if score > thresh: plt.cla() plt.imshow(im) plt.gca().add_patch( plt.Rectangle((bbox[0], bbox[1]), bbox[2] - bbox[0], bbox[3] - bbox[1], fill=False, edgecolor='g', linewidth=3) ) plt.title('{} {:.3f}'.format(class_name, score)) plt.show()
Example #22
Source File: toy2d_intractable.py From zhusuan with MIT License | 6 votes |
def draw(vmean, vlogstd): from scipy import stats plt.cla() xlimits = [-2, 2] ylimits = [-4, 2] def log_prob(z): z1, z2 = z[:, 0], z[:, 1] return stats.norm.logpdf(z2, 0, 1.35) + \ stats.norm.logpdf(z1, 0, np.exp(z2)) plot_isocontours(ax, lambda z: np.exp(log_prob(z)), xlimits, ylimits) def variational_contour(z): return stats.multivariate_normal.pdf( z, vmean, np.diag(np.exp(vlogstd))) plot_isocontours(ax, variational_contour, xlimits, ylimits) plt.draw() plt.pause(1.0 / 30.0)
Example #23
Source File: test.py From TFFRCNN with MIT License | 6 votes |
def vis_detections(im, class_name, dets, thresh=0.8): """Visual debugging of detections.""" import matplotlib.pyplot as plt #im = im[:, :, (2, 1, 0)] for i in xrange(np.minimum(10, dets.shape[0])): bbox = dets[i, :4] score = dets[i, -1] if score > thresh: #plt.cla() #plt.imshow(im) plt.gca().add_patch( plt.Rectangle((bbox[0], bbox[1]), bbox[2] - bbox[0], bbox[3] - bbox[1], fill=False, edgecolor='g', linewidth=3) ) plt.gca().text(bbox[0], bbox[1] - 2, '{:s} {:.3f}'.format(class_name, score), bbox=dict(facecolor='blue', alpha=0.5), fontsize=14, color='white') plt.title('{} {:.3f}'.format(class_name, score)) #plt.show()
Example #24
Source File: plot_history.py From n2n-watermark-remove with MIT License | 6 votes |
def main(): args = get_args() input_paths = [Path(args.input1).joinpath("history.npz")] if args.input2: input_paths.append(Path(args.input2).joinpath("history.npz")) datum = [(np.array(np.load(str(input_path))["history"], ndmin=1)[0], input_path.parent.name) for input_path in input_paths] metrics = ["val_loss", "val_PSNR"] for metric in metrics: for data, setting_name in datum: plt.plot(data[metric], label=setting_name) plt.xlabel("epochs") plt.ylabel(metric) plt.legend() plt.savefig(metric + ".png") plt.cla()
Example #25
Source File: utils.py From labelKeypoint with GNU General Public License v3.0 | 5 votes |
def draw_label(label, img, label_names, colormap=None): plt.subplots_adjust(left=0, right=1, top=1, bottom=0, wspace=0, hspace=0) plt.margins(0, 0) plt.gca().xaxis.set_major_locator(plt.NullLocator()) plt.gca().yaxis.set_major_locator(plt.NullLocator()) if colormap is None: colormap = label_colormap(len(label_names)) label_viz = label2rgb(label, img, n_labels=len(label_names)) plt.imshow(label_viz) plt.axis('off') plt_handlers = [] plt_titles = [] for label_value, label_name in enumerate(label_names): fc = colormap[label_value] p = plt.Rectangle((0, 0), 1, 1, fc=fc) plt_handlers.append(p) plt_titles.append(label_name) plt.legend(plt_handlers, plt_titles, loc='lower right', framealpha=.5) f = io.BytesIO() plt.savefig(f, bbox_inches='tight', pad_inches=0) plt.cla() plt.close() out_size = (img.shape[1], img.shape[0]) out = PIL.Image.open(f).resize(out_size, PIL.Image.BILINEAR).convert('RGB') out = np.asarray(out) return out
Example #26
Source File: tsne_visual.py From SceneChangeDet with MIT License | 5 votes |
def plot_with_labels(lowDWeights, labels,sz): plt.cla() X_t0,Y_t0 = lowDWeights[0][:,0],lowDWeights[0][:,1] X_t1,Y_t1 = lowDWeights[1][:,0],lowDWeights[1][:,1] for idx,(x_t0,y_t0,x_t1,y_t1,lab) in enumerate(zip(X_t0,Y_t0,X_t1,Y_t1,labels)): c = cm.rainbow(int(255 * idx/sz)) plt.text(x_t0,y_t0,lab,backgroundcolor=c,fontsize=9) plt.text(x_t1,y_t1,lab,backgroundcolor=c,fontsize=9) plt.xlim(X_t0.min(), X_t0.max());plt.ylim(Y_t0.min(), Y_t1.max()); plt.title('Visualize last layer');plt.show();plt.pause(0.01) #for x, y, s in zip(X, Y, labels): #c = cm.rainbow(int(255 * s / 9)); plt.text(x, y, s, backgroundcolor=c, fontsize=9)
Example #27
Source File: tsne_visual.py From SceneChangeDet with MIT License | 5 votes |
def plot_with_labels_feat_cat(lowDWeights, labels,save_dir,title): plt.cla() X,Y = lowDWeights[:,0],lowDWeights[:,1] #plt.scatter(X,Y) for idx,(x,y,lab) in enumerate(zip(X,Y,labels)): color = cm.rainbow(int(255 * lab/2)) #plt.scatter(x,y,color) plt.text(x,y,lab,backgroundcolor=color,fontsize=0) plt.xlim(X.min() *2 , X.max() *2);plt.ylim(Y.min()*2, Y.max()*2) plt.title(title) #plt.show();plt.pause(0.01) plt.savefig(save_dir) print save_dir #for x, y, s in zip(X, Y, labels): #c = cm.rainbow(int(255 * s / 9)); plt.text(x, y, s, backgroundcolor=c, fontsize=9)
Example #28
Source File: tsne_visual.py From SceneChangeDet with MIT License | 5 votes |
def plot_with_labels_feat_cat_without_text(lowDWeights, labels,save_dir): plt.cla() X,Y = lowDWeights[:,0],lowDWeights[:,1] for idx,(x,y,lab) in enumerate(zip(X,Y,labels)): #c = cm.rainbow(int(255 * lab/2)) if lab == 0: plt.plot(x,y,'b') if lab == 1: plt.plot(x,y,'r') #plt.text(x,y,lab,backgroundcolor=c,fontsize=9) plt.xlim(X.min() *2 , X.max() *2);plt.ylim(Y.min()*2, Y.max()*2) plt.title('Visualize last layer') #plt.show();plt.pause(0.01) plt.savefig(save_dir) print save_dir
Example #29
Source File: LidarTestPlot.py From PyLidar3 with MIT License | 5 votes |
def draw(): global is_plot while is_plot: plt.figure(1) plt.cla() plt.ylim(-9000,9000) plt.xlim(-9000,9000) plt.scatter(x,y,c='r',s=8) plt.pause(0.001) plt.close("all")
Example #30
Source File: two_dimensions_plot.py From douglas-quaid with GNU General Public License v3.0 | 5 votes |
def save_fig(self, output_path: pathlib.Path): # plt.show() plt.savefig(output_path, figsize=(20, 20), dpi=200) plt.clf() plt.cla() plt.close()