The following guide will help you install MXNet-$binding on $OS.
The following are required prerequisites:
- Install $prerequisite:
https://cdn-images-1.medium.com/max/800/1*x5lnmcK-PvjDeXZAfMEsRQ.jpeg |
# inception_predict.py | |
import mxnet as mx | |
import numpy as np | |
import cv2, os, urllib | |
from collections import namedtuple | |
Batch = namedtuple('Batch', ['data']) | |
# Load the symbols for the networks | |
with open('synset.txt', 'r') as f: |
Requirements: | |
Raspberry Pi 3B with Stretch. | |
If you have an existing installation, it must be upgraded to Stretch. | |
Follow these directions to upgrade: https://www.datenreise.de/en/raspberry-pi-raspbian-update-update-jessie-to-stretch/ | |
Format your SD card with SD Card Formatter. | |
Download, unzip, then copy contents of the NOOBS (network install) zip file to SD card. | |
Boot up the Pi and follow the prompts to install the headless Raspbian. | |
Login to the pi with user `pi` and password `raspberry`. |
# To setup initial repo | |
export USER=aaronmarkham | |
export REPO=amazon-sagemaker-examples | |
export REPO_URL=https://github.com/aws/amazon-sagemaker-examples | |
git clone --recursive https://github.com/${USER}/${REPO}.git ${USER}-${REPO} | |
cd ${USER}-${REPO} | |
git remote add upstream ${REPO_URL} | |
# Need to add user/email and auth settings steps |
import mxnet as mx | |
from mxnet.test_utils import download | |
from mxnet.gluon.model_zoo import vision as models | |
gpus = 0 | |
contexts = [mx.gpu(i) for i in range(gpus)] if gpus > 0 else [mx.cpu()] | |
deep_dog_net = models.squeezenet1_1(prefix='deep_dog_', classes=2) | |
deep_dog_net.collect_params().initialize(ctx=contexts) | |
download('https://apache-mxnet.s3-accelerate.amazonaws.com/gluon/models/deep-dog-5a342a6f.params', |
{ | |
0: 'tench, Tinca tinca', | |
1: 'goldfish, Carassius auratus', | |
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias', | |
3: 'tiger shark, Galeocerdo cuvieri', | |
4: 'hammerhead, hammerhead shark', | |
5: 'electric ray, crampfish, numbfish, torpedo', | |
6: 'stingray', | |
7: 'cock', | |
8: 'hen', |
Trying example: test_relu(self=<__main__.TestRelu testMethod=test_relu>, X=array([[-0.7635088 ], | |
[-0.24276257]], dtype=float32), gc=, dc=[]) | |
Trying example: test_relu(self=<__main__.TestRelu testMethod=test_relu>, X=array([[ 0. , 1. ], | |
[ 0.20600842, -0.92744243]], dtype=float32), gc=, dc=[]) | |
Trying example: test_relu(self=<__main__.TestRelu testMethod=test_relu>, X=array([ 0.22169138, -0. , 0. , 0. ], dtype=float32), gc=, dc=[]) | |
Trying example: test_relu(self=<__main__.TestRelu testMethod=test_relu>, X=array([-0.], dtype=float32), gc=, dc=[]) | |
Trying example: test_relu(self=<__main__.TestRelu testMethod=test_relu>, X=array([ 0.], dtype=float32), gc=, dc=[]) | |
Trying example: test_relu(self=<__main__.TestRelu testMethod=test_relu>, X=array([[-0.28297934], | |
[ 0.20971532], | |
[ 0. ]], dtype=float32), gc=, dc=[]) |