A repository of resources used in our tutorials and guides ⚡️
The scripts & jupyter notebooks in this repository provide Nexus users a guideline for those who may want to load a model for prediction and integrate them into their codebase or modify some parameters instead of using Portal to predict directly.
Firstly, users should clone this repository and change to the resource folder directory.
git clone https://github.com/datature/resources.git
Users can download two kinds of model formats from Nexus currently: Tensorflow model and TFlite model.
- Tensorflow Model - Bounding Box (Direct Download)
- Tensorflow Model - Bounding Box (Datature Hub Download)
- Tensorflow Model - Masks (Direct Download)
- TFLite Model - Bounding Box (Direct Download)
Users can download their trained model directly from Nexus or port the trained model through Datature Hub. Users need two sets of keys for the second method: Model Key
and Project Secret Key
.
To convert that artifact into an exported model for the prediction service, in Nexus, select Artifacts
under Project Overview. Within the artifacts page, select your chosen artifact and model format to generate a model key for deployment by clicking the triple dots box shown below.
You can generate the project secret key on the Nexus platform by going to API Management
and selecting the Generate New Secret
button, as shown below.
python 3.7 =< version =<3.9
Jupyter Notebook
tensorflow >= 2.5.0
Click to expand
Under the scripts/inference/tensorflow/
folder, there are subfolders of different types of computer vision models application or configuration, in Tensorflow
format:
Each of the subfolders contains a standard file structure. Below are descriptions for each file and folder regarding its content or purpose.
input/
: Some sample test images for predictionoutput/
: Output folder to store predicted imagesrequirements.txt
: Python3 dependenciesmodel_architecture/
: All bounding box model architectures offered on Nexus platformpredict.py
: Python script to load downloaded model and obtain predictionstf_xxx.ipynb
: Jupyter notebook script to load model and obtain predictionspredict_hub.py
: Python script to load model directly from Nexus platform
Click to expand
xxx
in the subsequent command prompts represents chosen model architecture, which is also the name of the folders within the model_architecture/
folder.
cd scripts/inference/tensorflow/bounding_box/
pip install -r requirements.txt
cd model_architecture/xxx
python predict.py --input "path_to_input_folder" --output "path_to_output_folder" --width 640 --height 640 --threshold 0.7 --model "path_to_model" --label "path_to_labelmap"
Sample default command
python predict.py --input "./input" --output "./output" --width 640 --height 640 --threshold 0.7 --model "./saved_model" --label "./label_map.pbtxt"
Below is the list of modifiable script parameters and its description.
--input "path_to_input_folder" (Required)
--output "path_to_output_folder" (Required)
--model "path_to_model" (Required)
--label "path_to_labelmap" (Required)
--width "width of image to load" (Optional) (default: 640)
--height "height of image to load" (Optional) (default: 640)
--threshold "confidence threshold" (Optional) (default: 0.7)
pip install jupyter
python -m notebook tf_xxx.ipynb
cd scripts/inference/tensorflow/bounding_box/
pip install -r requirements.txt
cd model_architecture/xxx
python predict_hub.py --input "path_to_input_folder" --output "path_to_output_folder" --threshold 0.7 --secret "Project_secret" --key "Your_model_key"
Sample default command
python predict_hub.py --input "./input" --output "./output" --secret "76d97105923491bfa13c84d74eb5457b3b04dceda19ca009d7af111bd7d05344" --key "f2324a0064025c01da8fe3482177a83a"
Below is the list of modifiable script parameters and its description.
--input "Path to folder that contains input images" (Required) (default:"./input")
--output "Path to folder to store predicted images" (Required)(default:"./output")
--threshold "Prediction confidence threshold" (Optional) (default: 0.7)
--secret "Datature Nexus project secret key" (Required)
--key "Datature Nexus model key" (Required)
Click to expand
xxx
in the subsequent command prompts represents chosen model architecture, which is also the name of the folders within the model_architecture/
folder.
cd scripts/inference/tensorflow/tensorflow/segmentation/
pip install -r requirements.txt
cd model_architecture/xxx
python predict.py --input "path_to_input_folder" --output "path_to_output_folder" --width 1024 --height 1024 --threshold 0.7 --model "path_to_model" --label "path_to_labelmap"
Sample default command
python predict.py --input "./input" --output "./output" --width 1024 --height 1024 --threshold 0.7 --model "./saved_model" --label "./label_map.pbtxt"
Below is the list of modifiable script parameters and its description.
--input "path_to_input_folder" (Required)
--output "path_to_output_folder" (Required)
--model "path_to_model" (Required)
--label "path_to_labelmap" (Required)
--width "width of image to load" (Optional) (default: 1024)
--height "height of image to load" (Optional) (default: 1024)
--threshold "confidence threshold" (Optional) (default: 0.7)
pip install jupyter
python -m notebook tf_xxx.ipynb
Click to expand
Under the scripts/inference/tflite/
folder, there are subfolders of different types of computer vision models application or configuration, in TFLite
format:
Each of the subfolders contains a standard file structure. Below are descriptions for each file and folder regarding its content or purpose.
input/
: Some sample test images for predictionoutput/
: Output folder to store predicted imagesrequirements.txt
: Python3 dependenciesmodel_architecture/
: All bounding box model architectures offered on Nexus platformpredict.py
: Python script to load downloaded model and obtain predictionstflite_xxx.ipynb
: Jupyter notebook script to load model and obtain predictions
Click to expand
xxx
in the subsequent command prompts represents chosen model architecture, which is also the name of the folders within the model_architecture/
folder.
cd scripts/inference/tflite/bounding_box/
pip install -r requirements.txt
cd model_architecture/xxx
python predict.py --input "path_to_input_folder" --output "path_to_output_folder" --width 640 --height 640 --threshold 0.7 --model "path_to_model" --label "path_to_labelmap"
Sample default command
python predict.py --input "./input" --output "./output" --width 640 --height 640 --threshold 0.7 --model "./tf.lite" --label "./label_map.pbtxt"
Below is the list of modifiable script parameters and its description.
--input "path_to_input_folder" (Required)
--output "path_to_output_folder" (Required)
--model "path_to_model" (Required)
--label "path_to_labelmap" (Required)
--width "width of image to load" (Optional) (default: 640)
--height "height of image to load" (Optional) (default: 640)
--threshold "confidence threshold" (Optional) (default: 0.7)
pip install jupyter
python -m notebook tflite_xxx.ipynb