|
| 1 | +#coding:utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | +def plt_bboxes(img, rclasses, rscores, rbboxes, \ |
| 5 | + nms_rclasses, nms_rscores, nms_rbboxes, \ |
| 6 | + all_rclasses, all_rscores, all_rbboxes, \ |
| 7 | + gbboxes, figsize=(10,10), linewidth=1.5): |
| 8 | + Visualize bounding boxes. Largely inspired by SSD-MXNET! |
| 9 | +
|
| 10 | + print('plt.show') |
| 11 | + fig = plt.figure(figsize=figsize) |
| 12 | + plt.imshow(img) |
| 13 | + height = img.shape[0] |
| 14 | + width = img.shape[1] |
| 15 | + colors = dict() |
| 16 | +
|
| 17 | + def plt_r(): |
| 18 | + ''' |
| 19 | + ''' |
| 20 | + print('rclass.shape: ') |
| 21 | + print(rclasses.shape) |
| 22 | + print("rclass id: ") |
| 23 | + print(rclasses[0]) |
| 24 | + for i in range(rclasses.shape[0]): |
| 25 | + cls_id = int(rclasses[i]) |
| 26 | + if cls_id >= 0: |
| 27 | + score = rscores[i] |
| 28 | + if cls_id not in colors: |
| 29 | + colors[cls_id] = (random.random(), random.random(), random.random()) |
| 30 | + ymin = int(rbboxes[i, 0] * height) |
| 31 | + xmin = int(rbboxes[i, 1] * width) |
| 32 | + ymax = int(rbboxes[i, 2] * height) |
| 33 | + xmax = int(rbboxes[i, 3] * width) |
| 34 | + rect = plt.Rectangle((xmin, ymin), xmax - xmin, |
| 35 | + ymax - ymin, fill=False, |
| 36 | + #edgecolor=colors[cls_id], |
| 37 | + edgecolor=(0.9,0.9,0.3), |
| 38 | + linewidth=linewidth) |
| 39 | + plt.gca().add_patch(rect) |
| 40 | +""" |
| 41 | + |
| 42 | +import matplotlib.pyplot as plt |
| 43 | +import numpy as np |
| 44 | + |
| 45 | +def plt_tables(times, epochs, data): |
| 46 | + |
| 47 | + print("plt show") |
| 48 | + fig = plt.figure(figsize=None) |
| 49 | + |
| 50 | + |
| 51 | +def show_plot(times, epochs, data): |
| 52 | + # 折线图 Or Scatter |
| 53 | + plt.figure(figsize=(8,5)) |
| 54 | + plt.plot(epochs, data, marker='ro') |
| 55 | + plt.grid(True) |
| 56 | + plt.xlabel('epochs') |
| 57 | + plt.ylabel('data') |
| 58 | + plt.title('Test') |
| 59 | + plt.show() |
| 60 | + |
| 61 | +def show_scatter(times, epochs, data): |
| 62 | + # scatter |
| 63 | + plt.figure(figsize=(8, 5)) |
| 64 | + # 2-dimensions # |
| 65 | + # plt.scatter(epochs, data, 'o') |
| 66 | + |
| 67 | + # 3-dimensions # |
| 68 | + c = np.random.randint(0,10,100) |
| 69 | + plt.scatter(epochs, data, c=c, marker='o') |
| 70 | + plt.colorbar() |
| 71 | + |
| 72 | + plt.grid(True) |
| 73 | + plt.xlabel('epochs') |
| 74 | + plt.ylabel('data') |
| 75 | + plt.title('Scatter Plot') |
| 76 | + plt.show() |
| 77 | + |
| 78 | +def show_hist(times, epochs, data): |
| 79 | + # histogram |
| 80 | + plt.figure(figsize=(8, 5)) |
| 81 | + # ValueError: `bins` must increase monotonically, when an array |
| 82 | + # plt.hist(data, epochs,label=['1st', '2nd']) |
| 83 | + plt.hist(data, 100,label=['1st']) |
| 84 | + plt.grid(True) |
| 85 | + plt.legend(loc=0) |
| 86 | + # 表示最佳位置显示图例 |
| 87 | + plt.xlabel('epochs') |
| 88 | + plt.ylabel('data') |
| 89 | + plt.title('Test') |
| 90 | + plt.show() |
| 91 | + |
| 92 | + # 两个数据集堆叠的直方图。 |
| 93 | + # plt.hist(y, bins=20, label=['1st', '2nd'], color=['b', 'm'], stacked=True, rwidth=0.8) |
| 94 | + # 参数stacked = True表示堆叠的直方图 |
| 95 | + |
| 96 | + |
| 97 | +def others(): |
| 98 | + ''' |
| 99 | + plt.boxplot(y) 表示用y绘制箱形图; |
| 100 | + plt.grid(True) 表示添加网格; |
| 101 | + plt.setp(ax, xticklabels=['1st', '2nd']) 表示刻度值标签设置为'1st' 和 '2nd' |
| 102 | + ''' |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + pass |
| 107 | + |
| 108 | + |
| 109 | +if __name__ == '__main__': |
| 110 | + epochs = np.array(range(100)) |
| 111 | + # epochs = np.random.rand(100) |
| 112 | + data = np.random.rand(100) |
| 113 | + |
| 114 | + # show_plot(None, epochs, data) |
| 115 | + # show_scatter(None, epochs, data) |
| 116 | + show_hist(None, epochs, data) |
0 commit comments