prep yoloserv for zeeshan

This commit is contained in:
carl 2023-09-07 11:09:02 -03:00
parent 3e94989618
commit a99b24c41e
2 changed files with 44 additions and 52 deletions

View File

@ -40,64 +40,21 @@ echo "PYTHONPATH = $PYTHONPATH"
# There are many of them and they are all different. # There are many of them and they are all different.
# Some are proprietary, so check your licensing (ask Matt) # Some are proprietary, so check your licensing (ask Matt)
function f_apt(){ function f_apt(){
apt update
apt upgrade
apt install libopencv-dev python3-opencv
pip3 install --upgrade pip
pip3 install yolov5
pip3 install yolov8
case $1 in # Regula
"updates") apt update
apt upgrade
apt install libopencv-dev python3-opencv
python3 -m pip install --upgrade pip
;;
"regula") f_apt_regula
;;
"yolov5") f_apt_yolov5
;;
"yolov8") f_apt_yolov8
;;
"paravision") f_apt_paravision
;;
"deepface") pip3 install deepface
;;
"freeface") f_apt_facerec
;;
"paraface") f_apt_regula
f_apt_yolov5
f_apt_paravision
;;
"intox") f_apt_yolov5
f_apt_intox
;;
*) echo "Error. Second parameter must be updates|regula|yolov5|paravision|freeface|paraface|palm|intox"
;;
esac
}
function f_apt_regula(){
apt install pcscd libccid 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/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 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 dpkg --install downloads/regula.deb
}
function f_apt_yolov5(){
wget -O downloads/yolov5.zip https://github.com/ultralytics/yolov5/archive/refs/heads/master.zip
cd downloads
unzip yolov5.zip
cd $HERE
}
function f_apt_yolov8(){
wget -O downloads/yolov8.zip https://github.com/ultralytics/ultralytics/archive/refs/heads/main.zip
cd downloads
unzip yolov8.zip
cd $HERE
}
function f_apt_openvino(){
sudo pip3 install openvino sudo pip3 install openvino
}
function f_apt_paravision(){
# Needs openvino
. /usr/local/lib/python3.10/dist-packages/ . /usr/local/lib/python3.10/dist-packages/
ROOTURL="http://824f668f-5c6e-4ffe-8b5b-edb4d0301982:985c5412-5e0d-4d66-8d28-ed32dbb900a3@paravision.mycloudrepo.io" ROOTURL="http://824f668f-5c6e-4ffe-8b5b-edb4d0301982:985c5412-5e0d-4d66-8d28-ed32dbb900a3@paravision.mycloudrepo.io"
pip3 install cmake --upgrade pip3 install cmake --upgrade
@ -106,10 +63,10 @@ function f_apt_paravision(){
--extra-index-url $ROOTURL/repositories/python-recognition\ --extra-index-url $ROOTURL/repositories/python-recognition\
"paravision-recognition" "paravision-models-gen5-balanced-openvino-2022-3" "openvino==2022.3"\ "paravision-recognition" "paravision-models-gen5-balanced-openvino-2022-3" "openvino==2022.3"\
--trusted-host paravision.mycloudrepo.io --trusted-host paravision.mycloudrepo.io
}
function f_apt_facerec(){
# Open source Face_Recognition # Open source Face_Recognition
pip3 install deepface
wget -O downloads/facerec.zip https://github.com/ageitgey/face_recognition/archive/refs/heads/master.zip wget -O downloads/facerec.zip https://github.com/ageitgey/face_recognition/archive/refs/heads/master.zip
cd downloads cd downloads
unzip facerec.zip unzip facerec.zip

View File

@ -104,6 +104,12 @@ class yoloserv(object):
self.life_detector = Realsense() self.life_detector = Realsense()
self.life_detector.init() self.life_detector.init()
# Documents
if "regula" in self.device_list:
print("Loading regula...")
self.doc_detector = Regula()
self.doc_detector.init()
# Intoxication # Intoxication
if "intox" in self.device_list: if "intox" in self.device_list:
print("Loading intoxivision...") print("Loading intoxivision...")
@ -127,6 +133,35 @@ class yoloserv(object):
def svc_match_faces(self,infile1,infile2): def svc_match_faces(self,infile1,infile2):
return self.face_detector.detect(infile1,infile2) return self.face_detector.detect(infile1,infile2)
@cherrypy.expose
def facematch(self,dev1,dev2):
if self.conf["emulate_facematch"]:
return '{ "status":0, "remark":"OK(Emulated)", "data":{"device1":"%s","device2":"%s","device1_qual":123,"device2_qual":234,"match_score":600} }' % (dev1,dev2)
if dev1 == "regula":
img1 = "/tmp/regula/Portrait_0.jpg"
if dev1 == "localcam":
img1 = "/tmp/localcam.png"
if dev2 == "regula":
img2 = "/tmp/regula/Portrait_0.jpg"
if dev2 == "localcam":
img2 = "/tmp/localcam.png"
if self.conf["emulate_facematch"]:
return '{ "status":0, "remark":"OK", "data":{} }'
self.devices["facematch"].load(dev1, dev2, img1, img2)
status = self.devices["facematch"].get_faces()
if status is not None:
return '{ "status":777242, "remark":"face matching failed", "guilty_param":"facematch", "guilty_value":"%s" }' % (status)
status = self.devices["facematch"].compute_scores()
if status is not None:
return '{ "status":777243, "remark":"face scoring failed", "guilty_param":"facematch", "guilty_value":"%s" }' % (status)
jsonstr = self.devices["facematch"].get_scores()
return '{ "status":0, "remark":"OK", "data":%s }' % (jsonstr)