Model | Download | Download (with sample test data) | ONNX version | Opset version |
---|---|---|---|---|
GoogleNet | 28 MB | 31 MB | 1.1 | 3 |
GoogleNet | 28 MB | 31 MB | 1.1.2 | 6 |
GoogleNet | 28 MB | 31 MB | 1.2 | 7 |
GoogleNet | 28 MB | 31 MB | 1.3 | 8 |
GoogleNet | 28 MB | 31 MB | 1.4 | 9 |
GoogLeNet is the name of a convolutional neural network for classification, which competed in the ImageNet Large Scale Visual Recognition Challenge in 2014.
Differences:
- not training with the relighting data-augmentation;
- not training with the scale or aspect-ratio data-augmentation;
- uses "xavier" to initialize the weights instead of "gaussian";
Going deeper with convolutions
Caffe BVLC GoogLeNet ==> Caffe2 GoogLeNet ==> ONNX GoogLeNet
data_0: float[1, 3, 224, 224]
prob_0: float[1, 1000]
import imageio
from PIL import Image
def get_image(path):
'''
Using path to image, return the RGB load image
'''
img = imageio.imread(path, pilmode='RGB')
return img
# Pre-processing function for ImageNet models using numpy
def preprocess(img):
'''
Preprocessing required on the images for inference with mxnet gluon
The function takes loaded image and returns processed tensor
'''
img = np.array(Image.fromarray(img).resize((224, 224))).astype(np.float32)
img[:, :, 0] -= 123.68
img[:, :, 1] -= 116.779
img[:, :, 2] -= 103.939
img[:,:,[0,1,2]] = img[:,:,[2,1,0]]
img = img.transpose((2, 0, 1))
img = np.expand_dims(img, axis=0)
return img
def predict(path):
# based on : https://mxnet.apache.org/versions/1.0.0/tutorials/python/predict_image.html
img = get_image(path)
img = preprocess(img)
mod.forward(Batch([mx.nd.array(img)]))
# Take softmax to generate probabilities
prob = mod.get_outputs()[0].asnumpy()
prob = np.squeeze(prob)
a = np.argsort(prob)[::-1]
return a
random generated sample test data:
- test_data_set_0
- test_data_set_1
- test_data_set_2
- test_data_set_3
- test_data_set_4
- test_data_set_5
This bundled model obtains a top-1 accuracy 68.7% (31.3% error) and a top-5 accuracy 88.9% (11.1% error) on the validation set, using just the center crop. (Using the average of 10 crops, (4 + 1 center) * 2 mirror, should obtain a bit higher accuracy.)