https://github.com/hszhao/semseg/blob/4f274c3f276778228bc14a4565822d46359f0cc8/util/util.py#L63 This line of code works if there are non-zero instances of intersection between the output and target. There should be a check for this.