Skip to content

Commit ada7e16

Browse files
Merge pull request #62 from AutomecUA/cnn_tf
fix error dividing by 0 in train2a_transfer_learning.py
2 parents feccd51 + 64d3a01 commit ada7e16

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

cnn/scripts/cnn2/train2a_transfer_learning.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def main():
101101

102102
# Change image and store the same angle, with some distortion, both in image and in angle (to increase robustness)
103103
# flipped
104-
center_image_temp = np.expand_dims(cv2.flip(center_image, 1), axis=2)
104+
#center_image_temp = np.expand_dims(cv2.flip(center_image, 1), axis=2)
105105

106106
# images.append(center_image_temp)
107107
# angles.append(-float(line[1]))
@@ -118,8 +118,21 @@ def main():
118118
csvfile.close()
119119

120120

121-
left_to_straight_ratio = total_straight_angles/total_left_angles
122-
right_to_straight_ratio = total_straight_angles/total_right_angles
121+
if total_left_angles == 0:
122+
left_to_straight_ratio = None
123+
else:
124+
left_to_straight_ratio = total_straight_angles/total_left_angles
125+
126+
if total_right_angles == 0:
127+
right_to_straight_ratio = None
128+
else:
129+
right_to_straight_ratio = total_straight_angles/total_right_angles
130+
131+
132+
133+
134+
135+
123136

124137
#print('angles are: ' + str(list(angles)))
125138

0 commit comments

Comments
 (0)