The CORAL TPU can be used to speed up Tensorflow on the RPi to give a fairly reasonable rate for computer vision tasks such as object detection, pose estimation, speech recognition.
For examples see: https://coral.ai/models/object-detection/
Sometimes you may need to move PostgreSQL's WAL (write ahead log) file to a new drive. For example to gain better speed if you put it on an SSD or NVME drive, or to gain additional space.
First stop PostgreSQL service:
sudo service postgresql stop
Now make a new folder on the new drive, and move (or copy if have room) the pg_wal directory across:
It's frustrating when you purchase an audio book on Audible but can then only play it back from their apps - which isn't possible if you want to put it on a basic MP3 player to take jogging, cycling, etc.
To get around this you can strip away the DRM using your activation code. So this isn't cracking the code but just removing it, meaning you need to know your own 4bit Audible key.
Steps:
1) download the .aax file from your Audible account
2) use this tool to find your key (drag the .aax file to this page and copy the key it returns)
https://audible-tools.github.io/
3) Install ffmpeg on your PC and then run this command:
where you switch your-key-here to the value you got from the web tool, and the input.aax to the filename of the .aax you downloaded. This generates an output MP4 file in a few seconds which is free from the DRM.
Now you can move it to any suitable player!
---
Shell script to chop .aax into mp3 chapters
#!/bin/bash # Author: http://crunchbang.org/forums/viewtopic.php?id=38748#p414992 # m4bronto # Chapter #0:0: start 0.000000, end 1290.013333 # first _ _ start _ end while [ $# -gt 0 ]; do ffmpeg -i "$1" 2> tmp.txt while read -r first _ _ start _ end; do if [[ $first = Chapter ]]; then read # discard line with Metadata: read _ _ chapter
QUICK guide to enabling Python on an Apache2 Linux server
Assuming Python3 and Apache2 are installed on Ubuntu server.
Firstly enable CGI on Apache|:
sudo a2enmod cgi Next configure Apache2 for the relevant website: sudo nano /etc/apache2/sites-enabled/000-default.conf add the following after the VirtualHosts line:
Step-by-step tutorial on training object detection models on your custom dataset
Object detection is one of the most profound aspects of computer vision as it allows you to locate, identify, count and track any object-of-interest in images and videos. Object detection is used extensively in many interesting areas of work and study such as:
autonomous vehicles
security
pedestrian/crowd detection
plate number and vehicle detection
industrial automation (E.g item picking and sorting)
robotics and more.
A number of pre-collected object detection datasets such as Pascal VOC, Microsoft’s COCO,Google’s Open Images are readily available along with their pre-trained models for detection and identifying only a fix set of items.
However, the challenge with using these public datasets and pre-trained models is that they do not provide a convenient way for you to easily train new object detection models to detect and identify your desired object(s) of interest. Since the past one year that I published my first Object Detection article “Object Detection with 10 lines of code”, I have received thousands of request from developers, teams, students and researchers who desire to detect their own objects-of-interest in images and videos, beyond the 80 classes provided in the COCO dataset and 600 classes provided in the Open Images dataset.
I am most glad to announce that with the latest release of ImageAI v2.1.0, support for training your custom YOLOv3 models to detect literally any kind and number of objects is now fully supported, and that is what we will guide you to do in this tutorial. Let’s get started.
For the purpose of this tutorial, we will be using Google Colab to train on a sample dataset we have provided. Follow the steps below.
Step 1 — Preparing your dataset
For your custom detection training, you have to provide sample images ( your image dataset ) for training your model and validating the model after training for accuracy. ImageAI detection training supports the Pascal VOC format for your custom dataset. For the purpose of this tutorial, we have provided a sample dataset for the Hololens Mixed Reality headset, on which we will train a model that can detect and identify the Hololens in pictures and videos. You can download the sample dataset via the link below.
If you want to train on your own images for your custom object(s), follow the instructions below.
Decide the type of object(s) you want to detect and collect about 200 (minimum recommendation) or more pictures of each of the object(s)
Once you have collected the images, you need to annotate the object(s) in the images. ImageAI uses the Pascal VOC format for image annotation. You can generate this annotation for your images by following a step-by-step tutorial we have provided via the link below.
Once you have the annotations for all your images, create a folder for your dataset (E.g headsets) and in this parent folder, create child folders train and validation
In the train folder, create images and annotations sub-folders. Put about 70–80% of your dataset images in the images folder and put the corresponding annotations for these images in the annotations folder
In the validation folder, create images and annotations sub-folders. Put the rest of your dataset images in the images folder and put the corresponding annotations for these images in the annotations folder
Once you have done this, the structure of your image dataset folder should look like the sample below:
For the purpose of this training, install Tensorflow GPU version 1.13.1. This is because the default Tensorflow GPU version installed on your notebook does generate a ‘_TfDeviceCaptureOp’ object has no attribute ‘_set_device_from_string’ error when training your model. If you receive a prompt that your notebook requires a restart after the installation, do restart your notebook after the installation.
!pip3 install tensorflow-gpu==1.13.1
Then install the latest version of ImageAI from PIP
!pip3 install imageai --upgrade
Step 3 — Initiate your detection model training
To ensure that our trained custom models have better detection accuracy, we will be using transfer learning from a pre-trained YOLOv3 model in the training. ImageAI provides the option to train with and without transfer learning. I will strongly recommend you use transfer learning except you have thousands of object samples in your dataset.
SIMPLE! The above 6-lines of code is all you need to initiate the training on your custom dataset. Now let’s break down the code to its part:
In the first line, we import the “DetectionModelTrainer” class from ImageAI
In the 2nd and 3rd lines, we created an instance of the class and set our model type to YOLOv3
In the 4th line, we set the path to our custom dataset
In the 5th line, we specified the following parameters:
— object_names_array: This is an array of the names of all the objects in your dataset. Please note that if your custom dataset annotation has more than one object, simple set the values as shown in the example below
— batch_size: This is the batch size for the training. Kindly note that the larger the batch size, the better the detection accuracy of the saved models. However, due to memory limits on the Nvidia K80 GPU available on Colab, we have to keep this value as 4. The batch size can be values of 8, 16 and so on.
— num_experiments: This is the number of times we want the training code to iterate on our custom dataset.
— train_from_pretrained_model: This is used to leverage transfer learning using the pretrained YOLOv3 model we downloaded earlier.
Once the training starts,
ImageAI will generate detection_config.json file in the hololens/json folder. This JSON file will be used during detection of objects in images and videos
ImageAI will create hololens/models folder which is where all generated models will be saved
You will see at the log like the sample details below.
In the sample log shown above, new models are saved based on the decrease in the validation loss (E.g — loss: 5.2569) . In most cases, the lower the loss, the more accurate the model will be detecting objects in images and videos. However, some models may experience overfitting and still have lower losses. To ensure that you pick the best model for your custom detection, ImageAI allows you to evaluate the mAP (mean Average Precision, read more about it here) of all the trained models saved in the hololens/models folder.
The higher the mAP, the better the detection accuracy of the model.
Simple run the code below on the models saved during the training.
When you run the above code, you get a result like the example below.
Model File: hololens/models/detection_model-ex-07--loss-4.42.h5
Using IoU : 0.5
Using Object Threshold : 0.3
Using Non-Maximum Suppression : 0.5
hololens: 0.9231
mAP: 0.9231
===============================
Model File: hololens/models/detection_model-ex-10--loss-3.95.h5
Using IoU : 0.5
Using Object Threshold : 0.3
Using Non-Maximum Suppression : 0.5
hololens: 0.9725
mAP: 0.9725
===============================
Model File: hololens/models/detection_model-ex-05--loss-5.26.h5
Using IoU : 0.5
Using Object Threshold : 0.3
Using Non-Maximum Suppression : 0.5
hololens: 0.9204
mAP: 0.9204
===============================
Let’s breakdown the evaluation code:
In the first 4 lines, we import the same training class, created the class instance, set the detection model type and and set the path to our dataset’s directory.
In the 5th line, we called the .evaluateModel function and specified the parameters below
— model_path: This is the path to the folder containing our models. It can also be the filepath to a specific model.
— json_file: This is the path to the detection_config.json file saved during the training.
— iou_threshold: This is our desired minimum Intersection over Union value for the mAP computation. It can be set to values between 0.0 to 1.0
— object_threshold: This is our desired minimum class score for the mAP computation. It can be set to values between 0.0 to 1.0.
— nms_threshold: This is our desired Non-maximum suppression for the mAP computation.
Step 5 — Detecting our custom Object in an image
Now that we have trained our custom model to detect the Hololens headset, we will use the best model saved as well as the detection_config.json file generated to detect the object in an image.
Let’s take the above sample image to test our trained custom hololens detection model.
We have provided an already trained Hololens detection model for you to test. Download the model and the corresponding detection_config.json file via the links below.
On a final note, ImageAI also allows you to use your custom detection model to detect objects in videos and perform video analysis as well. See the documentations and the sample codes links provided below.
If you will like to know everything about how object detection works with links to more useful and practical resources, visit the Object Detection Guide linked below.
The ImageAI project and this tutorial brought to you by DeepQuest AI.
At DeepQuest AI, our mission we chose to accept is to advance and democratize Artificial Intelligence, and make it accessible to every individual and organization on the planet.
Our Mission which we choose to accept is to advance and democratize Artificial Intelligence and make it accessible to every individual and corporate entity of all sizes everywhere on the planet. https://www.deepquestai.com
Our Mission which we choose to accept is to advance and democratize Artificial Intelligence and make it accessible to every individual and corporate entity of all sizes everywhere on the planet. https://www.deepquestai.com