MCPcopy Create free account
hub / github.com/VCIP-RGBD/DFormer / print_iou

Function print_iou

utils/visualize.py:62–124  ·  view source on GitHub ↗
(iou, freq_IoU, mean_pixel_acc, pixel_acc, class_names=None, show_no_back=False, no_print=False)

Source from the content-addressed store, hash-verified

60
61
62def print_iou(iou, freq_IoU, mean_pixel_acc, pixel_acc, class_names=None, show_no_back=False, no_print=False):
63 n = iou.size
64 lines = []
65 for i in range(n):
66 if class_names is None:
67 cls = "Class %d:" % (i + 1)
68 else:
69 cls = "%d %s" % (i + 1, class_names[i])
70 lines.append("%-8s\t%.3f%%" % (cls, iou[i] * 100))
71 mean_IoU = np.nanmean(iou)
72 mean_IoU_no_back = np.nanmean(iou[1:])
73 # print(len(iou))
74 if show_no_back:
75 lines.append(
76 "---------- %-8s\t%.3f%%\t%-8s\t%.3f%%\t%-8s\t%.3f%%\t%-8s\t%.3f%%\t%-8s\t%.3f%%"
77 % (
78 "mean_IoU",
79 mean_IoU * 100,
80 "mean_IoU_no_back",
81 mean_IoU_no_back * 100,
82 "freq_IoU",
83 freq_IoU * 100,
84 "mean_pixel_acc",
85 mean_pixel_acc * 100,
86 "pixel_acc",
87 pixel_acc * 100,
88 )
89 )
90 else:
91 lines.append(
92 "---------- %-8s\t%.3f%%\t%-8s\t%.3f%%\t%-8s\t%.3f%%\t%-8s\t%.3f%%"
93 % (
94 "mean_IoU",
95 mean_IoU * 100,
96 "freq_IoU",
97 freq_IoU * 100,
98 "mean_pixel_acc",
99 mean_pixel_acc * 100,
100 "pixel_acc",
101 pixel_acc * 100,
102 )
103 )
104 print(
105 "---------- %-8s\t%.3f%%\t%-8s\t%.3f%%\t%-8s\t%.3f%%\t%-8s\t%.3f%%\t%-8s\t%.3f%%"
106 % (
107 "mean_IoU",
108 mean_IoU * 100,
109 "mean_IU_no_back",
110 mean_IoU_no_back * 100,
111 "freq_IoU",
112 freq_IoU * 100,
113 "mean_pixel_acc",
114 mean_pixel_acc * 100,
115 "pixel_acc",
116 pixel_acc * 100,
117 )
118 )
119 line = "\n".join(lines)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected