11
11
from core .utils import freeze_all , unfreeze_all
12
12
13
13
flags .DEFINE_string ('model' , 'yolov4' , 'yolov4, yolov3' )
14
- flags .DEFINE_string ('weights' , './data /yolov4.weights' , 'pretrained weights' )
14
+ flags .DEFINE_string ('weights' , './scripts /yolov4.weights' , 'pretrained weights' )
15
15
flags .DEFINE_boolean ('tiny' , False , 'yolo or yolo-tiny' )
16
16
17
17
def main (_argv ):
@@ -60,6 +60,7 @@ def main(_argv):
60
60
bbox_tensors .append (bbox_tensor )
61
61
62
62
model = tf .keras .Model (input_layer , bbox_tensors )
63
+ model .summary ()
63
64
64
65
if FLAGS .weights == None :
65
66
print ("Training from scratch" )
@@ -75,6 +76,8 @@ def main(_argv):
75
76
if os .path .exists (logdir ): shutil .rmtree (logdir )
76
77
writer = tf .summary .create_file_writer (logdir )
77
78
79
+ # define training step function
80
+ # @tf.function
78
81
def train_step (image_data , target ):
79
82
with tf .GradientTape () as tape :
80
83
pred_result = model (image_data , training = True )
@@ -92,8 +95,8 @@ def train_step(image_data, target):
92
95
93
96
gradients = tape .gradient (total_loss , model .trainable_variables )
94
97
optimizer .apply_gradients (zip (gradients , model .trainable_variables ))
95
- tf .print ("=> STEP %4d lr: %.6f giou_loss: %4.2f conf_loss: %4.2f "
96
- "prob_loss: %4.2f total_loss: %4.2f" % (global_steps , optimizer .lr .numpy (),
98
+ tf .print ("=> STEP %4d/%4d lr: %.6f giou_loss: %4.2f conf_loss: %4.2f "
99
+ "prob_loss: %4.2f total_loss: %4.2f" % (global_steps , total_steps , optimizer .lr .numpy (),
97
100
giou_loss , conf_loss ,
98
101
prob_loss , total_loss ))
99
102
# update learning rate
0 commit comments