Hello,
I created a simple network for image classification (LeNet) which was trained on MNIST data set. I just added softmax, but that does not have impact on classification. When I classify one image (let’s say “Image with number zero” $PATH/mnist/train/0/08284.png) in digits I have correct predictions ( 0 - 23%, rest is under 9%)
Class number:0 Prediction:23,17%
Class number:5 Prediction:8,54%
Class number:6 Prediction:8,54%
Class number:8 Prediction:8,54%
Class number:9 Prediction:8,54%
and the rest... (Copied from Digits Classify One Image page)
Accuracy of whole network is ±98%. So I downloaded the model and exported the model to UFF format, so I can run my own interference. When I run on Jetson build and run project “sample_uff_mnist” (In TensortRT 4.0.1.6 sources) modifies so it uses my exported UFF model and my own input image (08248.png) the results are pretty bad :
Class number:0 Prediction:9,407872%
Class number:1 Prediction:9,695744%
Class number:2 Prediction:10,561737%
Class number:3 Prediction:10,322227%
Class number:4 Prediction:9,861691%
Class number:5 Prediction:10,206078%
Class number:6 Prediction:9,662967%
Class number:7 Prediction:9,109143%
Class number:8 Prediction:11,636149%
Class number:9 Prediction:9,536383%
When I use the lenet.uff model from TensorRT sources (TensorRT-4.0.1.6/data/mnist/lenet.uff) it correctly predicted, apparently there is some problem/preprocessing on DIGITS side which I can not find out.
Is there something that I am missing? All pictures are in grayscale, so there is no pre processing but converting the images to float. I am NOT using any mean image (image nor pixel), network was trained with Mean - None. Images are 28x28, so resize is not needed as well.
I am running latest DIGITS Container nvcr.io/nvidia/digits 18.10. On Jetson TX2 running Jetpack 3.3. TensorRT is 4.0.1.6. Using C++ API.
Btw. I get the same results on x86_64 desktop with GTX1070. So It is not Jetson dependant.
Network.py from Digits
from model import Tower
from utils import model_property
import tensorflow as tf
import tensorflow.contrib.slim as slim
import utils as digits
class UserModel(Tower):
@model_property
def inference(self):
x = tf.reshape(self.x, shape=[-1, self.input_shape[0], self.input_shape[1], self.input_shape[2]], name="input_node")
# scale (divide by MNIST std)
x = x * 0.0125
with slim.arg_scope([slim.conv2d, slim.fully_connected],
weights_initializer=tf.contrib.layers.xavier_initializer(),
weights_regularizer=slim.l2_regularizer(0.0005)):
model = slim.conv2d(x, 20, [5, 5], padding='VALID', scope='conv1')
model = slim.max_pool2d(model, [2, 2], padding='VALID', scope='pool1')
model = slim.conv2d(model, 50, [5, 5], padding='VALID', scope='conv2')
model = slim.max_pool2d(model, [2, 2], padding='VALID', scope='pool2')
model = slim.flatten(model)
model = slim.fully_connected(model, 500, scope='fc1')
model = slim.dropout(model, 0.5, is_training=self.is_training, scope='do1')
model = slim.fully_connected(model, self.nclasses, activation_fn=None, scope='fc2')
model = tf.nn.softmax(model, name="output_node")
return model
@model_property
def loss(self):
model = self.inference
loss = digits.classification_loss(model, self.y)
accuracy = digits.classification_accuracy(model, self.y)
self.summaries.append(tf.summary.scalar(accuracy.op.name, accuracy))
return loss