CNN classification models for TensorFlow
The CNN classification model that is trained with TensorFlow must be a single compressed file and contain the correct directory structure and files.
The compressed model file
The compressed model file must contain the following directories and files.
- model.config (file, required)
- source.config (file, required)
- cnet1.config (file, required)
- cnet1 (directory). The cnet1 directory must contain
the following files:
- labels.txt (file, required)
- checkpoint (file, required)
- model.ckpt-10000.data-00000-of-00001 (file, required)
- model.ckpt-10000.index (file, optional)
- model.ckpt-10000.meta (file, required)
Each file must have the correct structure and keywords. The files are described in the following sections.
model.config
The following text is an example of the contents of the model.config file.
Keywords are shown in bold text.
ipc_buffer_size:80000000
use_ipc_buffer:1
gpu_runnable:1
input_field_mapper {
entry {
app_field: "imageFile"
model_field: "image"
}
}
source {
type:"utility.ImageFileSource"
name:"source"
}
sink {
type:"utility.Sink"
name:"sink"
port_num_config{
input_num:1
}
}
module {
type:"tf_classification.TF_ClassificationNet"
name:"cnet1"
}
connection{
from_module:"source"
from_port:"0"
to_module:"cnet1"
to_port:"0"
}
connection{
from_module:"cnet1"
from_port:"0"
to_module:"sink"
to_port:"0"
}
process{
module_group {
module:"cnet1" }
gpu_runnable:1
}
This file must have at least one module that has the tf_classification.TF_ClassificationNet type in input_field_mapper. The module name, for example cnet1, refers to the folder name that contains the CNN model. You can add modules according to your needs. You do not need to change the source information unless you have a different name for the source.config file. If you change the name of source, you need change the module name in the connection correspondingly.
source.config
The contents of the source.config file are as follows. You do not need to
edit the
contents.
param {
name: "image"
value: "color"
}
param {
name: "gray_image"
value: "gray"
}
cnet1.config
The contents of the cnet1.config file are as follows. The name in
param of this configuration file cannot be changed. Value is the variable name
and image size you set when you train the
model.
param {
name: "input_name"
value: 'input'
}
param {
name: "output_name"
value: 'InceptionV3/Predictions/Softmax'
}
param {
name: "resize_width"
value: '299'
}
param {
name: "resize_height"
value: '299'
}
labels.txt
The labels.txt file contains all the class names with which this
classification model is classified. Each class name must be on a separate line, as shown in the
following example.
defect1
defect2
defect3
checkpoint
The contents of the checkpoint file are as follows. This file is generated
automatically when you train the
model.
model_checkpoint_path: "model.ckpt-10000"
all_model_checkpoint_paths: "model.ckpt-10000"