Getting Started
This tutorial guides you through the process from setting up SoftNeuro to using it for inference.
Setup
Setup (for Linux)
1. Library and CLI tool setup
※linux_x64 in this section is replaced by linux_armv8 on armv8 archtecture platform
-
cd to the top directory of the SDK.
-
Copy
linux_x64
to a directory of your choice, and add environment variableSOFTNEURO_DIR
to its parent directory. -
Add environment value
PATH
to${SOFTNEURO_DIR}/linux_x64
directory. In bash, these tasks can be performed using the commands shown below:mkdir ~/.softneuro cp -r linux_x64 ~/.softneuro export SOFTNEURO_DIR=~/.softneuro export PATH=${SOFTNEURO_DIR}/linux_x64:${PATH}
-
(Version 5.1 only)If you are using version 5.1, please register license by following steps.
-
(optional)Verify version. If the version is 5.1, follow the steps below.
$ softneuro version SoftNeuro 5.1.0.xxxxxxx
-
Execute
softneuro license
command, and check your User ID.$ softneuro license softneuro:Error: No license key. softneuro:Error: User ID: 12345678-ABCDEFGH.
-
Obtain your license key at the license issuance page with your User ID.
-
Execute
softneuro license --key
with your license key, then your registration will be done.$ softneuro license --key 12345678-90123456-ABCDEFGH-IJKLMNOP
-
-
Install plugin libraries using the plugins command.
$ softneuro plugins --install auto
Please refer to the CLI tool manual for detailed instruction of installing plugins.
2. Python module installation
You also need to install the Python module using pip command.
In Python3.6 env, you might use whl file as below:
$ pip install whl/softneuro-5.2.0-cp36-cp36m-*.whl
The following modules are required for sample code.
$ pip install scipy opencv-python
Setup(for Windows)
1. Library and CLI tool setup
-
cd to the top directory of the SDK.
-
Copy win_x64 to any directory on the target computer, and add environment variable
SOFTNEURO_DIR
to that directory. -
add environment value
PATH
to%SOFTNEURO_DIR%\win_x64
directory. In Windows, the procedure would be as below:- Open the Start Search, type in "env", and choose "Edit the system environment variables".
- Click the "Environment Variables..." button.
- Set the required environment variables.
-
(Version 5.1 only)If you are using version 5.1, please register license by following steps.
-
(optional)Verify version. If the version is 5.1, follow the steps below.
$ softneuro version SoftNeuro 5.1.0.xxxxxxx
-
Execute
softneuro license
command, and check your User ID.$ softneuro license softneuro:Error: No license key. softneuro:Error: User ID: 12345678-ABCDEFGH.
-
Obtain your license key at the license issuance page with your User ID.
-
Execute
softneuro license --key
with your license key, then your registration will be done.$ softneuro license --key 12345678-90123456-ABCDEFGH-IJKLMNOP
-
-
Install plugin libraries using the plugins command.
Please refer to the CLI tool manual for detailed instruction of installing plugins.$ softneuro plugins --install auto
2. Python module installation
Using pip command, install SoftNeuro Python module.
$ pip install whl/softneuro-5.2.0-cp36-cp36m-*.whl
The following modules are required for sample code.
$ pip install scipy opencv-python
Inference using the CLI tool (image classification)
Once the setup procedure above is complete, you can use the SoftNeuro CLI tool for neural inference.
For example, you can run image classification using the model examples/models/mobilenetv2-7.dnn
(MobileNets V2) on the image examples/images/classification_sample.jpg
using run command:
$ softneuro run --top 5 examples/models/mobilenetv2-7.dnn examples/data/classification_sample.jpg
---------------------------------
Top 5 Labels
---------------------------------
# SCORE LABEL
1 0.9996 goose
2 0.0003 black_swan
3 0.0000 drake
4 0.0000 peacock
5 0.0000 American_coot
---------------------------------
Statistics
---------------------------------
FUNCTION AVE(us) MIN(us) MAX(us) #RUN
Dnn_load() 9,395 9,395 9,395 1
Dnn_compile() 23,249 23,249 23,249 1
Dnn_forward() 6,774 6,774 6,774 1
Used memory: 40,955,904 Bytes
Inference using Python (image classification)
SoftNeuro comes with an API that can be called from Python code.
The SDK contains code samples that demonstrate how this can be done.
The example for image classification can be executed using the following command:
$ python classification.py ../../models/mobilenetv2-7.dnn ../../data/classification_sample.jpg
[Label Name] : [Probability]
0.goose : 0.9995970129966736
1.black_swan : 0.000263840367551893
2.peacock : 3.83547849196475e-05
3.drake : 3.685235060402192e-05
4.American_coot : 2.5823321266216226e-05
Inference using Python (object detection)
For object detection with sample code, please download pretrained object detection model file from SoftNeuro Model Zoo.
The Python example for object detection using SoftNeuro Python API can be executed using the following command in examples/python/detection
:
※A visualization of the output will be saved with the name result.png
$ python detection.py yolov4.dnn ../../data/detection_sample.jpg
Inference is done.
result.png is saved.
Inference using Python (segmentation)
For object detection with sample code, please download pretrained segmentation model file from SoftNeuro Model Zoo.
The Python example for segmentation using SoftNeuro Python API can be executed using the following command in examples/python/segmentation
:
※A visualization of the output will be saved with the name result.png and blended.png
$ python segmentation.py duc.dnn ../../data/segmentation_sample.png
Inference is done.
result.png and blended.png are saved.