# TensorFlow-Slim image classification model library
This directory contains code for training and evaluating several
widely used Convolutional Neural Network (CNN) image classification
models using
[tf_slim](https://github.com/google-research/tf-slim/tree/master/tf_slim).
It contains scripts that allow
you to train models from scratch or fine-tune them from pre-trained network
weights. It also contains code for downloading standard image datasets,
converting them
to TensorFlow's native TFRecord format and reading them in using TF-Slim's
data reading and queueing utilities. You can easily train any model on any of
these datasets, as we demonstrate below. We've also included a
[jupyter notebook](https://github.com/tensorflow/models/blob/master/research/slim/slim_walkthrough.ipynb),
which provides working examples of how to use TF-Slim for image classification.
For developing or modifying your own models, see also the [main TF-Slim page](https://github.com/google-research/tf-slim/tree/master/tf_slim).
## Contacts
Maintainers of TF-slim:
* Sergio Guadarrama, github: [sguada](https://github.com/sguada)
## Citation
"TensorFlow-Slim image classification model library"
N. Silberman and S. Guadarrama, 2016.
https://github.com/tensorflow/models/tree/master/research/slim
## Table of contents
<a href="#Install">Installation and setup</a><br>
<a href='#Data'>Preparing the datasets</a><br>
<a href='#Pretrained'>Using pre-trained models</a><br>
<a href='#Training'>Training from scratch</a><br>
<a href='#Tuning'>Fine tuning to a new task</a><br>
<a href='#Eval'>Evaluating performance</a><br>
<a href='#Export'>Exporting Inference Graph</a><br>
<a href='#Troubleshooting'>Troubleshooting</a><br>
# Installation
<a id='Install'></a>
In this section, we describe the steps required to install the appropriate
prerequisite packages.
## Installing latest version of TF-slim
TF-Slim is available as `tf_slim` package. To test that your
installation is working, execute the following command; it should run without
raising any errors.
```
python -c "import tf_slim as slim; eval = slim.evaluation.evaluate_once"
```
## Installing the TF-slim image models library
To use TF-Slim for image classification, you also have to install
the [TF-Slim image models library](https://github.com/tensorflow/models/tree/master/research/slim),
which is not part of the core TF library.
To do this, check out the
[tensorflow/models](https://github.com/tensorflow/models/) repository as follows:
```bash
cd $HOME/workspace
git clone https://github.com/tensorflow/models/
```
This will put the TF-Slim image models library in `$HOME/workspace/models/research/slim`.
(It will also create a directory called
[models/inception](https://github.com/tensorflow/models/tree/master/research/inception),
which contains an older version of slim; you can safely ignore this.)
To verify that this has worked, execute the following commands; it should run
without raising any errors.
```
cd $HOME/workspace/models/research/slim
python -c "from nets import cifarnet; mynet = cifarnet.cifarnet"
```
# Preparing the datasets
<a id='Data'></a>
As part of this library, we've included scripts to download several popular
image datasets (listed below) and convert them to slim format.
Dataset | Training Set Size | Testing Set Size | Number of Classes | Comments
:------:|:---------------:|:---------------------:|:-----------:|:-----------:
Flowers|2500 | 2500 | 5 | Various sizes (source: Flickr)
[Cifar10](https://www.cs.toronto.edu/~kriz/cifar.html) | 60k| 10k | 10 |32x32 color
[MNIST](http://yann.lecun.com/exdb/mnist/)| 60k | 10k | 10 | 28x28 gray
[ImageNet](http://www.image-net.org/challenges/LSVRC/2012/)|1.2M| 50k | 1000 | Various sizes
VisualWakeWords|82783 | 40504 | 2 | Various sizes (source: MS COCO)
## Downloading and converting to TFRecord format
For each dataset, we'll need to download the raw data and convert it to
TensorFlow's native
[TFRecord](https://www.tensorflow.org/versions/r0.10/api_docs/python/python_io.html#tfrecords-format-details)
format. Each TFRecord contains a
[TF-Example](https://github.com/tensorflow/tensorflow/blob/r0.10/tensorflow/core/example/example.proto)
protocol buffer. Below we demonstrate how to do this for the Flowers dataset.
```shell
$ DATA_DIR=/tmp/data/flowers
$ python download_and_convert_data.py \
--dataset_name=flowers \
--dataset_dir="${DATA_DIR}"
```
When the script finishes you will find several TFRecord files created:
```shell
$ ls ${DATA_DIR}
flowers_train-00000-of-00005.tfrecord
...
flowers_train-00004-of-00005.tfrecord
flowers_validation-00000-of-00005.tfrecord
...
flowers_validation-00004-of-00005.tfrecord
labels.txt
```
These represent the training and validation data, sharded over 5 files each.
You will also find the `$DATA_DIR/labels.txt` file which contains the mapping
from integer labels to class names.
You can use the same script to create the mnist, cifar10 and visualwakewords
datasets. However, for ImageNet, you have to follow the instructions
[here](https://github.com/tensorflow/models/blob/master/research/inception/README.md#getting-started).
Note that you first have to sign up for an account at image-net.org. Also, the
download can take several hours, and could use up to 500GB.
## Creating a TF-Slim Dataset Descriptor.
Once the TFRecord files have been created, you can easily define a Slim
[Dataset](https://github.com/google-research/tf-slim/master/tf_slim/data/dataset.py),
which stores pointers to the data file, as well as various other pieces of
metadata, such as the class labels, the train/test split, and how to parse the
TFExample protos. We have included the TF-Slim Dataset descriptors
for
[Flowers](https://github.com/tensorflow/models/blob/master/research/slim/datasets/flowers.py),
[Cifar10](https://github.com/tensorflow/models/blob/master/research/slim/datasets/cifar10.py),
[MNIST](https://github.com/tensorflow/models/blob/master/research/slim/datasets/mnist.py),
[ImageNet](https://github.com/tensorflow/models/blob/master/research/slim/datasets/imagenet.py)
and
[VisualWakeWords](https://github.com/tensorflow/models/blob/master/research/slim/datasets/visualwakewords.py),
An example of how to load data using a TF-Slim dataset descriptor using a
TF-Slim
[DatasetDataProvider](https://github.com/google-research/tf-slim/tree/master/tf_slim/data/dataset_data_provider.py)
is found below:
```python
import tensorflow.compat.v1 as tf
import tf_slim as slim
from datasets import flowers
# Selects the 'validation' dataset.
dataset = flowers.get_split('validation', DATA_DIR)
# Creates a TF-Slim DataProvider which reads the dataset in the background
# during both training and testing.
provider = slim.dataset_data_provider.DatasetDataProvider(dataset)
[image, label] = provider.get(['image', 'label'])
```
## An automated script for processing ImageNet data.
Training a model with the ImageNet dataset is a common request. To facilitate
working with the ImageNet dataset, we provide an automated script for
downloading and processing the ImageNet dataset into the native TFRecord
format.
The TFRecord format consists of a set of sharded files where each entry is a serialized `tf.Example` proto. Each `tf.Example` proto contains the ImageNet image (JPEG encoded) as well as metadata such as label and bounding box information.
We provide a single [script](datasets/download_and_convert_imagenet.sh) for
downloading and converting ImageNet data to TFRecord format. Downloading and
preprocessing the data may take several hours (up to half a day) depending on
your network and computer speed. Please be patient.
To begin, you will need to sign up for an account with [ImageNet]
(http://image-net.org) to gain access to the data. Look for the sign up page,
create an account and request an access key to download the data.
After you have `USERNAME` and `PASSWORD`, you are ready to run our script. Make
sure that your hard disk has at least 500 GB of free space for down
没有合适的资源?快使用搜索试试~ 我知道了~
Swift Swift简单例子,需要配置相关环境才能正常运行
共1596个文件
py:962个
config:111个
md:78个
需积分: 5 0 下载量 152 浏览量
2024-08-12
20:14:04
上传
评论
收藏 31.83MB ZIP 举报
温馨提示
Swift Swift简单例子,需要配置相关环境才能正常运行 【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。 【项目质量】:所有源码都经过严格测试,可以直接运行。功能在确认正常工作后才上传。 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。 【附加价值】:项目具有较高的学习借鉴价值,也可直接拿来修改复刻。对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。 【沟通交流】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。鼓励下载和使用,并欢迎大家互相学习,共同进步。
资源推荐
资源详情
资源评论
收起资源包目录
Swift Swift简单例子,需要配置相关环境才能正常运行 (1596个子文件)
proto_config.asciipb 125B
.bazelrc 3KB
.bazelrc 343B
BUILD 24KB
BUILD 10KB
pcl.BUILD 10KB
BUILD 5KB
flann.BUILD 4KB
BUILD 3KB
BUILD 3KB
BUILD 3KB
BUILD 2KB
BUILD 2KB
hdf5.BUILD 2KB
protobuf.BUILD 1KB
BUILD 1KB
BUILD 1KB
BUILD 985B
eigen.BUILD 628B
pybind11.BUILD 608B
BUILD 605B
icu.BUILD 571B
farmhash.BUILD 493B
BUILD 430B
BUILD 333B
BUILD 230B
BUILD 162B
BUILD 54B
BUILD 51B
BUILD 35B
BUILD 21B
BUILD 0B
repo.bzl 7KB
repo.bzl 6KB
build_def.bzl 3KB
android_configure.bzl 3KB
python_configure.bzl 2KB
repo.bzl 1KB
sequence_string_projection_test.cc 42KB
sequence_string_projection_test.cc 24KB
ssd_utils.cc 22KB
sequence_string_projection.cc 21KB
mobile_ssd_tflite_client.cc 21KB
sequence_string_projection.cc 18KB
denylist_op.cc 17KB
layer_norm.cc 16KB
layer_norm_test.cc 15KB
projection_util.cc 15KB
tf_tflite_diff_test_util.cc 14KB
beam_search.cc 14KB
icp_op_kernel.cc 12KB
denylist_op_test.cc 12KB
sequence_string_projection_op_v2_test.cc 11KB
sequence_string_projection_op_v2.cc 11KB
beam_search_test.cc 10KB
mobile_lstd_tflite_client.cc 9KB
denylist_tokenized_test.cc 8KB
tflite_decoder_handler_test.cc 8KB
denylist_skipgram_test.cc 7KB
tflite_decoder_handler.cc 7KB
expected_value.cc 7KB
mobile_ssd_client.cc 7KB
denylist_subsequence_test.cc 7KB
skipgram_finder.cc 6KB
skipgram_finder_test.cc 6KB
conversion_utils_test.cc 6KB
projection_normalizer_util.cc 6KB
tflite_qrnn_pooling.cc 6KB
pcl_demo.cc 5KB
prado_tflite_example.cc 5KB
denylist_tokenized.cc 5KB
subsequence_finder.cc 5KB
sgnn_projection.cc 5KB
tf_custom_ops.cc 4KB
denylist_subsequence.cc 4KB
denylist_skipgram.cc 4KB
denylist.cc 4KB
sgnn_projection_test.cc 3KB
projection_tokenizer_util.cc 3KB
subsequence_finder_test.cc 3KB
registerer.cc 2KB
conversion_utils.cc 2KB
text_distorter.cc 2KB
file_utils.cc 2KB
sgnn_projection_op_resolver.cc 1KB
command 523B
centernet_hourglass104_512x512_kpts_coco17_tpu-32.config 8KB
centernet_hourglass104_1024x1024_kpts_coco17_tpu-32.config 8KB
centernet_resnet50_v1_fpn_512x512_kpts_coco17_tpu-8.config 8KB
centernet_resnet50_v2_512x512_kpts_coco17_tpu-8.config 8KB
center_net_deepmac_1024x1024_non_voc_only_tpu-128.config 6KB
lstm_ssd_interleaved_mobilenet_v2_imagenet.config 6KB
center_net_deepmac_1024x1024_voc_only_tpu-128.config 6KB
center_net_deepmac_512x512_voc_only_tpu-32.config 6KB
ssd_mobilenet_v1_fpp.config 6KB
lstm_ssd_mobilenet_v1_imagenet.config 5KB
center_net_deepmac_1024x1024_coco_tpu-128.config 5KB
ssd_mobilenet_v2_fullyconv_coco.config 5KB
facessd_mobilenet_v2_quantized_320x320_open_image_v4.config 5KB
ssd_mobilenet_v2_quantized_300x300_coco.config 5KB
共 1596 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16
资源评论
聚财猫猫
- 粉丝: 248
- 资源: 162
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功