Skip to content

Instantly share code, notes, and snippets.

#Optimize the safety model
python3 /opt/intel/openvino/deployment_tools/tools/model_optimizer/mo_caffe.py --input_model <path to caffemodel file> --input_proto <path to prototxt file> -o <specify the output directory>
#Optimize the mask model
python3 /opt/intel/openvino/deployment_tools/tools/model_optimizer/mo_caffe.py --input_model <path to caffemodel file> --input_proto <path to prototxt file> -o <specify the output directory>
@Tob-iee
Tob-iee / gist:4ef845f60651cda66e1d8fb858604ed8
Last active September 21, 2020 08:07
download models from OpenVINO's model directory
#Navigate to the model downloader directory and download the models
#Download the person detection model
python3 /opt/intel/openvino/deployment_tools/tools/model_downloader/downloader.py --name "person-detection-retail-0013"
#Download the face detection model
python /opt/intel/openvino/deployment_tools/tools/model_downloader/downloader.py --name "face-detection-adas-binary-0001"
@Tob-iee
Tob-iee / .cc
Last active May 30, 2022 16:39
This is the file responsible for running all processes of all the above programs from the audio capture to blinking lights.
#include "tensorflow/lite/micro/examples/micro_speech/main_functions.h"
#include "tensorflow/lite/micro/examples/micro_speech/audio_provider.h"
#include "tensorflow/lite/micro/examples/micro_speech/command_responder.h"
#include "tensorflow/lite/micro/examples/micro_speech/feature_provider.h"
#include "tensorflow/lite/micro/examples/micro_speech/micro_features/micro_model_settings.h"
#include "tensorflow/lite/micro/examples/micro_speech/micro_features/model.h"
#include "tensorflow/lite/micro/examples/micro_speech/recognize_commands.h"
#include "tensorflow/lite/micro/kernels/micro_ops.h"
#include "tensorflow/lite/micro/micro_error_reporter.h"
@Tob-iee
Tob-iee / .cc
Created May 30, 2022 16:44
This defines the classes that exist in the model
#include "tensorflow/lite/micro/examples/micro_speech/micro_features/micro_model_settings.h"
const char* kCategoryLabels[kCategoryCount] = {
"silence",
"unknown",
"yes",
"no",
};
@Tob-iee
Tob-iee / .cc
Created May 30, 2022 16:55
model file in cc format
#include "tensorflow/lite/micro/examples/micro_speech/micro_features/model.h"
// We need to keep the data array aligned on some architectures.
#ifdef __has_attribute
#define HAVE_ATTRIBUTE(x) __has_attribute(x)
#else
#define HAVE_ATTRIBUTE(x) 0
#endif
#if HAVE_ATTRIBUTE(aligned) || (defined(__GNUC__) && !defined(__clang__))
#define DATA_ALIGN_ATTRIBUTE __attribute__((aligned(4)))
@Tob-iee
Tob-iee / .yaml
Last active July 12, 2022 21:29
data_preprocessor
stages:
ELT:
cmd: python src/data_preprocessor.py -s train test valid -o "./data_store/data/American
Sign Language Letters.v1-v1.tfrecord"
deps:
- src/data_preprocessor.py
outs:
- ./data_store/data/American Sign Language Letters.v1-v1.tfrecord
feature_tranform-train:
cmd: python src/train.py -dt True
@Tob-iee
Tob-iee / get_labels.py
Created September 13, 2023 13:56
Get the label names for the training dataset version from its label objects.
labels = train_dataset_version.list_labels()
label_names = [label.name for label in labels]
@Tob-iee
Tob-iee / coco_format_loader.py
Created September 13, 2023 14:00
Built, write and read annotations in COCO format using the COCO library
def coco_format_loader(train_dataset_version, label_names, coco_annotations_path):
coco_annotation = train_dataset_version.build_coco_file_locally(
enforced_ordered_categories=label_names
)
annotations_dict = coco_annotation.dict()
with open(coco_annotations_path, "w") as f:
f.write(json.dumps(annotations_dict))
annotations_coco = COCO(coco_annotations_path)
return annotations_coco
@Tob-iee
Tob-iee / label_map.py
Created September 13, 2023 14:01
Create a label map of the labels and their respective “ids” from the COCO annotation categories.
cats = annotations_coco.cats
id2label = {str(k): v['name'] for k,v in cats.items()}
label2id = {v: k for k, v in id2label.items()}
@Tob-iee
Tob-iee / label_map_log.py
Created September 13, 2023 14:03
Log the label maps to your Picsellia experiment.
# log dataset labels to the picsellia experiment
experiment.log("labelmap", id2label, type= LogType.TABLE, replace=True)