-
Notifications
You must be signed in to change notification settings - Fork 4
/
convert.py
29 lines (21 loc) · 863 Bytes
/
convert.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import numpy as np
import tensorflow as tf
from absl import app, flags, logging
from absl.flags import FLAGS
from models.yolov3 import Yolov3, load_darknet_weights
flags.DEFINE_string('weights', './model_data/yolov3.weights',
'path to input weights file (darknet)')
flags.DEFINE_integer('weights_num_classes', 80, 'number of classes in the model')
flags.DEFINE_string('output', './checkpoints/yolov3.tf',
'path to output weights file (tensorflow)')
# Convert Darknet weights to Tensorflow weights
def main(argv):
yolo = Yolov3(classes=FLAGS.weights_num_classes)
yolo.summary()
logging.info('Model created')
load_darknet_weights(yolo, FLAGS.weights)
logging.info('Weights loaded')
yolo.save_weights(FLAGS.output)
logging.info('Weights saved')
if __name__ == "__main__":
app.run(main)