Skip to content

Instantly share code, notes, and snippets.

@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"
#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 / .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 / exp_datasets.py
Last active October 25, 2023 16:57
Download the training dataset versions attached to experiment
attached_datasets = experiment.list_attached_dataset_versions()
train_dataset_version = experiment.get_dataset(train_version_name)
eval_dataset_version = experiment.get_dataset(eval_version_name)
images_dir = os.path.join(os.getcwd(), train_set_local_dir)
if os.path.isdir(train_set_local_dir):
print("dataset version has already been downloaded")
else:
train_dataset_version.download(train_set_local_dir)
@Tob-iee
Tob-iee / init_picsellia.py
Last active October 25, 2023 18:25
Initialize a connection to Picsellia and get experiment
# Initializing picsellia connection
if 'api_token' not in os.environ:
raise Exception("You must set an api_token to run this image")
api_token = os.environ["api_token"]
if "host" not in os.environ:
host = "https://trial.picsellia.com"
else:
host = os.environ["host"]
if "organization_name " not in os.environ:
@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