• 大小: 96.59MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-25
  • 语言: 其他
  • 标签: tensorflow  ssd  

资源简介

github上的资源转载,为没有注册github账号或者下载没找到资源的道友服务

资源截图

代码片段和文件信息

“““Convert a Caffe model file to TensorFlow checkpoint format.

Assume that the network built is a equivalent (or a sub-) to the Caffe
definition.
“““
import tensorflow as tf

from nets import caffe_scope
from nets import nets_factory

slim = tf.contrib.slim

# =========================================================================== #
# Main flags.
# =========================================================================== #
tf.app.flags.DEFINE_string(
    ‘model_name‘ ‘ssd_300_vgg‘ ‘Name of the model to convert.‘)
tf.app.flags.DEFINE_string(
    ‘num_classes‘ 21 ‘Number of classes in the dataset.‘)
tf.app.flags.DEFINE_string(
    ‘caffemodel_path‘ None
    ‘The path to the Caffe model file to convert.‘)

FLAGS = tf.app.flags.FLAGS


# =========================================================================== #
# Main converting routine.
# =========================================================================== #
def main(_):
    # Caffe scope...
    caffemodel = caffe_scope.CaffeScope()
    caffemodel.load(FLAGS.caffemodel_path)

    tf.logging.set_verbosity(tf.logging.INFO)
    with tf.Graph().as_default():
        global_step = slim.create_global_step()
        num_classes = int(FLAGS.num_classes)

        # Select the network.
        ssd_class = nets_factory.get_network(FLAGS.model_name)
        ssd_params = ssd_class.default_params._replace(num_classes=num_classes)
        ssd_net = ssd_class(ssd_params)
        ssd_shape = ssd_net.params.img_shape

        # Image placeholder and model.
        shape = (1 ssd_shape[0] ssd_shape[1] 3)
        img_input = tf.placeholder(shape=shape dtype=tf.float32)
        # Create model.
        with slim.arg_scope(ssd_net.arg_scope_caffe(caffemodel)):
            ssd_net.net(img_input is_training=False)

        init_op = tf.global_variables_initializer()
        with tf.Session() as session:
            # Run the init operation.
            session.run(init_op)

            # Save model in checkpoint.
            saver = tf.train.Saver()
            ckpt_path = FLAGS.caffemodel_path.replace(‘.caffemodel‘ ‘.ckpt‘)
            saver.save(session ckpt_path write_meta_graph=False)


if __name__ == ‘__main__‘:
    tf.app.run()


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-04-10 13:56  SSD-Tensorflow-master\
     文件         444  2017-04-10 13:56  SSD-Tensorflow-master\.gitignore
     文件       12024  2017-04-10 13:56  SSD-Tensorflow-master\COMMANDS.md
     文件        9293  2017-04-10 13:56  SSD-Tensorflow-master\README.md
     文件        2227  2017-04-10 13:56  SSD-Tensorflow-master\caffe_to_tensorflow.py
     目录           0  2017-04-10 13:56  SSD-Tensorflow-master\checkpoints\
     文件    97721959  2017-04-10 13:56  SSD-Tensorflow-master\checkpoints\ssd_300_vgg.ckpt.zip
     目录           0  2017-04-10 13:56  SSD-Tensorflow-master\datasets\
     文件           1  2017-04-10 13:56  SSD-Tensorflow-master\datasets\__init__.py
     文件        3218  2017-04-10 13:56  SSD-Tensorflow-master\datasets\cifar10.py
     文件        2112  2017-04-10 13:56  SSD-Tensorflow-master\datasets\dataset_factory.py
     文件        4696  2017-04-10 13:56  SSD-Tensorflow-master\datasets\dataset_utils.py
     文件        7483  2017-04-10 13:56  SSD-Tensorflow-master\datasets\imagenet.py
     文件        3403  2017-04-10 13:56  SSD-Tensorflow-master\datasets\pascalvoc_2007.py
     文件        2869  2017-04-10 13:56  SSD-Tensorflow-master\datasets\pascalvoc_2012.py
     文件        4753  2017-04-10 13:56  SSD-Tensorflow-master\datasets\pascalvoc_common.py
     文件        8668  2017-04-10 13:56  SSD-Tensorflow-master\datasets\pascalvoc_to_tfrecords.py
     目录           0  2017-04-10 13:56  SSD-Tensorflow-master\demo\
     文件       78771  2017-04-10 13:56  SSD-Tensorflow-master\demo\000001.jpg
     文件      113300  2017-04-10 13:56  SSD-Tensorflow-master\demo\000002.jpg
     文件      123361  2017-04-10 13:56  SSD-Tensorflow-master\demo\000003.jpg
     文件      102770  2017-04-10 13:56  SSD-Tensorflow-master\demo\000004.jpg
     文件       79789  2017-04-10 13:56  SSD-Tensorflow-master\demo\000006.jpg
     文件       82702  2017-04-10 13:56  SSD-Tensorflow-master\demo\000008.jpg
     文件      106000  2017-04-10 13:56  SSD-Tensorflow-master\demo\000010.jpg
     文件      102396  2017-04-10 13:56  SSD-Tensorflow-master\demo\000022.jpg
     文件      163759  2017-04-10 13:56  SSD-Tensorflow-master\demo\dog.jpg
     文件      141886  2017-04-10 13:56  SSD-Tensorflow-master\demo\eagle.jpg
     文件      133495  2017-04-10 13:56  SSD-Tensorflow-master\demo\horses.jpg
     文件      113880  2017-04-10 13:56  SSD-Tensorflow-master\demo\person.jpg
     文件      447571  2017-04-10 13:56  SSD-Tensorflow-master\demo\street.jpg
............此处省略43个文件信息

评论

共有 条评论