yufan lu
Created February 28, 2022 © Apache-2.0

All-in-one Self-adaptive Computing Platform for Smart City

Dynamically adjust the performance in real time by model size, processing branch, inference interval, and hardware configuration.

AdvancedOver 8 days250

Things used in this project

Hardware components

Kria KV260 Vision AI Starter Kit
AMD-Xilinx Kria KV260 Vision AI Starter Kit
×1
Zynq UltraScale+ MPSoC ZCU104
AMD-Xilinx Zynq UltraScale+ MPSoC ZCU104
×1
camera for kv260 (MIPI)
×1
Amozo 4K HDMI Video Capture Card, USB 3.0 Game Capture Card 1080P Capture Adapter for Streaming, Teaching, Video Conference or Live Broadcasting(Black)
×1
Audio / Video Cable Assembly, Ultra Slim RedMere HDMI to HDMI
Audio / Video Cable Assembly, Ultra Slim RedMere HDMI to HDMI
×1
LCD Monitor, Widescreen
LCD Monitor, Widescreen
×1

Software apps and online services

Vivado Design Suite
AMD-Xilinx Vivado Design Suite
Vitis Unified Software Platform
AMD-Xilinx Vitis Unified Software Platform
Vivado Design Suite HLx Editions
AMD-Xilinx Vivado Design Suite HLx Editions
PetaLinux
AMD-Xilinx PetaLinux
AMD-Xilinx VVAS
AMD-Xilinx Vitis AI

Story

Read more

Schematics

Main repo for Adaptive-Computing-Challenge-2021

Code

Shell to start 1080P mode

SH
video=/home/petalinux/videos/cars1900.nv12.h264
branch1="reid"
source=file
conf_pre_onlyresize="\"/opt/xilinx/share/ivas/cmpk/preprocess/resize_smartcam.json\""
conf_pre_seg="\"/opt/xilinx/share/ivas/cmpk/segmentation/preprocess_seg_smartcam.json\""
conf_pre_seg=$conf_pre_onlyresize
conf_dpu_seg="\"/opt/xilinx/share/ivas/cmpk/segmentation/dpu_seg.json\""
conf_draw_seg="\"/opt/xilinx/share/ivas/cmpk/segmentation/drawSegmentationTR.json\""

while getopts f:br:i:sh opt
do  
    case $opt in
        f)
            video=$OPTARG
            ;;
        b)
            segback="black"
            ;;
        r)  
            branch1="$OPTARG"
            ;;
        s)
            sync="true"
            echo $sync
            ;;
        i)
            source=$OPTARG
            ;;
        :)
            echo "-$OPTARG needs an argument"
            ;;
        h) 
            echo ""
            echo "Help:" 
            echo "-f video file source"
            echo "-b (optional) segmentation use black background"
            echo "-r (optional) model for branch 1  [(reid), openopse]"
            echo ""
            ;;
        *)  
            echo "-$opt not recognized"
            ;;
    esac
done

if [ $source == "usb" ]; then
    source_cmd=""
    source_cmd=$source_cmd"! video/x-raw, width=1920, height=1080"
    source_cmd=$source_cmd"! videoconvert ! video/x-raw, format=NV12"
elif [ $source == "mipi" ]; then 
    source_cmd="mediasrcbin media-device=/dev/media0 v4l2src0::io-mode=dmabuf v4l2src0::stride-align=256 !video/x-raw, width=1920, height=1080, format=NV12, framerate=30/1"
elif [ $source == "file" ]; then
    source_cmd="multifilesrc location=\"${video}\" ! h264parse ! queue ! omxh264dec ! video/x-raw, format=NV12, framerate=30/1"
else
    echo "unsupport video source :$source [usb,mipi,file]."
    exit -1
fi

echo $source_cmd

if [ -f $video ]; then
    echo "find video: $video"
else
    echo "cant find video file: $video"
    exit -1
fi


ivas_xfilter="! queue ! ivas_xfilter kernels-config="

if [ $branch1 == "reid" ]; then
    branch1firstmodel="\"/opt/xilinx/share/ivas/aibox-reid/refinedet.json\""
    branch1crop="\"/opt/xilinx/share/ivas/aibox-reid/crop.json\""
    branch1model="\"/opt/xilinx/share/ivas/cmpk/reid/reid.json\""
    branch1draw="\"/opt/xilinx/share/ivas/cmpk/reid/draw_reid.json\""
    branch1cmd="$ivas_xfilter $branch1firstmodel $ivas_xfilter $branch1crop $ivas_xfilter $branch1model"
    echo "branch 1: use reid"
elif [ $branch1 == "carid" ]; then
    branch1firstmodel="\"/opt/xilinx/share/ivas/smartcam/myapp/dpu_yolo2.json\""
    branch1crop="\"/opt/xilinx/share/ivas/aibox-reid/crop.json\""
    branch1model="\"/opt/xilinx/share/ivas/cmpk/reid/reid.json\""
    branch1draw="\"/opt/xilinx/share/ivas/cmpk/reid/draw_reid.json\""
    branch1cmd="$ivas_xfilter $branch1firstmodel $ivas_xfilter $branch1crop $ivas_xfilter $branch1model"
    echo "branch 1: use reid"
elif [ $branch1 == "openpose" ]; then
    branch1firstmodel="\"/opt/xilinx/share/ivas/aibox-reid/refinedet.json\""
    branch1crop="\"/opt/xilinx/share/ivas/cmpk/openpose/crop.json\""
    branch1model="\"/opt/xilinx/share/ivas/cmpk/openpose/openpose.json\""
    branch1draw="\"/opt/xilinx/share/ivas/cmpk/openpose/draw_pose.json\""
    branch1cmd="$ivas_xfilter $branch1firstmodel $ivas_xfilter $branch1crop $ivas_xfilter $branch1model"
    echo "branch 1: use openopse"
elif [ $branch1 == "yolo" ]; then
    branch1firstmodel="\"/opt/xilinx/share/ivas/smartcam/myapp/dpu_yolo2.json\""
    branch1cmd="$ivas_xfilter $branch1firstmodel"
    branch1draw="\"/opt/xilinx/share/ivas/smartcam/myapp/drawbox.json\""
else
    echo error
    exit -2
fi






gst-launch-1.0 \
$source_cmd \
! tee name=t  \
    ! queue ! ivas_xmultisrc kconfig=$conf_pre_onlyresize  \
    $branch1cmd  \
    ! ima.sink_master ivas_xmetaaffixer name=ima ima.src_master ! fakesink  \
t. \
    ! queue \
    ! ivas_xmultisrc kconfig=$conf_pre_seg  \
    ! queue \
    ! ivas_xfilter kernels-config=$conf_dpu_seg  \
    ! ima2.sink_master ivas_xmetaaffixer name=ima2 ima2.src_master \
    ! fakesink  \
t. \
    ! queue \
    ! ima.sink_slave_0 ima.src_slave_0  \
    ! queue \
    ! ivas_xfilter kernels-config=$branch1draw \
    ! queue  \
    ! ima2.sink_slave_0 ima2.src_slave_0  \
    ! queue ! ivas_xfilter kernels-config=$conf_draw_seg  \
! queue ! ivas_xfilter kernels-config="/opt/xilinx/share/ivas/smartcam/myapp/drawPower.json"  \
! queue ! ivas_xfilter kernels-config="/opt/xilinx/share/ivas/smartcam/myapp/drawTemp.json" \
! queue ! ivas_xfilter kernels-config="/opt/xilinx/share/ivas/smartcam/myapp/drawPerformance.json" \
! queue ! kmssink driver-name=xlnx plane-id=39 sync=false fullscreen-overlay=true 

Shell to start 4k mode

SH
#! /bin/sh
video=/home/petalinux
segback="ori"
branch1="reid"
sync="false"
input="file"

conf_pre_onlyresize="\"/opt/xilinx/share/ivas/cmpk/preprocess/resize_reid.json\""
conf_pp1_status="\"/opt/xilinx/share/ivas/cmpk/runstatus/pp1status.json\""
conf_pp2_status="\"/opt/xilinx/share/ivas/cmpk/runstatus/pp2status.json\""
conf_pp1_recordfps="\"/opt/xilinx/share/ivas/branch1/fpsbranch1.json\""
conf_pp2_recordfps="\"/opt/xilinx/share/ivas/branch2/fpsbranch2.json\""
conf_dpu_seg="\"/opt/xilinx/share/ivas/cmpk/segmentation/dpu_seg.json\""
conf_draw_seg="\"/opt/xilinx/share/ivas/cmpk/segmentation/drawSegmentation.json\""

while getopts f:br:sh opt
do  
    case $opt in
        f)
            video=$OPTARG
            ;;
        b)
            segback="black"
            ;;
        r)  
            branch1="$OPTARG"
            ;;
        s)
            sync="true"
            echo $sync
            ;;

        :)
            echo "-$OPTARG needs an argument"
            ;;
        h) 
            echo ""
            echo "Help:" 
            echo "-f video file source"
            echo "-b (optional) segmentation use black background"
            echo "-r (optional) model for branch 1  [(reid), openopse]"
            echo ""
            ;;
        *)  
            echo "-$opt not recognized"
            ;;
    esac
done



if [ $input == "file" ]; then

    if [ -f $video ]; then
        echo "find video: $video"
    else
        echo "cant find video file: $video"
        exit -1
    fi

    input_source="multifilesrc location=\"${video}\" ! h264parse ! queue ! omxh264dec ! video/x-raw, format=NV12"
elif [ $input == "mipi" ]; then 
    input_source="mediasrcbin media-device=/dev/media0 v4l2src0::io-mode=dmabuf v4l2src0::stride-align=256 !video/x-raw, width=1920, height=1080, format=NV12, framerate=30/1"
else
    echo "unsupport video source :$source [mipi,file]."
    exit -1
fi


if [ $sync == 'false' ]; then
    videosrc_cmd="multifilesrc location=\"${video}\" ! h264parse ! queue ! omxh264dec ! video/x-raw, format=NV12"
    tee1_name="maintee1"
    tee2_name="maintee2"
    teeseg_name="tseg"
    tee1_cmd=$videosrc_cmd"!tee name=$tee1_name"
    tee2_cmd=$videosrc_cmd"!tee name=$tee2_name"
    teeseg_cmd=$videosrc_cmd"!tee name=$teeseg_name"
    echo $tee1_cmd
    echo $tee2_cmd
    echo $teeseg_cmd
else
    echo "sync video pipeline (fps will drops)"
    tee1_name="maintee"
    tee2_name=$tee1_name
    teeseg_name=$tee1_name
    tee1_cmd=$videosrc_cmd"!tee name=$tee1_name"
    tee2_cmd="$tee2_name."
    teeseg_cmd="$teeseg_name."
    echo tee2_cmd
fi


if [ $segback == "black" ]; then
    segbackcmd="multifilesrc location=\"/home/petalinux/videos/black.nv12.h264\" ! h264parse ! queue ! omxh264dec ! video/x-raw, format=NV12"
    echo "use black background for segmentation."
else
    segbackcmd="$teeseg_name."
    echo "use original background for segmentation."
fi

if [ $branch1 == "reid" ]; then
    branch1crop="\"/opt/xilinx/share/ivas/aibox-reid/crop.json\""
    branch1model="\"/opt/xilinx/share/ivas/aibox-reid/reid.json\""
    branch1draw="\"/opt/xilinx/share/ivas/aibox-reid/draw_reid.json\""
    echo "branch 1: use reid"
elif [ $branch1 == "openpose" ]; then
    branch1crop="\"/opt/xilinx/share/ivas/cmpk/openpose/crop.json\""
    branch1model="\"/opt/xilinx/share/ivas/cmpk/openpose/openpose.json\""
    branch1draw="\"/opt/xilinx/share/ivas/cmpk/openpose/draw_pose.json\""
    echo "branch 1: use openopse"
else
    echo "branch 1: unsported model: $branch1 [(reid), openpose]"
    exit 2
fi


echo | modetest -M xlnx -D b0000000.v_mix -s 52@40:3840x2160@NV16
gst-launch-1.0 \
    $input_source \
    ! tee name=$tee1_name  \
        ! queue \
        ! ivas_xmultisrc kconfig=$conf_pre_onlyresize  \
        ! queue ! ivas_xfilter name=refinedet kernels-config="/opt/xilinx/share/ivas/aibox-reid/refinedet.json"  \
        ! queue ! ivas_xfilter name=crop kernels-config=$branch1crop  \
        ! queue ! ivas_xfilter kernels-config=$branch1model \
        ! ima.sink_master ivas_xmetaaffixer name=ima ima.src_master ! fakesink  \
    $tee1_name. \
    ! queue \
    ! ima.sink_slave_0 ima.src_slave_0  \
    ! queue ! ivas_xfilter kernels-config=$branch1draw  \
    ! queue ! ivas_xfilter kernels-config=$conf_pp1_status    \
    ! queue ! ivas_xfilter kernels-config=$conf_pp1_recordfps \
    ! queue ! kmssink bus-id=b0000000.v_mix plane-id=34 render-rectangle="<0,1080,1920,1080>" show-preroll-frame=false sync=false \
    \
    $tee2_cmd  \
        ! queue ! ivas_xmultisrc kconfig=$conf_pre_onlyresize  \
        ! queue ! ivas_xfilter kernels-config="/opt/xilinx/share/ivas/branch2/dpu_yolo2.json"  \
        ! imacar.sink_master ivas_xmetaaffixer name=imacar imacar.src_master ! fakesink  \
    $tee2_name. \
        ! queue \
        ! imacar.sink_slave_0 imacar.src_slave_0  \
        ! queue ! ivas_xfilter kernels-config="/opt/xilinx/share/ivas/branch2/drawbox.json"  \
        ! queue ! ivas_xfilter kernels-config=$conf_pp2_status    \
        ! queue ! ivas_xfilter kernels-config=$conf_pp2_recordfps  \
        ! queue ! kmssink bus-id=b0000000.v_mix plane-id=36 render-rectangle="<1920,1080,1920,1080>" show-preroll-frame=false sync=false \
    \
    $teeseg_cmd  \
        ! queue ! ivas_xmultisrc kconfig=$conf_pre_onlyresize  \
        ! queue ! ivas_xfilter kernels-config=$conf_dpu_seg  \
        ! imaseg.sink_master ivas_xmetaaffixer name=imaseg imaseg.src_master ! fakesink  \
    $segbackcmd \
        ! queue \
        ! imaseg.sink_slave_0 imaseg.src_slave_0  \
        ! queue ! ivas_xfilter kernels-config=$conf_draw_seg  \
        ! queue ! kmssink bus-id=b0000000.v_mix plane-id=35 render-rectangle="<0,0,1920,1080>" show-preroll-frame=false sync=false \
    \
    multifilesrc location="/home/petalinux/videos/back_logo.nv12.h264" \
    ! h264parse ! queue ! omxh264dec ! video/x-raw, format=NV12 ! queue \
    ! ivas_xfilter kernels-config="/opt/xilinx/share/ivas/cmpk/analysis/4K/drawPower.json"  ! queue \
    ! ivas_xfilter kernels-config="/opt/xilinx/share/ivas/cmpk/analysis/4K/drawTemp.json" ! queue \
    ! ivas_xfilter kernels-config="/opt/xilinx/share/ivas/cmpk/analysis/4K/drawPLTemp.json" ! queue \
    ! ivas_xfilter kernels-config="/opt/xilinx/share/ivas/cmpk/analysis/4K/drawfpsB1.json" ! queue \
    ! ivas_xfilter kernels-config="/opt/xilinx/share/ivas/cmpk/analysis/4K/drawfpsB2.json" ! queue \
    ! kmssink bus-id=b0000000.v_mix plane-id=37 render-rectangle="<1920,0,1920,1080>" show-preroll-frame=false sync=false \
    

Python example of host program

Python
copy from the Jupyter. It may need modification to run
import os
import threading
import time


class FIFOSendObj():
    _instance_dict = {}
    busy = False
    timeout = 1
    
    def __new__(cls, write_path, *args, **kw):
        if(write_path in cls._instance_dict.keys()):
            return cls._instance_dict[write_path]
        cls._instance_dict[write_path] = object.__new__(cls)
        return cls._instance_dict[write_path]
        
    def __init__(self,write_path, timeout = 1, *args, **kw):
        self.write_path =  write_path
        self.timeout = timeout
        
    def writeData2FIFO(self,msg):
        if(self.busy):
            print("Bus is busy")
            return
        
        self.busy = True
        self.istimeout = True
        def writefifodata(write_path,msg):
            if(not os.path.exists(write_path)):
                os.mkfifo(write_path)
            fifo_write_fd = open(write_path, 'w', 1 )
            protect = open(write_path, 'r')
            fifo_write_fd.write(msg)  
            fifo_write_fd.flush()
            fifo_write_fd.close()
            time.sleep(0.2)
            protect.close()
            self.istimeout = False
#             print("write finished")
        
        self.t1 = threading.Thread(target=writefifodata,args=(self.write_path,msg))
        self.t1.start()
        self.t1.join(self.timeout)
        if(os.path.exists(self.write_path)):
            os.remove(self.write_path)
        self.busy = False
        if(self.istimeout):
            print("write fifo timeout!")
            return False
#             
        else:
            return True
            


class kv260adpModelCtr(object):
   
    modelname = ""
    modelpath = ""
    modelclass = ""
    enable_str = ["ON","1"]
    disable_str = ["OFF","0"]
    
    def __init__(self,write_path="",*args, **kw):
        self.write_path = write_path
        self.timeout = 1;
        
        
    def checkModelfile(self):
        if(self.modelname == "" or self.modelpath==""):
            assert self.write_path != "" ,"model file path unset"

        if(not os.path.exists(os.path.join(self.modelpath,self.modelname,self.modelname+'.xmodel'))):
            assert self.write_path != "" ,"xmodel file does not exist!"

        if(not os.path.exists(os.path.join(self.modelpath,self.modelname,self.modelname+'.prototxt'))):
            assert self.write_path != "" ,"prototxt file does not exist!"
        return True
    
    def checkModelClass(self):
        vaildclasses=['YOLOV3','FACEDETECT','CLASSIFICATION','SSD','REID','REFINEDET','TFSSD','YOLOV2','ROADLINE','SEGMENTATION']
        if(self.modelclass not in vaildclasses):
            assert self.write_path != "" ,"invalid class, please use valid calss name:{}".format(vaildclasses)
           
        return True
    
    def checkWritePath(self):
        assert self.write_path != "" ,"please set write path"
     
    def resetWritePath(self, write_path):
        if(write_path != ""):
            self.write_path = write_path;
        self.checkWritePath()
        
# =====================================================================================
    def setNewModel(self,modelname, modelclass, modelpath, write_path = ""):
        self.resetWritePath(write_path)
        header = "switch2model" 
        self.modelname = modelname
        self.modelpath = modelpath
        self.modelclass = modelclass
        self.checkModelfile()
        self.checkModelClass()
        cmd = "{},{},{},{}".format(header,self.modelname,self.modelclass,self.modelpath)
        fifosend = FIFOSendObj(self.write_path,self.timeout)
        fifosend.writeData2FIFO(cmd)      
        
    def setNewREIDModel(self,modelname,modelpath,write_path = ""):
        self.resetWritePath(write_path)
        header = "switch2reidmodel" 
        self.modelname = modelname
        self.modelpath = modelpath
        
        if(not self.checkModelfile()):
            return
        
        cmd = "{},{},{}".format(header,self.modelname,self.modelpath)
        fifosend = FIFOSendObj(self.write_path,self.timeout)
        fifosend.writeData2FIFO(cmd)
        
    def setDPUInvteral(self,inverteral,write_path = ""):
        self.resetWritePath(write_path)
        inverteral = int(inverteral)
        header = "pluginCtr_invteral" 
        if(inverteral<1):
            print("invalid value:",inverteral)
            return
        fifosend = FIFOSendObj(self.write_path,self.timeout)
        fifosend.writeData2FIFO('{},{}'.format(header,inverteral))
    
    
    def setDPUenable(self,enable,write_path = ""):
        self.resetWritePath(write_path)
        header = "pluginCtr_DPUenable" 
        
        
        if str(enable).upper() in self.enable_str:
            ctr = 1
        elif str(enable).upper() in self.disable_str:
            ctr = 0
        else:
            print("invaild",str(enable).upper(),)
            return
            
        fifosend = FIFOSendObj(self.write_path,self.timeout)
        fifosend.writeData2FIFO('{},{}'.format(header,ctr))
        
    def setIndicaterUI(self,on,write_path = ""):
        self.resetWritePath(write_path)
        
        if(on == "ON" or on == 1 or on == "on"):
            status = 1;
        else:
            status = 0; 
   
        
        header = "runindicater" 
        fifosend = FIFOSendObj(self.write_path,self.timeout)
        fifosend.writeData2FIFO('{},{}'.format(header,status))
        
    def getFPSfromFile(self, file):
        f = open(file)
        line = f.readline()
#         print("fps:",line)
        return float(str(line))
        
    def getSegmentationResult(self,file):
        f = open(file)
        line = f.readline()
        rescnt = []
        p_sum = 0
        for s in line.split(','):
            rescnt.append(int(s))
            p_sum += int(s)
        
        res_normal = [x/p_sum for x in rescnt]
    
        car_related = rescnt[13] + rescnt[14] + rescnt[15] + rescnt[17]
        people_related = rescnt[18] + rescnt[11] + rescnt[12]
               
        k1 = 0.1
        k2 = 0.1
        k3 = 0.2
        k4 = 1.5
        if(car_related < k1 and people_related < k2 ):
            if(rescnt[0]> k3):
                return 'car'
            else:
                return None
        
        
        if(car_related > people_related * 1.5):
            return 'car'
        else:
            return 'people'
    

    
def getSegRes_FFC():
        classification = {-1:"unknown",0:"people",1:"car",2:"road"}
        result = -1
        read_path = "/home/petalinux/.temp/segresults"
        rf = os.open(read_path, os.O_RDONLY)
        s = b''
        while True:
            try:
                s += os.read(rf, 1024)
                if(len(s) >= 1024):
                    continue 
    #             print("received msg:",len(s),s)
                for string in s.split():
                    info = str(string,encoding = "utf-8").split(',')
                    if(info[0] == 'reportSeg' and int(info[1]) in classification.keys()):
                        result = int(info[1])
                break
            except NameError as error: 
                print(error) 
                break

        os.close(rf)
        os.remove(read_path)
        return result
    
        
        
def reidSwtichModel():
    reid_models = [["carid","/opt/xilinx/share/vitis_ai_library/models/B3136/"],
                   ["personreid-res18_pt","/opt/xilinx/share/vitis_ai_library/models/kv260-aibox-reid/"],
                   ["RN18_08","/opt/xilinx/share/vitis_ai_library/models/B3136/carid/"],
                   ["RN18_06","/opt/xilinx/share/vitis_ai_library/models/B3136/carid/"],
                   ["RN18_04","/opt/xilinx/share/vitis_ai_library/models/B3136/carid/"],
                   ["RN18_02","/opt/xilinx/share/vitis_ai_library/models/B3136/carid/"]]
    reid_modelctr = kv260adpModelCtr("/home/petalinux/.temp/reidrx")
    reid_modelctr.setNewREIDModel(reid_models[5][0],reid_models[5][1])

def segmentationSwtichModel():
    modelctr = kv260adpModelCtr("/home/petalinux/.temp/dpu_seg_rx")
    modelctr.setNewModel("SemanticFPN_cityscapes_256_512","SEGMENTATION","/opt/xilinx/share/vitis_ai_library/models/B3136/")
    modelctr.setNewModel("ENet_cityscapes_pt","SEGMENTATION","/opt/xilinx/share/vitis_ai_library/models/B3136/")
    modelctr.setDPUInvteral(10)



def branchSwitch(maxcnt = -1):
    
    # READ
    FFC_SEG_RES = "/home/petalinux/.temp/segresults"
    FFC_FPS_HB = '/home/petalinux/.temp/pf_tx'
    FILE_FPS = '/home/petalinux/.temp/fps'
    FILE_FPS1 = '/home/petalinux/.temp/fps_branch1'
    FILE_FPS2 = '/home/petalinux/.temp/fps_branch2'
    FILE_SEGMENTATION = '/home/petalinux/.temp/segres'
    # WRITE
    FFC_UI_BRANCH1 = '/home/petalinux/.temp/runstatus1_rx'
    FFC_UI_BRANCH2 = '/home/petalinux/.temp/runstatus2_rx'  
    FFC_DPU_BRANCH_CAR_CTR = '/home/petalinux/.temp/dpu_yolo_rx'
    FFC_DPU_BRANCH_PEO_CTR ='/home/petalinux/.temp/dpu_refinedet_rx'
    FFC_DPU_SEG_CTR = '/home/petalinux/.temp/dpu_seg_rx'

    lastseg = -1
    traffic_modelctr = kv260adpModelCtr()
    traffic_modelctr.setDPUInvteral(30,FFC_DPU_SEG_CTR)
    while(maxcnt != 0):
#         fps1 = traffic_modelctr.getFPSfromFile(FILE_FPS1)
#         fps2 = traffic_modelctr.getFPSfromFile(FILE_FPS2)
        maxcnt -= 1
        seg = getSegRes_FFC()
#         seg = traffic_modelctr.getSegmentationResult(FILE_SEGMENTATION)
        if lastseg != seg:
            print("do switch",lastseg,seg)
            lastseg = seg
            if(seg in [0]):
                traffic_modelctr.setIndicaterUI('on',FFC_UI_BRANCH2)
                traffic_modelctr.setIndicaterUI('off',FFC_UI_BRANCH1)
                traffic_modelctr.setDPUenable('on',FFC_DPU_BRANCH_CAR_CTR)
                traffic_modelctr.setDPUenable('off',FFC_DPU_BRANCH_PEO_CTR)

            elif(seg in [1]):
                traffic_modelctr.setIndicaterUI('on',FFC_UI_BRANCH1)
                traffic_modelctr.setIndicaterUI('off',FFC_UI_BRANCH2)
                traffic_modelctr.setDPUenable('off',FFC_DPU_BRANCH_CAR_CTR)
                traffic_modelctr.setDPUenable('on',FFC_DPU_BRANCH_PEO_CTR)
   
        time.sleep(1) 
    
# traffic_modelctr.setDPUenable('0',FFC_DPU_BRANCH_PEO_CTR)
# traffic_modelctr.setDPUenable('on',FFC_DPU_BRANCH_CAR_CTR)
# traffic_modelctr.setDPUenable('on',FFC_DPU_BRANCH_CAR_CTR)
# traffic_modelctr.setDPUInvteral(30,FFC_DPU_SEG_CTR)
# branchSwitch()
# getSegRes_FFC()
def reidSwtichModel(i):
    reid_models = [["RN18_08","/opt/xilinx/share/vitis_ai_library/models/B3136/carid/"],
                   ["RN18_06","/opt/xilinx/share/vitis_ai_library/models/B3136/carid/"],
                   ["RN18_04","/opt/xilinx/share/vitis_ai_library/models/B3136/carid/"],
                   ["RN18_02","/opt/xilinx/share/vitis_ai_library/models/B3136/carid/"],
                  ["personreid-res18_pt","/opt/xilinx/share/vitis_ai_library/models/kv260-aibox-reid/"]]
    reid_modelctr = kv260adpModelCtr("/home/petalinux/.temp/reidrx")
    reid_modelctr.setNewREIDModel(reid_models[i][0],reid_models[i][1])

JSON configurations for VVAS

JSON
No preview (download only).

Main repo for Adaptive-Computing-Challenge-2021

Shell, Python, C++ and other needed files

New VVAS libs - C Source Codes

Source code to generate VVAS libs

Credits

yufan lu

yufan lu

1 project • 3 followers
PhD student.
Thanks to DTennant and mit-han-lab.

Comments