import matplotlib
import matplotlib.pyplot as plt
import os
import random
import io
import imageio
import glob
import scipy.misc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tensorflow as tf | |
| from object_detection.utils import label_map_util | |
| from object_detection.utils import visualization_utils as viz_utils | |
| import random | |
| from PIL import Image | |
| import numpy as np | |
| import glob | |
| import os | |
| # TO LOAD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from object_detection.utils import config_util | |
| from object_detection.builders import model_builder | |
| #Where to save the SavedModel | |
| output_directory = './try2_trained_model' | |
| #Recover our saved model with the latest checkpoint: | |
| pipeline_config = 'pipeline.config' | |
| #Put the last ckpt from training in here, don't use long pathnames: | |
| model_dir = './trained_checkpoints/ckpt-31' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # echo "blacklist nouveau" | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf > /dev/null | |
| # echo "options nouveau modeset=0" | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf > /dev/null | |
| # sudo update-initramfs -u | |
| sudo apt update | |
| sudo apt -y install build-essential | |
| sudo apt update | |
| sudo apt -y install linux-headers-$(uname -r) |
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam',
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| import cv2 | |
| import tensorflow as tf | |
| import numpy as np | |
| # https://www.tensorflow.org/lite/guide/hosted_models | |
| # http://storage.googleapis.com/download.tensorflow.org/models/tflite/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29.zip | |
| def detect_from_camera(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cv2 | |
| import time | |
| CONFIDENCE_THRESHOLD = 0.2 | |
| NMS_THRESHOLD = 0.4 | |
| COLORS = [(0, 255, 255), (255, 255, 0), (0, 255, 0), (255, 0, 0)] | |
| class_names = [] | |
| with open("classes.txt", "r") as f: | |
| class_names = [cname.strip() for cname in f.readlines()] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # TFLite quantized inference example | |
| # | |
| # Based on: | |
| # https://www.tensorflow.org/lite/performance/post_training_integer_quant | |
| # https://www.tensorflow.org/lite/api_docs/java/org/tensorflow/lite/Tensor.QuantizationParams | |
| import numpy as np | |
| import tensorflow as tf | |
| # Location of tflite model file (float32 or int8 quantized) |
Add these two lines to your ~/.zshrc file:
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
autoload -Uz compinit && compinit
Tested on:
MacOS BigSur Version 11.5.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| author: Timothy C. Arlen | |
| date: 28 Feb 2018 | |
| revised by: Sadjad Asghari Esfeden | |
| date: 10 Sep 2018 | |
| Calculate Mean Average Precision (mAP) for a set of bounding boxes corresponding to specific | |
| image Ids. Usage: |