219 lines
6.5 KiB
Bash
Executable File
219 lines
6.5 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# DISPENSION CONFIDENTIAL
|
|
#
|
|
# [2020] - [2021] Dispension Industries Limited.
|
|
# Portions Copyright © 2014-2020 Atlantean Technical Solutions Limited
|
|
# with full licensing rights granted to Dispension & Successors.
|
|
#
|
|
# All Rights Reserved.
|
|
#
|
|
# NOTICE: All information contained herein is, and remains
|
|
# the property of Dispension Industries Limited.
|
|
# The intellectual and technical concepts contained
|
|
# herein are proprietary to Dispension Industries Limited
|
|
# and its suppliers and may be covered by U.S. and Foreign Patents,
|
|
# patents in process, and are protected by trade secret or copyright law.
|
|
# Dissemination of this information or reproduction of this material
|
|
# is strictly forbidden unless prior written permission is obtained
|
|
# from Dispension Industries Limited.
|
|
#
|
|
|
|
# OK just so were clear, this is a pretty complicated lib. This is due
|
|
# to all the various tools we are obliged to use due to various tech
|
|
# we've been asked to implement, some of which is proprietary, most
|
|
# of which is experimental and ALL of which is huge.
|
|
# See doc for more details.
|
|
#
|
|
# sudo pip3 install openvino opencv-python yolov5 yolov8
|
|
|
|
. awesome_venv/bin/activate
|
|
|
|
HERE=$PWD
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
|
cd $DIR/..
|
|
|
|
# Read in UKDI and determine basic PATHs etc
|
|
function f_read_ukdi(){
|
|
cat /etc/ukdi.json |\
|
|
tr -d '"'| sed 's/,$//'|\
|
|
awk '{ if (NF>1){print "export UKDI_"$1"=\""$2"\"" } }' |\
|
|
sed 's/://' > var/gen.ukdi
|
|
chmod +x var/gen.ukdi
|
|
. var/gen.ukdi
|
|
|
|
export ZZZ=5
|
|
export UKDIHOST=`echo $UKDI_ukdi|tr '/:,' ' '| awk '{print $2}'`
|
|
export UKDIPORT=`echo $UKDI_ukdi|tr '/:,' ' '| awk '{print $3}'`
|
|
export YOLOHOST=`echo $UKDI_yolo|tr '/:,' ' '| awk '{print $2}'`
|
|
export YOLOPORT=`echo $UKDI_yolo|tr '/:,' ' '| awk '{print $3}'`
|
|
export CORE=$PWD/../core
|
|
export UKDI=$PWD/../ukdi
|
|
export YOLO=$PWD/../yoloserv
|
|
|
|
cat<<EOF
|
|
UKDIHOST=$UKDIHOST
|
|
UKDIPORT=$UKDIPORT
|
|
YOLOHOST=$YOLOHOST
|
|
YOLOPORT=$YOLOPORT
|
|
CORE=$CORE
|
|
UKDI=$UKDI
|
|
EOF
|
|
}
|
|
f_read_ukdi
|
|
|
|
ZZZ=5
|
|
mkdir -p $UKDI_yolo_indir
|
|
mkdir -p $UKDI_yolo_outdir
|
|
|
|
|
|
# Determina all the possible libs based on whats in UKDI_yolo_devices
|
|
PYP_OPENVINO="modules"
|
|
LIB_OPENVINO="modules/openvino/inference_engine/lib/intel64/:\
|
|
modules/openvino/inference_engine:\
|
|
modules/openvino/python3.10/dist-packages/openvino/libs:\
|
|
modules/openvino/python3.10/dist-packages/openvino/inference_engine"
|
|
PYP_PARAVISION="modules"
|
|
PYP_DEEPFACE="modules"
|
|
PYP_YOLOV5="modules/yolov5-face_Jan1"
|
|
LIB_SEEK="modules/seek/Seekware_SDK_3.6.0.0/lib/x86_64-linux-gnu/"
|
|
|
|
# WHich libs are loaded depends on the YOLO device list
|
|
LLP="."
|
|
PYP="."
|
|
echo "UKDI_yolo_devices = $UKDI_yolo_devices"
|
|
for i in `echo $UKDI_yolo_devices| tr ',' ' '`
|
|
do
|
|
case $i in
|
|
"paravision") LLP="$LLP:$LIB_OPENVINO"
|
|
PYP="$PYP:$PYP_OPENVINO:$PYP_PARAVISION"
|
|
;;
|
|
"yolov5") LLP="$LLP:$LIB_OPENVINO"
|
|
PYP="$PYP:$PYP_YOLOV5"
|
|
;;
|
|
"deepface") LLP="$LLP:$LIB_DEEPFACE"
|
|
PYP="$PYP:$PYP_DEEPFACE"
|
|
;;
|
|
"seek") LLP="$LLP:$LIB_SEEK"
|
|
PYP="$PYP:src"
|
|
;;
|
|
"face_recognition") LLP="$LLP:$LIB_DEEPFACE"
|
|
PYP="$PYP:$PYP_DEEPFACE"
|
|
;;
|
|
"camera") ;;
|
|
*) echo "yoloserv does not implement backend $i. Edit /etc/ukdi.json::yolo_devices and try again."
|
|
exit 1
|
|
esac
|
|
done
|
|
echo "PYTHONPATH = $PYP"
|
|
export LD_LIBRARY_PATH="$LLP"
|
|
export PYTHONPATH="$PYP"
|
|
export WEIGHTS="$DIR/../modules/yolov5-face_Jan1/runs/train/exp/weights/yolov5m6_face.pt"
|
|
|
|
|
|
# # # #### ##### ## # #
|
|
# ## # # # # # # #
|
|
# # # # #### # # # # #
|
|
# # # # # # ###### # #
|
|
# # ## # # # # # # #
|
|
# # # #### # # # ###### ######
|
|
|
|
# Install all the components.
|
|
# There are many of them and they are all different.
|
|
# Some are proprietary, so check your licensing (ask Matt)
|
|
function f_apt(){
|
|
apt update
|
|
apt upgrade
|
|
apt install libopencv-dev python3-opencv
|
|
pip3 install --upgrade pip
|
|
pip3 install yolov5
|
|
pip3 install yolov8
|
|
pip3 install deepface
|
|
|
|
apt install libopencv-dev python3-opencv
|
|
pip3 install deepface
|
|
#REGULA..
|
|
apt install pcscd libccid
|
|
wget -O downloads/regula.deb https://downloads.regulaforensics.com/repo/ubuntu/pool/stable/r/regula-reader/regula-reader_6.7.198393.16246_amd64.deb
|
|
wget -O downloads/drivers.deb https://downloads.regulaforensics.com/repo/ubuntu/pool/stable/r/regula-drivers/regula-drivers_2.1.1.12_amd64.deb
|
|
dpkg --install downloads/regula.deb
|
|
|
|
sudo pip3 install openvino
|
|
|
|
# bypass paravision
|
|
# . /usr/local/lib/python3.10/dist-packages/
|
|
# ROOTURL="http://824f668f-5c6e-4ffe-8b5b-edb4d0301982:985c5412-5e0d-4d66-8d28-ed32dbb900a3@paravision.mycloudrepo.io"
|
|
# pip3 install cmake --upgrade
|
|
# pip3 install --no-cache-dir\
|
|
# --extra-index-url $ROOTURL/repositories/python-sdk\
|
|
# --extra-index-url $ROOTURL/repositories/python-recognition\
|
|
# "paravision-recognition" "paravision-models-gen5-balanced-openvino-2022-3" "openvino==2022.3"\
|
|
# --trusted-host paravision.mycloudrepo.io
|
|
|
|
|
|
wget -O downloads/facerec.zip https://github.com/ageitgey/face_recognition/archive/refs/heads/master.zip
|
|
cd downloads
|
|
unzip facerec.zip
|
|
cd $HERE
|
|
}
|
|
|
|
function f_apt_intox(){
|
|
make -f sbin/Makefile
|
|
}
|
|
|
|
|
|
|
|
|
|
#### #### # # ##### ##### #### #
|
|
# # # # ## # # # # # # #
|
|
# # # # # # # # # # # #
|
|
# # # # # # # ##### # # #
|
|
# # # # # ## # # # # # #
|
|
#### #### # # # # # #### ######
|
|
|
|
function f_test(){
|
|
mkdir -p $UKDI_yolo_indir
|
|
cp testimg/* $UKDI_yolo_indir
|
|
# echo "loading messi 1"
|
|
wget "http://localhost:$YOLOPORT/svc_load_face/messi1/messi1.jpg"
|
|
}
|
|
|
|
function f_start(){
|
|
echo PPPPPPPPPPPp
|
|
echo $PYTHONPATH
|
|
echo $$ > var/yoloserv.pid
|
|
while [ -e var/yoloserv.pid ]
|
|
do
|
|
python3 src/yoloserv.py $YOLOPORT $UKDI_yolo_indir $UKDI_yolo_outdir $WEIGHTS
|
|
sleep $ZZZ
|
|
done
|
|
}
|
|
|
|
function f_stop(){
|
|
rm var/yoloserv.pid
|
|
wget http://localhost:$YOLOPORT/shutdown
|
|
}
|
|
|
|
|
|
echo "Running $0 with option $1 at $DIR"
|
|
case $1 in
|
|
|
|
"apt") f_apt
|
|
;;
|
|
"start") f_start
|
|
;;
|
|
"restart") f_stop
|
|
f_start
|
|
;;
|
|
"reload") f_reload
|
|
;;
|
|
"stop") f_stop
|
|
;;
|
|
*) echo "Error. $1 is not a $0 command."
|
|
;;
|
|
esac
|
|
|
|
|
|
|
|
cd $HERE
|