• 大小: 97.77MB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2022-08-31
  • 语言: Python
  • 标签: target  detec  

资源简介

原来的代码是在jupyter notebook上运行,改为直接python运行,并且加入图片和视频中的目标检测

资源截图

代码片段和文件信息

“““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  2018-09-30 14:57  SSD-Tensorflow-master\
     文件         444  2017-04-10 21:56  SSD-Tensorflow-master\.gitignore
     目录           0  2018-09-30 14:57  SSD-Tensorflow-master\.idea\
     文件         233  2018-09-30 11:11  SSD-Tensorflow-master\.idea\misc.xml
     文件         294  2018-09-30 11:11  SSD-Tensorflow-master\.idea\modules.xml
     文件         459  2018-09-30 11:12  SSD-Tensorflow-master\.idea\SSD-Tensorflow-master.iml
     文件       22607  2018-09-30 14:57  SSD-Tensorflow-master\.idea\workspace.xml
     文件        2227  2017-04-10 21:56  SSD-Tensorflow-master\caffe_to_tensorflow.py
     目录           0  2018-09-30 10:58  SSD-Tensorflow-master\checkpoints\
     文件   105141952  2017-01-26 01:55  SSD-Tensorflow-master\checkpoints\ssd_300_vgg.ckpt.data-00000-of-00001
     文件        3220  2017-01-26 01:55  SSD-Tensorflow-master\checkpoints\ssd_300_vgg.ckpt.index
     文件       12024  2017-04-10 21:56  SSD-Tensorflow-master\COMMANDS.md
     目录           0  2018-09-30 11:05  SSD-Tensorflow-master\datasets\
     文件        3218  2017-04-10 21:56  SSD-Tensorflow-master\datasets\cifar10.py
     文件        2112  2017-04-10 21:56  SSD-Tensorflow-master\datasets\dataset_factory.py
     文件        4696  2017-04-10 21:56  SSD-Tensorflow-master\datasets\dataset_utils.py
     文件        7483  2017-04-10 21:56  SSD-Tensorflow-master\datasets\imagenet.py
     文件        3403  2017-04-10 21:56  SSD-Tensorflow-master\datasets\pascalvoc_2007.py
     文件        2869  2017-04-10 21:56  SSD-Tensorflow-master\datasets\pascalvoc_2012.py
     文件        4753  2017-04-10 21:56  SSD-Tensorflow-master\datasets\pascalvoc_common.py
     文件        8668  2017-04-10 21:56  SSD-Tensorflow-master\datasets\pascalvoc_to_tfrecords.py
     文件           1  2017-04-10 21:56  SSD-Tensorflow-master\datasets\__init__.py
     目录           0  2018-09-30 11:05  SSD-Tensorflow-master\datasets\__pycache__\
     文件        2360  2018-09-30 11:05  SSD-Tensorflow-master\datasets\__pycache__\cifar10.cpython-35.pyc
     文件        1406  2018-09-30 11:05  SSD-Tensorflow-master\datasets\__pycache__\dataset_factory.cpython-35.pyc
     文件        4495  2018-09-30 11:05  SSD-Tensorflow-master\datasets\__pycache__\dataset_utils.cpython-35.pyc
     文件        5927  2018-09-30 11:05  SSD-Tensorflow-master\datasets\__pycache__\imagenet.cpython-35.pyc
     文件        2802  2018-09-30 11:05  SSD-Tensorflow-master\datasets\__pycache__\pascalvoc_2007.cpython-35.pyc
     文件        2317  2018-09-30 11:05  SSD-Tensorflow-master\datasets\__pycache__\pascalvoc_2012.cpython-35.pyc
     文件        3317  2018-09-30 11:05  SSD-Tensorflow-master\datasets\__pycache__\pascalvoc_common.cpython-35.pyc
     文件         106  2018-09-30 11:05  SSD-Tensorflow-master\datasets\__pycache__\__init__.cpython-35.pyc
............此处省略93个文件信息

评论

共有 条评论